22
22
import java .util .Optional ;
23
23
24
24
public class Locator {
25
+ final Map <String , Object > map = new HashMap <>();
26
+
25
27
private enum Type {
26
28
CSS ("css" ),
27
29
INNER ("innerText" ),
@@ -39,32 +41,22 @@ public String toString() {
39
41
}
40
42
}
41
43
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
-
52
44
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 ) ;
55
47
}
56
48
57
- public Locator (
49
+ private Locator (
58
50
Type type ,
59
51
String value ,
60
52
Optional <Boolean > ignoreCase ,
61
53
Optional <String > matchType ,
62
54
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 )) ;
68
60
}
69
61
70
62
public static Locator css (String value ) {
@@ -88,14 +80,6 @@ public static Locator xpath(String value) {
88
80
}
89
81
90
82
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
-
99
83
return map ;
100
84
}
101
85
}
0 commit comments