File tree Expand file tree Collapse file tree 1 file changed +55
-0
lines changed
java/src/org/openqa/selenium/bidi/script Expand file tree Collapse file tree 1 file changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ package org .openqa .selenium .bidi .script ;
2+
3+ import static java .util .Collections .unmodifiableMap ;
4+ import static org .openqa .selenium .bidi .script .RemoteReference .RemoteReferenceType .HANDLE ;
5+ import static org .openqa .selenium .bidi .script .RemoteReference .RemoteReferenceType .SHARED_ID ;
6+
7+ import java .util .Map ;
8+ import java .util .TreeMap ;
9+
10+ public class RemoteReference extends LocalValue {
11+ public enum RemoteReferenceType {
12+ HANDLE ("handle" ),
13+ SHARED_ID ("sharedId" );
14+
15+ private final String type ;
16+
17+ RemoteReferenceType (String type ) {
18+ this .type = type ;
19+ }
20+
21+ @ Override
22+ public String toString () {
23+ return type ;
24+ }
25+ }
26+
27+ private String handle ;
28+ private String sharedId ;
29+
30+ public RemoteReference (String handle , String sharedId ) {
31+ this .handle = handle ;
32+ this .sharedId = sharedId ;
33+ }
34+
35+ public RemoteReference (RemoteReferenceType type , String value ) {
36+ if (HANDLE .equals (type )) {
37+ this .handle = value ;
38+ } else {
39+ this .sharedId = value ;
40+ }
41+ }
42+
43+ public Map <String , Object > asMap () {
44+ Map <String , String > toReturn = new TreeMap <>();
45+ if (handle != null ) {
46+ toReturn .put (HANDLE .toString (), this .handle );
47+ }
48+
49+ if (sharedId != null ) {
50+ toReturn .put (SHARED_ID .toString (), this .sharedId );
51+ }
52+
53+ return unmodifiableMap (toReturn );
54+ }
55+ }
You can’t perform that action at this time.
0 commit comments