Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
com.sinch.sdk.domains.sms.models.dto.v1.UpdateBatchMessageRequestDto Maven / Gradle / Ivy
/*
* API Overview | Sinch
* Sinch SMS API is one of the easiest APIs we offer and enables you to add fast and reliable global SMS to your applications. Send single messages, scheduled batch messages, use available message templates and more.
*
* The version of the OpenAPI document: v1
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package com.sinch.sdk.domains.sms.models.dto.v1;
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.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 com.sinch.sdk.core.models.AbstractOpenApiSchema;
import com.sinch.sdk.core.utils.databind.JSONNavigator;
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;
@JsonDeserialize(
using = UpdateBatchMessageRequestDto.UpdateBatchMessageRequestDtoDeserializer.class)
@JsonSerialize(using = UpdateBatchMessageRequestDto.UpdateBatchMessageRequestDtoSerializer.class)
public final class UpdateBatchMessageRequestDto extends AbstractOpenApiSchema {
private static final Logger log = Logger.getLogger(UpdateBatchMessageRequestDto.class.getName());
public static final class UpdateBatchMessageRequestDtoSerializer
extends StdSerializer {
private static final long serialVersionUID = 1L;
public UpdateBatchMessageRequestDtoSerializer(Class t) {
super(t);
}
public UpdateBatchMessageRequestDtoSerializer() {
this(null);
}
@Override
public void serialize(
UpdateBatchMessageRequestDto value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException {
jgen.writeObject(value.getActualInstance());
}
}
public static final class UpdateBatchMessageRequestDtoDeserializer
extends StdDeserializer {
private static final long serialVersionUID = 1L;
public UpdateBatchMessageRequestDtoDeserializer() {
this(UpdateBatchMessageRequestDto.class);
}
public UpdateBatchMessageRequestDtoDeserializer(Class> vc) {
super(vc);
}
@Override
public UpdateBatchMessageRequestDto deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
JsonNode tree = jp.readValueAsTree();
Object deserialized = null;
UpdateBatchMessageRequestDto newUpdateBatchMessageRequestDto =
new UpdateBatchMessageRequestDto();
Map result2 =
tree.traverse(jp.getCodec()).readValueAs(new TypeReference>() {});
String discriminatorValue = (String) result2.get("type");
switch (discriminatorValue) {
case "ApiUpdateBinaryMtMessage":
deserialized =
tree.traverse(jp.getCodec()).readValueAs(ApiUpdateBinaryMtMessageDto.class);
newUpdateBatchMessageRequestDto.setActualInstance(deserialized);
return newUpdateBatchMessageRequestDto;
case "ApiUpdateMmsMtMessage":
deserialized = tree.traverse(jp.getCodec()).readValueAs(ApiUpdateMmsMtMessageDto.class);
newUpdateBatchMessageRequestDto.setActualInstance(deserialized);
return newUpdateBatchMessageRequestDto;
case "ApiUpdateTextMtMessage":
deserialized = tree.traverse(jp.getCodec()).readValueAs(ApiUpdateTextMtMessageDto.class);
newUpdateBatchMessageRequestDto.setActualInstance(deserialized);
return newUpdateBatchMessageRequestDto;
case "mt_binary":
deserialized =
tree.traverse(jp.getCodec()).readValueAs(ApiUpdateBinaryMtMessageDto.class);
newUpdateBatchMessageRequestDto.setActualInstance(deserialized);
return newUpdateBatchMessageRequestDto;
case "mt_media":
deserialized = tree.traverse(jp.getCodec()).readValueAs(ApiUpdateMmsMtMessageDto.class);
newUpdateBatchMessageRequestDto.setActualInstance(deserialized);
return newUpdateBatchMessageRequestDto;
case "mt_text":
deserialized = tree.traverse(jp.getCodec()).readValueAs(ApiUpdateTextMtMessageDto.class);
newUpdateBatchMessageRequestDto.setActualInstance(deserialized);
return newUpdateBatchMessageRequestDto;
default:
log.log(
Level.WARNING,
String.format(
"Failed to lookup discriminator value `%s` for UpdateBatchMessageRequestDto."
+ " Possible values: ApiUpdateBinaryMtMessage ApiUpdateMmsMtMessage"
+ " ApiUpdateTextMtMessage mt_binary mt_media mt_text",
discriminatorValue));
}
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
int match = 0;
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
// deserialize ApiUpdateBinaryMtMessageDto
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (ApiUpdateBinaryMtMessageDto.class.equals(Integer.class)
|| ApiUpdateBinaryMtMessageDto.class.equals(Long.class)
|| ApiUpdateBinaryMtMessageDto.class.equals(Float.class)
|| ApiUpdateBinaryMtMessageDto.class.equals(Double.class)
|| ApiUpdateBinaryMtMessageDto.class.equals(Boolean.class)
|| ApiUpdateBinaryMtMessageDto.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((ApiUpdateBinaryMtMessageDto.class.equals(Integer.class)
|| ApiUpdateBinaryMtMessageDto.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((ApiUpdateBinaryMtMessageDto.class.equals(Float.class)
|| ApiUpdateBinaryMtMessageDto.class.equals(Double.class))
&& token == JsonToken.VALUE_NUMBER_FLOAT);
attemptParsing |=
(ApiUpdateBinaryMtMessageDto.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(ApiUpdateBinaryMtMessageDto.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
deserialized =
tree.traverse(jp.getCodec()).readValueAs(ApiUpdateBinaryMtMessageDto.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.
match++;
log.log(Level.FINER, "Input data matches schema 'ApiUpdateBinaryMtMessageDto'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'ApiUpdateBinaryMtMessageDto'", e);
}
// deserialize ApiUpdateMmsMtMessageDto
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (ApiUpdateMmsMtMessageDto.class.equals(Integer.class)
|| ApiUpdateMmsMtMessageDto.class.equals(Long.class)
|| ApiUpdateMmsMtMessageDto.class.equals(Float.class)
|| ApiUpdateMmsMtMessageDto.class.equals(Double.class)
|| ApiUpdateMmsMtMessageDto.class.equals(Boolean.class)
|| ApiUpdateMmsMtMessageDto.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((ApiUpdateMmsMtMessageDto.class.equals(Integer.class)
|| ApiUpdateMmsMtMessageDto.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((ApiUpdateMmsMtMessageDto.class.equals(Float.class)
|| ApiUpdateMmsMtMessageDto.class.equals(Double.class))
&& token == JsonToken.VALUE_NUMBER_FLOAT);
attemptParsing |=
(ApiUpdateMmsMtMessageDto.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(ApiUpdateMmsMtMessageDto.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
deserialized = tree.traverse(jp.getCodec()).readValueAs(ApiUpdateMmsMtMessageDto.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.
match++;
log.log(Level.FINER, "Input data matches schema 'ApiUpdateMmsMtMessageDto'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'ApiUpdateMmsMtMessageDto'", e);
}
// deserialize ApiUpdateTextMtMessageDto
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (ApiUpdateTextMtMessageDto.class.equals(Integer.class)
|| ApiUpdateTextMtMessageDto.class.equals(Long.class)
|| ApiUpdateTextMtMessageDto.class.equals(Float.class)
|| ApiUpdateTextMtMessageDto.class.equals(Double.class)
|| ApiUpdateTextMtMessageDto.class.equals(Boolean.class)
|| ApiUpdateTextMtMessageDto.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((ApiUpdateTextMtMessageDto.class.equals(Integer.class)
|| ApiUpdateTextMtMessageDto.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((ApiUpdateTextMtMessageDto.class.equals(Float.class)
|| ApiUpdateTextMtMessageDto.class.equals(Double.class))
&& token == JsonToken.VALUE_NUMBER_FLOAT);
attemptParsing |=
(ApiUpdateTextMtMessageDto.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(ApiUpdateTextMtMessageDto.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
deserialized = tree.traverse(jp.getCodec()).readValueAs(ApiUpdateTextMtMessageDto.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.
match++;
log.log(Level.FINER, "Input data matches schema 'ApiUpdateTextMtMessageDto'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'ApiUpdateTextMtMessageDto'", e);
}
if (match == 1) {
UpdateBatchMessageRequestDto ret = new UpdateBatchMessageRequestDto();
ret.setActualInstance(deserialized);
return ret;
}
throw new IOException(
String.format(
"Failed deserialization for UpdateBatchMessageRequestDto: %d classes match result,"
+ " expected 1",
match));
}
/** Handle deserialization of the 'null' value. */
@Override
public UpdateBatchMessageRequestDto getNullValue(DeserializationContext ctxt)
throws JsonMappingException {
throw new JsonMappingException(
ctxt.getParser(), "UpdateBatchMessageRequestDto cannot be null");
}
}
// store a list of schema names defined in oneOf
public static final Map> schemas = new HashMap<>();
public UpdateBatchMessageRequestDto() {
super("oneOf", Boolean.FALSE);
}
public UpdateBatchMessageRequestDto(ApiUpdateBinaryMtMessageDto o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
public UpdateBatchMessageRequestDto(ApiUpdateMmsMtMessageDto o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
public UpdateBatchMessageRequestDto(ApiUpdateTextMtMessageDto o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
static {
schemas.put("ApiUpdateBinaryMtMessageDto", ApiUpdateBinaryMtMessageDto.class);
schemas.put("ApiUpdateMmsMtMessageDto", ApiUpdateMmsMtMessageDto.class);
schemas.put("ApiUpdateTextMtMessageDto", ApiUpdateTextMtMessageDto.class);
JSONNavigator.registerDescendants(
UpdateBatchMessageRequestDto.class, Collections.unmodifiableMap(schemas));
// Initialize and register the discriminator mappings.
Map> mappings = new HashMap>();
mappings.put("ApiUpdateBinaryMtMessage", ApiUpdateBinaryMtMessageDto.class);
mappings.put("ApiUpdateMmsMtMessage", ApiUpdateMmsMtMessageDto.class);
mappings.put("ApiUpdateTextMtMessage", ApiUpdateTextMtMessageDto.class);
mappings.put("mt_binary", ApiUpdateBinaryMtMessageDto.class);
mappings.put("mt_media", ApiUpdateMmsMtMessageDto.class);
mappings.put("mt_text", ApiUpdateTextMtMessageDto.class);
mappings.put("UpdateBatchMessage_request", UpdateBatchMessageRequestDto.class);
JSONNavigator.registerDiscriminator(UpdateBatchMessageRequestDto.class, "type", mappings);
}
@Override
public Map> getSchemas() {
return UpdateBatchMessageRequestDto.schemas;
}
/**
* Set the instance that matches the oneOf child schema, check the instance parameter is valid
* against the oneOf child schemas: ApiUpdateBinaryMtMessageDto, ApiUpdateMmsMtMessageDto,
* ApiUpdateTextMtMessageDto
*
* 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 (JSONNavigator.isInstanceOf(
ApiUpdateBinaryMtMessageDto.class, instance, new HashSet>())) {
super.setActualInstance(instance);
return;
}
if (JSONNavigator.isInstanceOf(
ApiUpdateMmsMtMessageDto.class, instance, new HashSet>())) {
super.setActualInstance(instance);
return;
}
if (JSONNavigator.isInstanceOf(
ApiUpdateTextMtMessageDto.class, instance, new HashSet>())) {
super.setActualInstance(instance);
return;
}
throw new RuntimeException(
"Invalid instance type. Must be ApiUpdateBinaryMtMessageDto, ApiUpdateMmsMtMessageDto,"
+ " ApiUpdateTextMtMessageDto");
}
/**
* Get the actual instance, which can be the following: ApiUpdateBinaryMtMessageDto,
* ApiUpdateMmsMtMessageDto, ApiUpdateTextMtMessageDto
*
* @return The actual instance (ApiUpdateBinaryMtMessageDto, ApiUpdateMmsMtMessageDto,
* ApiUpdateTextMtMessageDto)
*/
@Override
public Object getActualInstance() {
return super.getActualInstance();
}
/**
* Get the actual instance of `ApiUpdateBinaryMtMessageDto`. If the actual instance is not
* `ApiUpdateBinaryMtMessageDto`, the ClassCastException will be thrown.
*
* @return The actual instance of `ApiUpdateBinaryMtMessageDto`
* @throws ClassCastException if the instance is not `ApiUpdateBinaryMtMessageDto`
*/
public ApiUpdateBinaryMtMessageDto getApiUpdateBinaryMtMessageDto() throws ClassCastException {
return (ApiUpdateBinaryMtMessageDto) super.getActualInstance();
}
/**
* Get the actual instance of `ApiUpdateMmsMtMessageDto`. If the actual instance is not
* `ApiUpdateMmsMtMessageDto`, the ClassCastException will be thrown.
*
* @return The actual instance of `ApiUpdateMmsMtMessageDto`
* @throws ClassCastException if the instance is not `ApiUpdateMmsMtMessageDto`
*/
public ApiUpdateMmsMtMessageDto getApiUpdateMmsMtMessageDto() throws ClassCastException {
return (ApiUpdateMmsMtMessageDto) super.getActualInstance();
}
/**
* Get the actual instance of `ApiUpdateTextMtMessageDto`. If the actual instance is not
* `ApiUpdateTextMtMessageDto`, the ClassCastException will be thrown.
*
* @return The actual instance of `ApiUpdateTextMtMessageDto`
* @throws ClassCastException if the instance is not `ApiUpdateTextMtMessageDto`
*/
public ApiUpdateTextMtMessageDto getApiUpdateTextMtMessageDto() throws ClassCastException {
return (ApiUpdateTextMtMessageDto) super.getActualInstance();
}
}