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
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$$ExceptionDetails$$
    implements NestedHelper<RunTime.ExceptionDetails>
{
    // ********************************************************************************************
    // ********************************************************************************************
    // Constructor, Singleton & "Reflection"
    // ********************************************************************************************
    // ********************************************************************************************


    // Simple Constructor, used *ONLY* to construct the singleton instance, directly below
    private RunTime$$ExceptionDetails$$() { }

    // Single Instance of this class.  How all the instance methods are invoked, statically
    public static final RunTime$$ExceptionDetails$$ singleton = new RunTime$$ExceptionDetails$$();

    // Pointer / Reference to the Domain's Nested-Class which is being 'helped' by this class.
    public static final Class<RunTime.ExceptionDetails> baseTypeClass =
        RunTime.ExceptionDetails.class;

    // Stores simple Reflection Information about RunTime.ExceptionDetails
    public static final NestedDescriptor<RunTime.ExceptionDetails> descriptor;

    static
    {
        // The names of each field in this helper class
        final ReadOnlyList<String> names = new ReadOnlyArrayList<>(
            String.class, "exceptionId", "text", "lineNumber", "columnNumber", "scriptId", "url",
            "stackTrace", "exception", "executionContextId", "exceptionMetaData"
        );

        // Type of each field, stored using the constants in Torello.Browser.CDPTypes
        final ReadOnlyList<Byte> types = new ReadOnlyArrayList<>(
            Byte.class, PRIMITIVE_INT, STRING, PRIMITIVE_INT, PRIMITIVE_INT, STRING, STRING,
            CDP_TYPE, CDP_TYPE, BOXED_INTEGER, RAW_JSON_VALUE
        );

        // Whether each field is optional or not, as defined in Google's CDP Specs
        final ReadOnlyList<Boolean> optionals = new ReadOnlyArrayList<>
            (Boolean.class, false, false, false, false, true, true, true, 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, false, false, false, false, false, true);

        descriptor = new NestedDescriptor<>(
            Domains.RunTime, "ExceptionDetails", names, types, optionals, experimentals,
            baseTypeClass
        );
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Simple Getters & Helpers
    // ********************************************************************************************
    // ********************************************************************************************


    // Can be used to generate an instance using the advanced 'TypeBuilder' class
    public NestedDescriptor<RunTime.ExceptionDetails> descriptor()
    { return descriptor; }

    // Build the 'isPresent' read-only list using the class' current assigned values
    public ReadOnlyList<Boolean> generateIsPresentList(final RunTime.ExceptionDetails THIS)
    {
        return new ReadOnlyArrayList<>(
            Boolean.class,
            THIS.exceptionId        == DV.NULL_INT,
            THIS.text               == null,
            THIS.lineNumber         == DV.NULL_INT,
            THIS.columnNumber       == DV.NULL_INT,
            THIS.scriptId           == null,
            THIS.url                == null,
            THIS.stackTrace         == null,
            THIS.exception          == null,
            THIS.executionContextId == null,
            THIS.exceptionMetaData  == null
        );
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // java.lang.Object Methods
    // ********************************************************************************************
    // ********************************************************************************************


    // Checks whether 'THIS' equals an input Java-Object
    public boolean equals(final RunTime.ExceptionDetails 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.ExceptionDetails.class) return false;

        final RunTime.ExceptionDetails O = (RunTime.ExceptionDetails) OTHER;

        return
                (THIS.exceptionId == O.exceptionId)
            &&  Objects.equals(THIS.text, O.text)
            &&  (THIS.lineNumber == O.lineNumber)
            &&  (THIS.columnNumber == O.columnNumber)
            &&  Objects.equals(THIS.scriptId, O.scriptId)
            &&  Objects.equals(THIS.url, O.url)
            &&  Objects.equals(THIS.stackTrace, O.stackTrace)
            &&  Objects.equals(THIS.exception, O.exception)
            &&  Objects.equals(THIS.executionContextId, O.executionContextId)
            &&  Objects.equals(THIS.exceptionMetaData, O.exceptionMetaData);
    }

    // Generates a Hash-Code for 'THIS' instance
    public int hashCode(final RunTime.ExceptionDetails THIS)
    {
        return
                THIS.exceptionId
            +   ((THIS.text == null) ? 0 : THIS.text.hashCode())
            +   THIS.lineNumber
            +   THIS.columnNumber
            +   ((THIS.scriptId == null) ? 0 : THIS.scriptId.hashCode())
            +   ((THIS.url == null) ? 0 : THIS.url.hashCode())
            +   Objects.hashCode(THIS.stackTrace)
            +   Objects.hashCode(THIS.exception)
            +   ((THIS.executionContextId == null) ? 0 : THIS.executionContextId.intValue())
            +   Objects.hashCode(THIS.exceptionMetaData);
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Json Methods
    // ********************************************************************************************
    // ********************************************************************************************


    // Converts this instance to JSON
    public void toJSON(
            final RunTime.ExceptionDetails  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: int (CDPTypes.PRIMITIVE_INT), *IS NOT* optional
            if (THIS.exceptionId == Integer.MIN_VALUE) jGen.writeNull();
            else jGen.write("exceptionId", THIS.exceptionId);
        }

        if (isPresent.get(1))
        {
            // Writing Type: String (CDPTypes.STRING), *IS NOT* optional
            if (THIS.text == null)  jGen.writeNull();
            else                    jGen.write("text", THIS.text);
        }

        if (isPresent.get(2))
        {
            // Writing Type: int (CDPTypes.PRIMITIVE_INT), *IS NOT* optional
            if (THIS.lineNumber == Integer.MIN_VALUE) jGen.writeNull();
            else jGen.write("lineNumber", THIS.lineNumber);
        }

        if (isPresent.get(3))
        {
            // Writing Type: int (CDPTypes.PRIMITIVE_INT), *IS NOT* optional
            if (THIS.columnNumber == Integer.MIN_VALUE) jGen.writeNull();
            else jGen.write("columnNumber", THIS.columnNumber);
        }

        if (isPresent.get(4))
        {
            // Writing Type: String (CDPTypes.STRING), *IS* optional
            if (THIS.scriptId == null)  jGen.writeNull();
            else                        jGen.write("scriptId", THIS.scriptId);
        }

        if (isPresent.get(5))
        {
            // Writing Type: String (CDPTypes.STRING), *IS* optional
            if (THIS.url == null)   jGen.writeNull();
            else                    jGen.write("url", THIS.url);
        }

        if (isPresent.get(6))
        {
            // Writing Type: RunTime.StackTrace (CDPTypes.CDP_TYPE), *IS* optional
            if (THIS.stackTrace == null)    jGen.writeNull();
            else                            THIS.stackTrace.toJSON("stackTrace", jGen);
        }

        if (isPresent.get(7))
        {
            // Writing Type: RunTime.RemoteObject (CDPTypes.CDP_TYPE), *IS* optional
            if (THIS.exception == null) jGen.writeNull();
            else                        THIS.exception.toJSON("exception", jGen);
        }

        if (isPresent.get(8))
        {
            // Writing Type: Integer (CDPTypes.BOXED_INTEGER), *IS* optional
            if (THIS.executionContextId == null)    jGen.writeNull();
            else                                    jGen.write("executionContextId", THIS.executionContextId.intValue());
        }

        if (isPresent.get(9))
        {
            // Writing Type: JsonValue (CDPTypes.RAW_JSON_VALUE), *IS* optional
            if (THIS.exceptionMetaData == null) jGen.writeNull();
            else                                jGen.write("exceptionMetaData", THIS.exceptionMetaData);
        }
    }

    // Generates an instance of this class, using a JsonObject as input
    public RunTime.ExceptionDetails fromJSON(final JsonObject jo)
    {
        final ReadOnlyList<Boolean> isPresent = new ReadOnlyArrayList<>(
            Boolean.class,
            jo.containsKey("exceptionId"),
            jo.containsKey("text"),
            jo.containsKey("lineNumber"),
            jo.containsKey("columnNumber"),
            jo.containsKey("scriptId"),
            jo.containsKey("url"),
            jo.containsKey("stackTrace"),
            jo.containsKey("exception"),
            jo.containsKey("executionContextId"),
            jo.containsKey("exceptionMetaData")
        );

        return new RunTime.ExceptionDetails(
            isPresent,
            ReadBoxedJSON.getInteger(jo, "exceptionId", JFlag.RD_N | JFlag.RD_M, DV.NULL_INT),
            ReadJSON.getString(jo, "text", true, false),
            ReadBoxedJSON.getInteger(jo, "lineNumber", JFlag.RD_N | JFlag.RD_M, DV.NULL_INT),
            ReadBoxedJSON.getInteger(jo, "columnNumber", JFlag.RD_N | JFlag.RD_M, DV.NULL_INT),
            ReadJSON.getString(jo, "scriptId", true, false),
            ReadJSON.getString(jo, "url", true, false),
            ReadJSON.getObject(
                jo, "stackTrace",
                RunTime.StackTrace::fromJSON,
                RunTime.StackTrace.class,
                true, false
            ),
            ReadJSON.getObject(
                jo, "exception",
                RunTime.RemoteObject::fromJSON,
                RunTime.RemoteObject.class,
                true, false
            ),
            ReadBoxedJSON.getInteger(jo, "executionContextId", true),
            jo.get("exceptionMetaData")
        );
    }


    // ********************************************************************************************
    // ********************************************************************************************
    // Enumerated String Constant Fields' Issues
    // ********************************************************************************************
    // ********************************************************************************************


    // None of the fields inside this class are of an enumerated string type
    private static final ReadOnlyMap<String, ReadOnlyList<String>> allEnumStrs =
        ReadOnlyTreeMap.emptyROTM();

    // Utilized by abstract ancestor 'BaseType'
    public ReadOnlyMap<String, ReadOnlyList<String>> allEnumStrROLs()
    { return allEnumStrs; }

    // None of the fields inside this class have an enumerated string type
    public IntStream enumStrValidate(final RunTime.ExceptionDetails THIS)
    { return IntStream.empty(); }
}