-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regenerate client from commit 957a4550 of spec repo
- Loading branch information
ci.datadog-api-spec
committed
Feb 4, 2025
1 parent
0ebdaeb
commit ffa32c2
Showing
5 changed files
with
355 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
271 changes: 271 additions & 0 deletions
271
src/main/java/com/datadog/api/client/v2/model/AppVersionSelector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,271 @@ | ||
/* | ||
* 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.v2.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 = AppVersionSelector.AppVersionSelectorDeserializer.class) | ||
@JsonSerialize(using = AppVersionSelector.AppVersionSelectorSerializer.class) | ||
public class AppVersionSelector extends AbstractOpenApiSchema { | ||
private static final Logger log = Logger.getLogger(AppVersionSelector.class.getName()); | ||
|
||
@JsonIgnore public boolean unparsed = false; | ||
|
||
public static class AppVersionSelectorSerializer extends StdSerializer<AppVersionSelector> { | ||
public AppVersionSelectorSerializer(Class<AppVersionSelector> t) { | ||
super(t); | ||
} | ||
|
||
public AppVersionSelectorSerializer() { | ||
this(null); | ||
} | ||
|
||
@Override | ||
public void serialize(AppVersionSelector value, JsonGenerator jgen, SerializerProvider provider) | ||
throws IOException, JsonProcessingException { | ||
jgen.writeObject(value.getActualInstance()); | ||
} | ||
} | ||
|
||
public static class AppVersionSelectorDeserializer extends StdDeserializer<AppVersionSelector> { | ||
public AppVersionSelectorDeserializer() { | ||
this(AppVersionSelector.class); | ||
} | ||
|
||
public AppVersionSelectorDeserializer(Class<?> vc) { | ||
super(vc); | ||
} | ||
|
||
@Override | ||
public AppVersionSelector 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 AppVersionSelectorConstants | ||
try { | ||
boolean attemptParsing = true; | ||
// ensure that we respect type coercion as set on the client ObjectMapper | ||
if (AppVersionSelectorConstants.class.equals(Integer.class) | ||
|| AppVersionSelectorConstants.class.equals(Long.class) | ||
|| AppVersionSelectorConstants.class.equals(Float.class) | ||
|| AppVersionSelectorConstants.class.equals(Double.class) | ||
|| AppVersionSelectorConstants.class.equals(Boolean.class) | ||
|| AppVersionSelectorConstants.class.equals(String.class)) { | ||
attemptParsing = typeCoercion; | ||
if (!attemptParsing) { | ||
attemptParsing |= | ||
((AppVersionSelectorConstants.class.equals(Integer.class) | ||
|| AppVersionSelectorConstants.class.equals(Long.class)) | ||
&& token == JsonToken.VALUE_NUMBER_INT); | ||
attemptParsing |= | ||
((AppVersionSelectorConstants.class.equals(Float.class) | ||
|| AppVersionSelectorConstants.class.equals(Double.class)) | ||
&& (token == JsonToken.VALUE_NUMBER_FLOAT | ||
|| token == JsonToken.VALUE_NUMBER_INT)); | ||
attemptParsing |= | ||
(AppVersionSelectorConstants.class.equals(Boolean.class) | ||
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); | ||
attemptParsing |= | ||
(AppVersionSelectorConstants.class.equals(String.class) | ||
&& token == JsonToken.VALUE_STRING); | ||
} | ||
} | ||
if (attemptParsing) { | ||
tmp = tree.traverse(jp.getCodec()).readValueAs(AppVersionSelectorConstants.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 (!((AppVersionSelectorConstants) tmp).unparsed) { | ||
deserialized = tmp; | ||
match++; | ||
} | ||
log.log(Level.FINER, "Input data matches schema 'AppVersionSelectorConstants'"); | ||
} | ||
} catch (Exception e) { | ||
// deserialization failed, continue | ||
log.log(Level.FINER, "Input data does not match schema 'AppVersionSelectorConstants'", e); | ||
} | ||
|
||
// deserialize Long | ||
try { | ||
boolean attemptParsing = true; | ||
// ensure that we respect type coercion as set on the client ObjectMapper | ||
if (Long.class.equals(Integer.class) | ||
|| Long.class.equals(Long.class) | ||
|| Long.class.equals(Float.class) | ||
|| Long.class.equals(Double.class) | ||
|| Long.class.equals(Boolean.class) | ||
|| Long.class.equals(String.class)) { | ||
attemptParsing = typeCoercion; | ||
if (!attemptParsing) { | ||
attemptParsing |= | ||
((Long.class.equals(Integer.class) || Long.class.equals(Long.class)) | ||
&& token == JsonToken.VALUE_NUMBER_INT); | ||
attemptParsing |= | ||
((Long.class.equals(Float.class) || Long.class.equals(Double.class)) | ||
&& (token == JsonToken.VALUE_NUMBER_FLOAT | ||
|| token == JsonToken.VALUE_NUMBER_INT)); | ||
attemptParsing |= | ||
(Long.class.equals(Boolean.class) | ||
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE)); | ||
attemptParsing |= (Long.class.equals(String.class) && token == JsonToken.VALUE_STRING); | ||
} | ||
} | ||
if (attemptParsing) { | ||
tmp = tree.traverse(jp.getCodec()).readValueAs(Long.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. | ||
deserialized = tmp; | ||
match++; | ||
|
||
log.log(Level.FINER, "Input data matches schema 'Long'"); | ||
} | ||
} catch (Exception e) { | ||
// deserialization failed, continue | ||
log.log(Level.FINER, "Input data does not match schema 'Long'", e); | ||
} | ||
|
||
AppVersionSelector ret = new AppVersionSelector(); | ||
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 AppVersionSelector getNullValue(DeserializationContext ctxt) | ||
throws JsonMappingException { | ||
throw new JsonMappingException(ctxt.getParser(), "AppVersionSelector cannot be null"); | ||
} | ||
} | ||
|
||
// store a list of schema names defined in oneOf | ||
public static final Map<String, GenericType> schemas = new HashMap<String, GenericType>(); | ||
|
||
public AppVersionSelector() { | ||
super("oneOf", Boolean.FALSE); | ||
} | ||
|
||
public AppVersionSelector(AppVersionSelectorConstants o) { | ||
super("oneOf", Boolean.FALSE); | ||
setActualInstance(o); | ||
} | ||
|
||
public AppVersionSelector(Long o) { | ||
super("oneOf", Boolean.FALSE); | ||
setActualInstance(o); | ||
} | ||
|
||
static { | ||
schemas.put("AppVersionSelectorConstants", new GenericType<AppVersionSelectorConstants>() {}); | ||
schemas.put("Long", new GenericType<Long>() {}); | ||
JSON.registerDescendants(AppVersionSelector.class, Collections.unmodifiableMap(schemas)); | ||
} | ||
|
||
@Override | ||
public Map<String, GenericType> getSchemas() { | ||
return AppVersionSelector.schemas; | ||
} | ||
|
||
/** | ||
* Set the instance that matches the oneOf child schema, check the instance parameter is valid | ||
* against the oneOf child schemas: AppVersionSelectorConstants, Long | ||
* | ||
* <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(AppVersionSelectorConstants.class, instance, new HashSet<Class<?>>())) { | ||
super.setActualInstance(instance); | ||
return; | ||
} | ||
if (JSON.isInstanceOf(Long.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 AppVersionSelectorConstants, Long"); | ||
} | ||
|
||
/** | ||
* Get the actual instance, which can be the following: AppVersionSelectorConstants, Long | ||
* | ||
* @return The actual instance (AppVersionSelectorConstants, Long) | ||
*/ | ||
@Override | ||
public Object getActualInstance() { | ||
return super.getActualInstance(); | ||
} | ||
|
||
/** | ||
* Get the actual instance of `AppVersionSelectorConstants`. If the actual instance is not | ||
* `AppVersionSelectorConstants`, the ClassCastException will be thrown. | ||
* | ||
* @return The actual instance of `AppVersionSelectorConstants` | ||
* @throws ClassCastException if the instance is not `AppVersionSelectorConstants` | ||
*/ | ||
public AppVersionSelectorConstants getAppVersionSelectorConstants() throws ClassCastException { | ||
return (AppVersionSelectorConstants) super.getActualInstance(); | ||
} | ||
|
||
/** | ||
* Get the actual instance of `Long`. If the actual instance is not `Long`, the ClassCastException | ||
* will be thrown. | ||
* | ||
* @return The actual instance of `Long` | ||
* @throws ClassCastException if the instance is not `Long` | ||
*/ | ||
public Long getLong() throws ClassCastException { | ||
return (Long) super.getActualInstance(); | ||
} | ||
} |
Oops, something went wrong.