1717
1818package org .openqa .selenium .bidi .script ;
1919
20- import java .util .Collections ;
2120import java .util .Map ;
2221import java .util .TreeMap ;
22+ import org .jspecify .annotations .Nullable ;
2323
24+ /**
25+ * @see <a href="https://www.w3.org/TR/webdriver-bidi/#type-script-ChannelValue">BiDi spec</a>
26+ */
2427public class ChannelValue extends LocalValue {
2528
2629 private final String channelId ;
27- private SerializationOptions options ;
28-
29- private ResultOwnership resultOwnership ;
30+ private final @ Nullable SerializationOptions options ;
31+ private final @ Nullable ResultOwnership resultOwnership ;
3032
3133 public ChannelValue (String channelId ) {
32- this . channelId = channelId ;
34+ this ( channelId , null , null ) ;
3335 }
3436
3537 public ChannelValue (String channelId , SerializationOptions options ) {
36- this .channelId = channelId ;
37- this .options = options ;
38+ this (channelId , options , null );
3839 }
3940
4041 public ChannelValue (String channelId , ResultOwnership resultOwnership ) {
41- this .channelId = channelId ;
42- this .resultOwnership = resultOwnership ;
42+ this (channelId , null , resultOwnership );
4343 }
4444
45- ChannelValue (String channelId , SerializationOptions options , ResultOwnership resultOwnership ) {
45+ ChannelValue (
46+ String channelId ,
47+ @ Nullable SerializationOptions options ,
48+ @ Nullable ResultOwnership resultOwnership ) {
4649 this .channelId = channelId ;
4750 this .options = options ;
4851 this .resultOwnership = resultOwnership ;
4952 }
5053
5154 @ Override
5255 public Map <String , Object > toJson () {
53- Map <String , Object > toReturn = new TreeMap <>();
54-
5556 Map <String , Object > channelProperties = new TreeMap <>();
56-
5757 channelProperties .put ("channel" , channelId );
5858
5959 if (options != null ) {
@@ -64,9 +64,6 @@ public Map<String, Object> toJson() {
6464 channelProperties .put ("ownership" , resultOwnership );
6565 }
6666
67- toReturn .put ("type" , "channel" );
68- toReturn .put ("value" , channelProperties );
69-
70- return Collections .unmodifiableMap (toReturn );
67+ return Map .of ("type" , "channel" , "value" , channelProperties );
7168 }
7269}
0 commit comments