-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathGuidedTableColumn.java
More file actions
346 lines (319 loc) · 14.7 KB
/
GuidedTableColumn.java
File metadata and controls
346 lines (319 loc) · 14.7 KB
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
346
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/
package com.datadog.api.client.v1.model;
import com.datadog.api.client.AbstractOpenApiSchema;
import com.datadog.api.client.JSON;
import com.datadog.api.client.UnparsedObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import jakarta.ws.rs.core.GenericType;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@jakarta.annotation.Generated(
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
@JsonDeserialize(using = GuidedTableColumn.GuidedTableColumnDeserializer.class)
@JsonSerialize(using = GuidedTableColumn.GuidedTableColumnSerializer.class)
public class GuidedTableColumn extends AbstractOpenApiSchema {
private static final Logger log = Logger.getLogger(GuidedTableColumn.class.getName());
@JsonIgnore public boolean unparsed = false;
public static class GuidedTableColumnSerializer extends StdSerializer<GuidedTableColumn> {
public GuidedTableColumnSerializer(Class<GuidedTableColumn> t) {
super(t);
}
public GuidedTableColumnSerializer() {
this(null);
}
@Override
public void serialize(GuidedTableColumn value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException {
jgen.writeObject(value.getActualInstance());
}
}
public static class GuidedTableColumnDeserializer extends StdDeserializer<GuidedTableColumn> {
public GuidedTableColumnDeserializer() {
this(GuidedTableColumn.class);
}
public GuidedTableColumnDeserializer(Class<?> vc) {
super(vc);
}
@Override
public GuidedTableColumn deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
JsonNode tree = jp.readValueAsTree();
Object deserialized = null;
Object tmp = null;
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
int match = 0;
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
// deserialize GuidedTableComputeColumn
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (GuidedTableComputeColumn.class.equals(Integer.class)
|| GuidedTableComputeColumn.class.equals(Long.class)
|| GuidedTableComputeColumn.class.equals(Float.class)
|| GuidedTableComputeColumn.class.equals(Double.class)
|| GuidedTableComputeColumn.class.equals(Boolean.class)
|| GuidedTableComputeColumn.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((GuidedTableComputeColumn.class.equals(Integer.class)
|| GuidedTableComputeColumn.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((GuidedTableComputeColumn.class.equals(Float.class)
|| GuidedTableComputeColumn.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(GuidedTableComputeColumn.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(GuidedTableComputeColumn.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(GuidedTableComputeColumn.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
if (!((GuidedTableComputeColumn) tmp).unparsed) {
deserialized = tmp;
match++;
}
log.log(Level.FINER, "Input data matches schema 'GuidedTableComputeColumn'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'GuidedTableComputeColumn'", e);
}
// deserialize GuidedTablePresetColumn
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (GuidedTablePresetColumn.class.equals(Integer.class)
|| GuidedTablePresetColumn.class.equals(Long.class)
|| GuidedTablePresetColumn.class.equals(Float.class)
|| GuidedTablePresetColumn.class.equals(Double.class)
|| GuidedTablePresetColumn.class.equals(Boolean.class)
|| GuidedTablePresetColumn.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((GuidedTablePresetColumn.class.equals(Integer.class)
|| GuidedTablePresetColumn.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((GuidedTablePresetColumn.class.equals(Float.class)
|| GuidedTablePresetColumn.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(GuidedTablePresetColumn.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(GuidedTablePresetColumn.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(GuidedTablePresetColumn.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
if (!((GuidedTablePresetColumn) tmp).unparsed) {
deserialized = tmp;
match++;
}
log.log(Level.FINER, "Input data matches schema 'GuidedTablePresetColumn'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'GuidedTablePresetColumn'", e);
}
// deserialize GuidedTableFormulaColumn
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (GuidedTableFormulaColumn.class.equals(Integer.class)
|| GuidedTableFormulaColumn.class.equals(Long.class)
|| GuidedTableFormulaColumn.class.equals(Float.class)
|| GuidedTableFormulaColumn.class.equals(Double.class)
|| GuidedTableFormulaColumn.class.equals(Boolean.class)
|| GuidedTableFormulaColumn.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((GuidedTableFormulaColumn.class.equals(Integer.class)
|| GuidedTableFormulaColumn.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((GuidedTableFormulaColumn.class.equals(Float.class)
|| GuidedTableFormulaColumn.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(GuidedTableFormulaColumn.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(GuidedTableFormulaColumn.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(GuidedTableFormulaColumn.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
if (!((GuidedTableFormulaColumn) tmp).unparsed) {
deserialized = tmp;
match++;
}
log.log(Level.FINER, "Input data matches schema 'GuidedTableFormulaColumn'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'GuidedTableFormulaColumn'", e);
}
GuidedTableColumn ret = new GuidedTableColumn();
if (match == 1) {
ret.setActualInstance(deserialized);
} else {
Map<String, Object> res =
new ObjectMapper()
.readValue(
tree.traverse(jp.getCodec()).readValueAsTree().toString(),
new TypeReference<Map<String, Object>>() {});
ret.setActualInstance(new UnparsedObject(res));
}
return ret;
}
/** Handle deserialization of the 'null' value. */
@Override
public GuidedTableColumn getNullValue(DeserializationContext ctxt) throws JsonMappingException {
throw new JsonMappingException(ctxt.getParser(), "GuidedTableColumn cannot be null");
}
}
// store a list of schema names defined in oneOf
public static final Map<String, GenericType> schemas = new HashMap<String, GenericType>();
public GuidedTableColumn() {
super("oneOf", Boolean.FALSE);
}
public GuidedTableColumn(GuidedTableComputeColumn o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
public GuidedTableColumn(GuidedTablePresetColumn o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
public GuidedTableColumn(GuidedTableFormulaColumn o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
static {
schemas.put("GuidedTableComputeColumn", new GenericType<GuidedTableComputeColumn>() {});
schemas.put("GuidedTablePresetColumn", new GenericType<GuidedTablePresetColumn>() {});
schemas.put("GuidedTableFormulaColumn", new GenericType<GuidedTableFormulaColumn>() {});
JSON.registerDescendants(GuidedTableColumn.class, Collections.unmodifiableMap(schemas));
}
@Override
public Map<String, GenericType> getSchemas() {
return GuidedTableColumn.schemas;
}
/**
* Set the instance that matches the oneOf child schema, check the instance parameter is valid
* against the oneOf child schemas: GuidedTableComputeColumn, GuidedTablePresetColumn,
* GuidedTableFormulaColumn
*
* <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
* composed schema (allOf, anyOf, oneOf).
*/
@Override
public void setActualInstance(Object instance) {
if (JSON.isInstanceOf(GuidedTableComputeColumn.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(GuidedTablePresetColumn.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(GuidedTableFormulaColumn.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
throw new RuntimeException(
"Invalid instance type. Must be GuidedTableComputeColumn, GuidedTablePresetColumn,"
+ " GuidedTableFormulaColumn");
}
/**
* Get the actual instance, which can be the following: GuidedTableComputeColumn,
* GuidedTablePresetColumn, GuidedTableFormulaColumn
*
* @return The actual instance (GuidedTableComputeColumn, GuidedTablePresetColumn,
* GuidedTableFormulaColumn)
*/
@Override
public Object getActualInstance() {
return super.getActualInstance();
}
/**
* Get the actual instance of `GuidedTableComputeColumn`. If the actual instance is not
* `GuidedTableComputeColumn`, the ClassCastException will be thrown.
*
* @return The actual instance of `GuidedTableComputeColumn`
* @throws ClassCastException if the instance is not `GuidedTableComputeColumn`
*/
public GuidedTableComputeColumn getGuidedTableComputeColumn() throws ClassCastException {
return (GuidedTableComputeColumn) super.getActualInstance();
}
/**
* Get the actual instance of `GuidedTablePresetColumn`. If the actual instance is not
* `GuidedTablePresetColumn`, the ClassCastException will be thrown.
*
* @return The actual instance of `GuidedTablePresetColumn`
* @throws ClassCastException if the instance is not `GuidedTablePresetColumn`
*/
public GuidedTablePresetColumn getGuidedTablePresetColumn() throws ClassCastException {
return (GuidedTablePresetColumn) super.getActualInstance();
}
/**
* Get the actual instance of `GuidedTableFormulaColumn`. If the actual instance is not
* `GuidedTableFormulaColumn`, the ClassCastException will be thrown.
*
* @return The actual instance of `GuidedTableFormulaColumn`
* @throws ClassCastException if the instance is not `GuidedTableFormulaColumn`
*/
public GuidedTableFormulaColumn getGuidedTableFormulaColumn() throws ClassCastException {
return (GuidedTableFormulaColumn) super.getActualInstance();
}
}