File tree 1 file changed +25
-1
lines changed
java/client/src/org/openqa/selenium/internal
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change 17
17
18
18
package org .openqa .selenium .internal ;
19
19
20
- public class Either <A , B > {
20
+ import java .util .Collections ;
21
+ import java .util .Iterator ;
22
+ import java .util .function .Function ;
23
+ import java .util .stream .Stream ;
24
+
25
+ public class Either <A , B > implements Iterable <B > {
21
26
private final A left ;
22
27
private final B right ;
23
28
@@ -49,4 +54,23 @@ public A left() {
49
54
public B right () {
50
55
return right ;
51
56
}
57
+
58
+ public <R > R map (Function <? super B , ? extends R > mapper ) {
59
+ Require .nonNull ("Mapper" , mapper );
60
+ return mapper .apply (right ());
61
+ }
62
+
63
+ public <R > R mapLeft (Function <? super A , ? extends R > mapper ) {
64
+ Require .nonNull ("Mapper" , mapper );
65
+ return mapper .apply (left ());
66
+ }
67
+
68
+ @ Override
69
+ public Iterator <B > iterator () {
70
+ return Collections .singleton (right ()).iterator ();
71
+ }
72
+
73
+ public Stream <B > stream () {
74
+ return Stream .of (right ());
75
+ }
52
76
}
You can’t perform that action at this time.
0 commit comments