Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25656,9 +25656,9 @@ components:
WidgetTime:
description: Time setting for the widget.
oneOf:
- $ref: '#/components/schemas/WidgetLegacyLiveSpan'
- $ref: '#/components/schemas/WidgetNewLiveSpan'
- $ref: '#/components/schemas/WidgetNewFixedSpan'
- $ref: '#/components/schemas/WidgetLegacyLiveSpan'
WidgetTimeWindows:
description: Define a time window.
enum:
Expand Down
138 changes: 69 additions & 69 deletions src/main/java/com/datadog/api/client/v1/model/WidgetTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,51 +77,6 @@ public WidgetTime deserialize(JsonParser jp, DeserializationContext ctxt)
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
int match = 0;
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
// deserialize WidgetLegacyLiveSpan
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (WidgetLegacyLiveSpan.class.equals(Integer.class)
|| WidgetLegacyLiveSpan.class.equals(Long.class)
|| WidgetLegacyLiveSpan.class.equals(Float.class)
|| WidgetLegacyLiveSpan.class.equals(Double.class)
|| WidgetLegacyLiveSpan.class.equals(Boolean.class)
|| WidgetLegacyLiveSpan.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((WidgetLegacyLiveSpan.class.equals(Integer.class)
|| WidgetLegacyLiveSpan.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((WidgetLegacyLiveSpan.class.equals(Float.class)
|| WidgetLegacyLiveSpan.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(WidgetLegacyLiveSpan.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(WidgetLegacyLiveSpan.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(WidgetLegacyLiveSpan.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 (!((WidgetLegacyLiveSpan) tmp).unparsed) {
deserialized = tmp;
match++;
}
log.log(Level.FINER, "Input data matches schema 'WidgetLegacyLiveSpan'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'WidgetLegacyLiveSpan'", e);
}

// deserialize WidgetNewLiveSpan
try {
boolean attemptParsing = true;
Expand Down Expand Up @@ -210,6 +165,51 @@ public WidgetTime deserialize(JsonParser jp, DeserializationContext ctxt)
log.log(Level.FINER, "Input data does not match schema 'WidgetNewFixedSpan'", e);
}

// deserialize WidgetLegacyLiveSpan
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (WidgetLegacyLiveSpan.class.equals(Integer.class)
|| WidgetLegacyLiveSpan.class.equals(Long.class)
|| WidgetLegacyLiveSpan.class.equals(Float.class)
|| WidgetLegacyLiveSpan.class.equals(Double.class)
|| WidgetLegacyLiveSpan.class.equals(Boolean.class)
|| WidgetLegacyLiveSpan.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((WidgetLegacyLiveSpan.class.equals(Integer.class)
|| WidgetLegacyLiveSpan.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((WidgetLegacyLiveSpan.class.equals(Float.class)
|| WidgetLegacyLiveSpan.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(WidgetLegacyLiveSpan.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(WidgetLegacyLiveSpan.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(WidgetLegacyLiveSpan.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 (!((WidgetLegacyLiveSpan) tmp).unparsed) {
deserialized = tmp;
match++;
}
log.log(Level.FINER, "Input data matches schema 'WidgetLegacyLiveSpan'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'WidgetLegacyLiveSpan'", e);
}

WidgetTime ret = new WidgetTime();
if (match == 1) {
ret.setActualInstance(deserialized);
Expand Down Expand Up @@ -238,25 +238,25 @@ public WidgetTime() {
super("oneOf", Boolean.FALSE);
}

public WidgetTime(WidgetLegacyLiveSpan o) {
public WidgetTime(WidgetNewLiveSpan o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}

public WidgetTime(WidgetNewLiveSpan o) {
public WidgetTime(WidgetNewFixedSpan o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}

public WidgetTime(WidgetNewFixedSpan o) {
public WidgetTime(WidgetLegacyLiveSpan o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}

static {
schemas.put("WidgetLegacyLiveSpan", new GenericType<WidgetLegacyLiveSpan>() {});
schemas.put("WidgetNewLiveSpan", new GenericType<WidgetNewLiveSpan>() {});
schemas.put("WidgetNewFixedSpan", new GenericType<WidgetNewFixedSpan>() {});
schemas.put("WidgetLegacyLiveSpan", new GenericType<WidgetLegacyLiveSpan>() {});
JSON.registerDescendants(WidgetTime.class, Collections.unmodifiableMap(schemas));
}

Expand All @@ -267,22 +267,22 @@ public Map<String, GenericType> getSchemas() {

/**
* Set the instance that matches the oneOf child schema, check the instance parameter is valid
* against the oneOf child schemas: WidgetLegacyLiveSpan, WidgetNewLiveSpan, WidgetNewFixedSpan
* against the oneOf child schemas: WidgetNewLiveSpan, WidgetNewFixedSpan, WidgetLegacyLiveSpan
*
* <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(WidgetLegacyLiveSpan.class, instance, new HashSet<Class<?>>())) {
if (JSON.isInstanceOf(WidgetNewLiveSpan.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(WidgetNewLiveSpan.class, instance, new HashSet<Class<?>>())) {
if (JSON.isInstanceOf(WidgetNewFixedSpan.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(WidgetNewFixedSpan.class, instance, new HashSet<Class<?>>())) {
if (JSON.isInstanceOf(WidgetLegacyLiveSpan.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
Expand All @@ -292,32 +292,21 @@ public void setActualInstance(Object instance) {
return;
}
throw new RuntimeException(
"Invalid instance type. Must be WidgetLegacyLiveSpan, WidgetNewLiveSpan,"
+ " WidgetNewFixedSpan");
"Invalid instance type. Must be WidgetNewLiveSpan, WidgetNewFixedSpan,"
+ " WidgetLegacyLiveSpan");
}

/**
* Get the actual instance, which can be the following: WidgetLegacyLiveSpan, WidgetNewLiveSpan,
* WidgetNewFixedSpan
* Get the actual instance, which can be the following: WidgetNewLiveSpan, WidgetNewFixedSpan,
* WidgetLegacyLiveSpan
*
* @return The actual instance (WidgetLegacyLiveSpan, WidgetNewLiveSpan, WidgetNewFixedSpan)
* @return The actual instance (WidgetNewLiveSpan, WidgetNewFixedSpan, WidgetLegacyLiveSpan)
*/
@Override
public Object getActualInstance() {
return super.getActualInstance();
}

/**
* Get the actual instance of `WidgetLegacyLiveSpan`. If the actual instance is not
* `WidgetLegacyLiveSpan`, the ClassCastException will be thrown.
*
* @return The actual instance of `WidgetLegacyLiveSpan`
* @throws ClassCastException if the instance is not `WidgetLegacyLiveSpan`
*/
public WidgetLegacyLiveSpan getWidgetLegacyLiveSpan() throws ClassCastException {
return (WidgetLegacyLiveSpan) super.getActualInstance();
}

/**
* Get the actual instance of `WidgetNewLiveSpan`. If the actual instance is not
* `WidgetNewLiveSpan`, the ClassCastException will be thrown.
Expand All @@ -339,4 +328,15 @@ public WidgetNewLiveSpan getWidgetNewLiveSpan() throws ClassCastException {
public WidgetNewFixedSpan getWidgetNewFixedSpan() throws ClassCastException {
return (WidgetNewFixedSpan) super.getActualInstance();
}

/**
* Get the actual instance of `WidgetLegacyLiveSpan`. If the actual instance is not
* `WidgetLegacyLiveSpan`, the ClassCastException will be thrown.
*
* @return The actual instance of `WidgetLegacyLiveSpan`
* @throws ClassCastException if the instance is not `WidgetLegacyLiveSpan`
*/
public WidgetLegacyLiveSpan getWidgetLegacyLiveSpan() throws ClassCastException {
return (WidgetLegacyLiveSpan) super.getActualInstance();
}
}
Loading