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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345 | package Torello.Browser.JsonAST;
import Torello.Browser.JsonAST.TypeNode;
import Torello.Java.ReadOnly.ReadOnlyList;
import Torello.Java.ReadOnly.ReadOnlySet;
import Torello.Java.ReadOnly.ROTreeSetBuilder;
import Torello.Java.ReadOnly.ROArrayListBuilder;
import Torello.Java.UnreachableError;
import Torello.Java.StrCSV;
import Torello.Java.StrPrint;
/**
* <EMBED CLASS='external-html' DATA-FILE-ID=INFO_DATA>
* @see ExtraData
* @see SERIALIZED_AST#browserDat
* @see SERIALIZED_AST#jsDat
*/
@Torello.JavaDoc.Annotations.JDHeaderBackgroundImg(EmbedTagFileID="SERIALIZER_JDHBI")
public class InfoData implements java.io.Serializable
{
static InfoData.Builder builder() { return new InfoData.Builder(); }
/** <EMBED CLASS='external-html' DATA-FILE-ID=SVUID> */
protected static final long serialVersionUID = 1;
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Lists - The names of these lists *OUGHT TO* explain exatly what they are lists of ...
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
/**
* <EMBED CLASS='external-html' DATA-FILE-ID=ID_ELIM_TYPE_NODES>
* @see #simpleTypeNodes
* @see #enumValTypeNodes
*/
public final ReadOnlyList<TypeNode> eliminatedTypeNodes;
/** <EMBED CLASS='external-html' DATA-FILE-ID=ID_SIMPLE_TYPE_NODES> */
public final ReadOnlyList<TypeNode> simpleTypeNodes;
/** <EMBED CLASS='external-html' DATA-FILE-ID=ID_ENUM_VAL_TYPE_NODES> */
public final ReadOnlyList<TypeNode> enumValTypeNodes;
/** <EMBED CLASS='external-html' DATA-FILE-ID=ID_MARKER_EVENT_NODES> */
public final ReadOnlyList<EventNode> markerEventNodes;
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Sets - The names of these sets *OUGHT TO* explain exatly what they are lists of ...
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
/**
* <EMBED CLASS='external-html' DATA-FILE-ID=ID_HAS_ENUM_STR_LISTS>
* @see Entity#ownerDomain
* @see #enumValTypeNodes
*/
public final ReadOnlySet<Domain> hasEnumStrLists;
/**
* The list of domains which have at least one zero-property type (and were eliminated during
* the code generation step).
*/
public final ReadOnlySet<Domain> hasSimpleTypes;
/**
* <EMBED CLASS='external-html' DATA-FILE-ID=ID_HAS_MARKER_EVENTS>
* @see Entity#ownerDomain
* @see #markerEventNodes
*/
public final ReadOnlySet<Domain> hasMarkerEvents;
/**
* The set of all domains which have actual nested java inner classes defined within them.
* There are relatively few domains in the CDP API that do not actually define any types, though
* there are some.
*
* <BR /><BR />
* In the most recent parsing and generation of the "Browser API" from CDP, 41 out of the 47
* Domains have actual, reified, events. You may see the {@link #toString() toString Output}
* for this class by clicking the link.
*/
public final ReadOnlySet<Domain> hasReifiedTypes;
/**
* This should list all domains that have commands which return more than one value as a result
* of their invocation. Rather than return tuples of results, a dedicated nested-inner type is
* created for any CDP command that needs to actually return more than one value.
*/
public final ReadOnlySet<Domain> hasReifiedReturnTypes;
/**
* The set of all domains which have actual nested java inner classes defined within them.
* Event inner classes are not actually defined in any way that is different from standard
* inner types. Instead, they are just listed on their respective Java-Doc Pages as "Event
* Classes" which are only generated when the CDP API actually fires an event for them.
*
* <BR /><BR />
* In the most recent parsing and generation of the "Browser API" from CDP, 33 out of the 47
* Domains have actual, reified, events. You may see the {@link #toString() toString Output}
* for this class by clicking the link.
*/
public final ReadOnlySet<Domain> hasReifiedEvents;
// ********************************************************************************************
// ********************************************************************************************
// Constructor
// ********************************************************************************************
// ********************************************************************************************
InfoData(
final ReadOnlyList<TypeNode> eliminatedTypeNodes,
final ReadOnlyList<TypeNode> simpleTypeNodes,
final ReadOnlyList<TypeNode> enumValTypeNodes,
final ReadOnlyList<EventNode> markerEventNodes,
final ReadOnlySet<Domain> hasEnumStrLists,
final ReadOnlySet<Domain> hasSimpleTypes,
final ReadOnlySet<Domain> hasMarkerEvents,
final ReadOnlySet<Domain> hasReifiedTypes,
final ReadOnlySet<Domain> hasReifiedReturnTypes,
final ReadOnlySet<Domain> hasReifiedEvents
)
{
this.eliminatedTypeNodes = eliminatedTypeNodes;
this.simpleTypeNodes = simpleTypeNodes;
this.enumValTypeNodes = enumValTypeNodes;
this.markerEventNodes = markerEventNodes;
this.hasEnumStrLists = hasEnumStrLists;
this.hasSimpleTypes = hasSimpleTypes;
this.hasMarkerEvents = hasMarkerEvents;
this.hasReifiedTypes = hasReifiedTypes;
this.hasReifiedReturnTypes = hasReifiedReturnTypes;
this.hasReifiedEvents = hasReifiedEvents;
}
// ********************************************************************************************
// ********************************************************************************************
// toString
// ********************************************************************************************
// ********************************************************************************************
/**
* Generates a {@code String} representation of the contents of this {@code 'InfoData'}
* instance. The only two instances of {@code 'InfoData'} which are generated are the one for
* the "Browser API" along with the instance which represents Google's "JavaScript API"
*
* <BR /><BR />
* The "See Also" link below provides a direct link to the two fields within the class
* {@link SERIALIZED_AST} which contains a reference / pointer to an instance of this class.
*
* @return A {@code String} representation / summary of one of the two API's.
*
* @see SERIALIZED_AST#browserDat
* @see SERIALIZED_AST#jsDat
*/
public String toString()
{
return
"{\n" +
" this.hasEnumStrLists:" + list(this.hasEnumStrLists) +
" this.hasSimpleTypes:" + list(this.hasSimpleTypes) +
" this.hasMarkerEvents:" + list(this.hasMarkerEvents) +
" this.hasReifiedTypes:" + list(this.hasReifiedTypes) +
" this.hasReifiedEvents:" + list(this.hasReifiedEvents) +
'\n' +
" this.eliminatedTypeNodes.size(): " + this.eliminatedTypeNodes.size() + '\n' +
" this.simpleTypeNodes.size(): " + this.simpleTypeNodes.size() + '\n' +
" this.enumValTypeNodes.size(): " + this.enumValTypeNodes.size() + '\n' +
" this.markerEventNodes.size(): " + this.markerEventNodes.size() + '\n' +
'\n' +
" this.hasEnumStrLists.size(): " + this.hasEnumStrLists.size() + '\n' +
" this.hasSimpleTypes.size(): " + this.hasSimpleTypes.size() + '\n' +
" this.hasMarkerEvents.size(): " + this.hasMarkerEvents.size() + '\n' +
'n' +
" this.hasReifiedTypes.size(): " + this.hasReifiedTypes.size() + '\n' +
" this.hasReifiedReturnTypes.size(): " + this.hasReifiedReturnTypes.size() + '\n' +
" this.hasReifiedEvents.size(): " + this.hasReifiedEvents.size() + '\n' +
"}\n";
}
private static String list(final ReadOnlySet<Domain> domainList)
{
final String csv =
'\n' +
" " +
StrCSV.toCSV(domainList, (Domain d) -> d.name, true, null) +
'\n' +
'\n';
return StrPrint.wrapToIndentation(csv, 100);
}
// ********************************************************************************************
// ********************************************************************************************
// Builder
// ********************************************************************************************
// ********************************************************************************************
// When complicated data gets moving there is nothing more valuable than enuring that the code
// which is going to "use" your data (Here, AST data) - is final, immutable and read only.
//
// Using this "Builder" design pattern means that the "InfoData" class that is saved to disk
// so that the Code Generator can later retrieve it - CONTAINS NOTHING BUT FINAL, IMMUTABLE AND
// READ-ONLY DATA.
static class Builder
{
private Builder() { }
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Lists ==> The exact same lists as above, but as "ReadOnlyList Builders" instead
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
private final ROArrayListBuilder<TypeNode> eliminatedTypeNodesROALB =
new ROArrayListBuilder<>();
private final ROArrayListBuilder<TypeNode> simpleTypeNodesROALB =
new ROArrayListBuilder<>();
private final ROArrayListBuilder<TypeNode> enumValTypeNodesROALB =
new ROArrayListBuilder<>();
private final ROArrayListBuilder<EventNode> markerEventNodesROALB =
new ROArrayListBuilder<>();
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Sets ==> The exact same sets as above, but as "ReadOnlySet Builders" instead
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
private final ROTreeSetBuilder<Domain> hasEnumStrListsROTSB =
new ROTreeSetBuilder<>();
private final ROTreeSetBuilder<Domain> hasSimpleTypesROTSB =
new ROTreeSetBuilder<>();
private final ROTreeSetBuilder<Domain> hasMarkerEventsROTSB =
new ROTreeSetBuilder<>();
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// More Sets ==> Specifically for the "Reified Nested Types"
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
private final ROTreeSetBuilder<Domain> hasReifiedTypesROTSB =
new ROTreeSetBuilder<>();
private final ROTreeSetBuilder<Domain> hasReifiedReturnTypesROTSB =
new ROTreeSetBuilder<>();
private final ROTreeSetBuilder<Domain> hasReifiedEventsROTSB =
new ROTreeSetBuilder<>();
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Builder Methods that "add stuff" into this builder! (How the builder "builds")
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
void enumValType(final TypeNode tn)
{
if (tn.enumVals == null) throw new UnreachableError();
if (tn.isReifiedInnerClass) throw new UnreachableError();
enumValTypeNodesROALB.add(tn);
eliminatedTypeNodesROALB.add(tn);
hasEnumStrListsROTSB.add(tn.ownerDomain);
}
void simpleType(final TypeNode tn)
{
if (tn.isReifiedInnerClass) throw new UnreachableError();
if (tn.properties != null) throw new UnreachableError();
simpleTypeNodesROALB.add(tn);
eliminatedTypeNodesROALB.add(tn);
hasSimpleTypesROTSB.add(tn.ownerDomain);
}
void markerEvent(final EventNode en)
{
if (en.parameters != null) throw new UnreachableError();
markerEventNodesROALB.add(en);
hasMarkerEventsROTSB.add(en.ownerDomain);
}
void reifiedInnerType(final TypeNode tn)
{
if (! tn.isReifiedInnerClass) throw new UnreachableError();
if (tn.properties == null) throw new UnreachableError();
if (tn.properties.size() == 0) throw new UnreachableError();
hasReifiedTypesROTSB.add(tn.ownerDomain);
}
void reifiedReturnType(final CommandNode cn)
{
if (! cn.hasReifiedRetInnerClass) throw new UnreachableError();
if (cn.returns == null) throw new UnreachableError();
if (cn.returns.size() <= 1) throw new UnreachableError();
hasReifiedReturnTypesROTSB.add(cn.ownerDomain);
}
void reifiedEvent(final EventNode en)
{
if (! en.isReifiedInnerClass) throw new UnreachableError();
if (en.parameters == null) throw new UnreachableError();
if (en.parameters.size() == 0) throw new UnreachableError();
hasReifiedEventsROTSB.add(en.ownerDomain);
}
InfoData build()
{
return new InfoData(
eliminatedTypeNodesROALB.build(),
simpleTypeNodesROALB.build(),
enumValTypeNodesROALB.build(),
markerEventNodesROALB.build(),
hasEnumStrListsROTSB.build(),
hasSimpleTypesROTSB.build(),
hasMarkerEventsROTSB.build(),
hasReifiedTypesROTSB.build(),
hasReifiedReturnTypesROTSB.build(),
hasReifiedEventsROTSB.build()
);
}
}
}
|