1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238 | package Torello.Browser.JavaScriptAPI.NestedHelpers.Types;
import static Torello.Browser.CDPTypes.*;
import Torello.JSON.*;
import Torello.Java.ReadOnly.*;
import Torello.Browser.*;
import Torello.Browser.BrowserAPI.*;
import Torello.Browser.JavaScriptAPI.*;
import Torello.Browser.helper.*;
import javax.json.JsonObject;
import javax.json.stream.JsonGenerator;
import java.util.Objects;
import java.util.Arrays;
import java.util.stream.IntStream;
public class RunTime$$DeepSerializedValue$$
implements NestedHelper<RunTime.DeepSerializedValue>
{
// ********************************************************************************************
// ********************************************************************************************
// Constructor, Singleton & "Reflection"
// ********************************************************************************************
// ********************************************************************************************
// Simple Constructor, used *ONLY* to construct the singleton instance, directly below
private RunTime$$DeepSerializedValue$$() { }
// Single Instance of this class. How all the instance methods are invoked, statically
public static final RunTime$$DeepSerializedValue$$ singleton =
new RunTime$$DeepSerializedValue$$();
// Pointer / Reference to the Domain's Nested-Class which is being 'helped' by this class.
public static final Class<RunTime.DeepSerializedValue> baseTypeClass =
RunTime.DeepSerializedValue.class;
// Stores simple Reflection Information about RunTime.DeepSerializedValue
public static final NestedDescriptor<RunTime.DeepSerializedValue> descriptor;
static
{
// The names of each field in this helper class
final ReadOnlyList<String> names = new ReadOnlyArrayList<>
(String.class, "type", "value", "objectId", "weakLocalObjectReference");
// Type of each field, stored using the constants in Torello.Browser.CDPTypes
final ReadOnlyList<Byte> types =
new ReadOnlyArrayList<>(Byte.class, STRING, RAW_JSON_VALUE, STRING, BOXED_INTEGER);
// Whether each field is optional or not, as defined in Google's CDP Specs
final ReadOnlyList<Boolean> optionals =
new ReadOnlyArrayList<>(Boolean.class, false, true, true, true);
// Whether each field is experimental or not, as defined in Google's CDP Specs
final ReadOnlyList<Boolean> experimentals =
new ReadOnlyArrayList<>(Boolean.class, false, false, false, false);
descriptor = new NestedDescriptor<>(
Domains.RunTime, "DeepSerializedValue", names, types, optionals, experimentals,
baseTypeClass
);
}
// ********************************************************************************************
// ********************************************************************************************
// Simple Getters & Helpers
// ********************************************************************************************
// ********************************************************************************************
// Can be used to generate an instance using the advanced 'TypeBuilder' class
public NestedDescriptor<RunTime.DeepSerializedValue> descriptor()
{ return descriptor; }
// Build the 'isPresent' read-only list using the class' current assigned values
public ReadOnlyList<Boolean> generateIsPresentList(final RunTime.DeepSerializedValue THIS)
{
return new ReadOnlyArrayList<>(
Boolean.class,
THIS.type == null,
THIS.value == null,
THIS.objectId == null,
THIS.weakLocalObjectReference == null
);
}
// ********************************************************************************************
// ********************************************************************************************
// java.lang.Object Methods
// ********************************************************************************************
// ********************************************************************************************
// Checks whether 'THIS' equals an input Java-Object
public boolean equals(final RunTime.DeepSerializedValue THIS, final Object OTHER)
{
if (THIS == OTHER) return true;
if (OTHER == null) return false;
// This equals expects that the instance be of the exact class
if (OTHER.getClass() != RunTime.DeepSerializedValue.class) return false;
final RunTime.DeepSerializedValue O = (RunTime.DeepSerializedValue) OTHER;
return
Objects.equals(THIS.type, O.type)
&& Objects.equals(THIS.value, O.value)
&& Objects.equals(THIS.objectId, O.objectId)
&& Objects.equals(THIS.weakLocalObjectReference, O.weakLocalObjectReference);
}
// Generates a Hash-Code for 'THIS' instance
public int hashCode(final RunTime.DeepSerializedValue THIS)
{
return
((THIS.type == null) ? 0 : THIS.type.hashCode())
+ Objects.hashCode(THIS.value)
+ ((THIS.objectId == null) ? 0 : THIS.objectId.hashCode())
+ ((THIS.weakLocalObjectReference == null) ? 0 : THIS.weakLocalObjectReference.intValue());
}
// ********************************************************************************************
// ********************************************************************************************
// Json Methods
// ********************************************************************************************
// ********************************************************************************************
// Converts this instance to JSON
public void toJSON(
final RunTime.DeepSerializedValue THIS,
final String name,
final JsonGenerator jGen
)
{
final ReadOnlyList<Boolean> isPresent = THIS.isPresent();
if (name != null) jGen.writeStartObject(name);
else jGen.writeStartObject();
if (isPresent.get(0))
{
// Writing Type: String (CDPTypes.STRING), *IS NOT* optional
if (THIS.type == null) jGen.writeNull();
else jGen.write("type", THIS.type);
}
if (isPresent.get(1))
{
// Writing Type: JsonValue (CDPTypes.RAW_JSON_VALUE), *IS* optional
if (THIS.value == null) jGen.writeNull();
else jGen.write("value", THIS.value);
}
if (isPresent.get(2))
{
// Writing Type: String (CDPTypes.STRING), *IS* optional
if (THIS.objectId == null) jGen.writeNull();
else jGen.write("objectId", THIS.objectId);
}
if (isPresent.get(3))
{
// Writing Type: Integer (CDPTypes.BOXED_INTEGER), *IS* optional
if (THIS.weakLocalObjectReference == null) jGen.writeNull();
else jGen.write("weakLocalObjectReference", THIS.weakLocalObjectReference.intValue());
}
}
// Generates an instance of this class, using a JsonObject as input
public RunTime.DeepSerializedValue fromJSON(final JsonObject jo)
{
final ReadOnlyList<Boolean> isPresent = new ReadOnlyArrayList<>(
Boolean.class,
jo.containsKey("type"),
jo.containsKey("value"),
jo.containsKey("objectId"),
jo.containsKey("weakLocalObjectReference")
);
return new RunTime.DeepSerializedValue(
isPresent,
ReadJSON.getString(jo, "type", true, false),
jo.get("value"),
ReadJSON.getString(jo, "objectId", true, false),
ReadBoxedJSON.getInteger(jo, "weakLocalObjectReference", true)
);
}
// ********************************************************************************************
// ********************************************************************************************
// Enumerated String Constant Fields' Issues
// ********************************************************************************************
// ********************************************************************************************
// Permitted String-Values for the field: type
public static final ReadOnlyList<String> type$$ = new ReadOnlyArrayList<>(
String.class,
"array", "arraybuffer", "bigint", "boolean", "date", "error", "function", "generator",
"map", "node", "null", "number", "object", "promise", "proxy", "regexp", "set", "string",
"symbol", "typedarray", "undefined", "weakmap", "weakset", "window"
);
private static final ReadOnlyMap<String, ReadOnlyList<String>> allEnumStrs;
static
{
final ROTreeMapBuilder<String, ReadOnlyList<String>> rotmb = new ROTreeMapBuilder<>();
rotmb.put("type", type$$);
allEnumStrs = rotmb.build();
}
// Utilized by abstract ancestor 'BaseType'
public ReadOnlyMap<String, ReadOnlyList<String>> allEnumStrROLs()
{ return allEnumStrs; }
// Checks all string fields, whose values are limited to an enumerated set
public IntStream enumStrValidate(final RunTime.DeepSerializedValue THIS)
{
final IntStream.Builder b = IntStream.builder();
if (! type$$.contains(THIS.type)) b.accept(0);
return b.build();
}
}
|