Skip to content

Commit baf6116

Browse files
committed
[bidi][java] Update Locator class to not use optional
1 parent 309b3e8 commit baf6116

File tree

1 file changed

+10
-26
lines changed
  • java/src/org/openqa/selenium/bidi/browsingcontext

1 file changed

+10
-26
lines changed

java/src/org/openqa/selenium/bidi/browsingcontext/Locator.java

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.Optional;
2323

2424
public class Locator {
25+
final Map<String, Object> map = new HashMap<>();
26+
2527
private enum Type {
2628
CSS("css"),
2729
INNER("innerText"),
@@ -39,32 +41,22 @@ public String toString() {
3941
}
4042
}
4143

42-
private final Type type;
43-
44-
private final String value;
45-
46-
private Optional<Boolean> ignoreCase = Optional.empty();
47-
48-
private Optional<String> matchType = Optional.empty();
49-
50-
private Optional<Long> maxDepth = Optional.empty();
51-
5244
private Locator(Type type, String value) {
53-
this.type = type;
54-
this.value = value;
45+
map.put("type", type.toString());
46+
map.put("value", value);
5547
}
5648

57-
public Locator(
49+
private Locator(
5850
Type type,
5951
String value,
6052
Optional<Boolean> ignoreCase,
6153
Optional<String> matchType,
6254
Optional<Long> maxDepth) {
63-
this.type = type;
64-
this.value = value;
65-
this.ignoreCase = ignoreCase;
66-
this.matchType = matchType;
67-
this.maxDepth = maxDepth;
55+
map.put("type", type.toString());
56+
map.put("value", value);
57+
ignoreCase.ifPresent(val -> map.put("ignoreCase", val));
58+
matchType.ifPresent(val -> map.put("matchType", val));
59+
maxDepth.ifPresent(val -> map.put("maxDepth", val));
6860
}
6961

7062
public static Locator css(String value) {
@@ -88,14 +80,6 @@ public static Locator xpath(String value) {
8880
}
8981

9082
public Map<String, Object> toMap() {
91-
final Map<String, Object> map = new HashMap<>();
92-
map.put("type", type.toString());
93-
map.put("value", value);
94-
95-
ignoreCase.ifPresent(val -> map.put("ignoreCase", val));
96-
matchType.ifPresent(val -> map.put("matchType", val));
97-
maxDepth.ifPresent(val -> map.put("maxDepth", val));
98-
9983
return map;
10084
}
10185
}

0 commit comments

Comments
 (0)