com.clinia.model.common.V1DomainResourceWithIncludesAllOfIncludes Maven / Gradle / Ivy
// Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost
// - read more on https://github.com/clinia/api-clients-generation. DO NOT EDIT.
package com.clinia.model.common;
import com.clinia.exceptions.CliniaRuntimeException;
import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.*;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.annotation.*;
import java.io.IOException;
import java.util.List;
import java.util.logging.Logger;
/** V1DomainResourceWithIncludesAllOfIncludes */
@JsonDeserialize(using = V1DomainResourceWithIncludesAllOfIncludes.Deserializer.class)
public interface V1DomainResourceWithIncludesAllOfIncludes {
// V1DomainResourceWithIncludesAllOfIncludes as List wrapper.
static V1DomainResourceWithIncludesAllOfIncludes ofListOfV1Relationship(List value) {
return new ListOfV1RelationshipWrapper(value);
}
// V1DomainResourceWithIncludesAllOfIncludes as List wrapper.
static V1DomainResourceWithIncludesAllOfIncludes ofListOfV1DomainResource(List value) {
return new ListOfV1DomainResourceWrapper(value);
}
// V1DomainResourceWithIncludesAllOfIncludes as List wrapper.
@JsonSerialize(using = ListOfV1RelationshipWrapper.Serializer.class)
class ListOfV1RelationshipWrapper implements V1DomainResourceWithIncludesAllOfIncludes {
private final List value;
ListOfV1RelationshipWrapper(List value) {
this.value = value;
}
public List getValue() {
return value;
}
static class Serializer extends JsonSerializer {
@Override
public void serialize(ListOfV1RelationshipWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeObject(value.getValue());
}
}
}
// V1DomainResourceWithIncludesAllOfIncludes as List wrapper.
@JsonSerialize(using = ListOfV1DomainResourceWrapper.Serializer.class)
class ListOfV1DomainResourceWrapper implements V1DomainResourceWithIncludesAllOfIncludes {
private final List value;
ListOfV1DomainResourceWrapper(List value) {
this.value = value;
}
public List getValue() {
return value;
}
static class Serializer extends JsonSerializer {
@Override
public void serialize(ListOfV1DomainResourceWrapper value, JsonGenerator gen, SerializerProvider provider) throws IOException {
gen.writeObject(value.getValue());
}
}
}
class Deserializer extends JsonDeserializer {
private static final Logger LOGGER = Logger.getLogger(Deserializer.class.getName());
@Override
public V1DomainResourceWithIncludesAllOfIncludes deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode tree = jp.readValueAsTree();
// deserialize List
if (tree.isArray()) {
try (JsonParser parser = tree.traverse(jp.getCodec())) {
List value = parser.readValueAs(new TypeReference>() {});
return new V1DomainResourceWithIncludesAllOfIncludes.ListOfV1RelationshipWrapper(value);
} catch (Exception e) {
// deserialization failed, continue
LOGGER.finest("Failed to deserialize oneOf List (error: " + e.getMessage() + ") (type: List)");
}
}
// deserialize List
if (tree.isArray()) {
try (JsonParser parser = tree.traverse(jp.getCodec())) {
List value = parser.readValueAs(new TypeReference>() {});
return new V1DomainResourceWithIncludesAllOfIncludes.ListOfV1DomainResourceWrapper(value);
} catch (Exception e) {
// deserialization failed, continue
LOGGER.finest(
"Failed to deserialize oneOf List (error: " + e.getMessage() + ") (type: List)"
);
}
}
throw new CliniaRuntimeException(String.format("Failed to deserialize json element: %s", tree));
}
/** Handle deserialization of the 'null' value. */
@Override
public V1DomainResourceWithIncludesAllOfIncludes getNullValue(DeserializationContext ctxt) throws JsonMappingException {
throw new JsonMappingException(ctxt.getParser(), "V1DomainResourceWithIncludesAllOfIncludes cannot be null");
}
}
}