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.
/*
* Transfer webhooks
*
* The version of the OpenAPI document: 4
*
*
* 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.adyen.model.transferwebhooks;
import java.util.Objects;
import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;
import com.adyen.model.transferwebhooks.BankCategoryData;
import com.adyen.model.transferwebhooks.InternalCategoryData;
import com.adyen.model.transferwebhooks.IssuedCard;
import com.adyen.model.transferwebhooks.PlatformPayment;
import com.adyen.model.transferwebhooks.RelayedAuthorisationData;
import com.adyen.model.transferwebhooks.TransferNotificationValidationFact;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeName;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import jakarta.ws.rs.core.GenericType;
import jakarta.ws.rs.core.Response;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
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.DeserializationFeature;
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;
@JsonDeserialize(using = TransferDataCategoryData.TransferDataCategoryDataDeserializer.class)
@JsonSerialize(using = TransferDataCategoryData.TransferDataCategoryDataSerializer.class)
public class TransferDataCategoryData extends AbstractOpenApiSchema {
private static final Logger log = Logger.getLogger(TransferDataCategoryData.class.getName());
public static class TransferDataCategoryDataSerializer extends StdSerializer {
public TransferDataCategoryDataSerializer(Class t) {
super(t);
}
public TransferDataCategoryDataSerializer() {
this(null);
}
@Override
public void serialize(TransferDataCategoryData value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException {
jgen.writeObject(value.getActualInstance());
}
}
public static class TransferDataCategoryDataDeserializer extends StdDeserializer {
public TransferDataCategoryDataDeserializer() {
this(TransferDataCategoryData.class);
}
public TransferDataCategoryDataDeserializer(Class vc) {
super(vc);
}
@Override
public TransferDataCategoryData deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
JsonNode tree = jp.readValueAsTree();
Object deserialized = null;
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
int match = 0;
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
// deserialize BankCategoryData
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (BankCategoryData.class.equals(Integer.class) || BankCategoryData.class.equals(Long.class) || BankCategoryData.class.equals(Float.class) || BankCategoryData.class.equals(Double.class) || BankCategoryData.class.equals(Boolean.class) || BankCategoryData.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |= ((BankCategoryData.class.equals(Integer.class) || BankCategoryData.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |= ((BankCategoryData.class.equals(Float.class) || BankCategoryData.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
attemptParsing |= (BankCategoryData.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |= (BankCategoryData.class.equals(String.class) && token == JsonToken.VALUE_STRING);
}
}
// Checks if the unique type of the oneOf json matches any of the object TypeEnum values
boolean typeMatch = Arrays.stream(BankCategoryData.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText()));
if (attemptParsing || typeMatch) {
// Strict deserialization for oneOf models
deserialized = JSON.getMapper().readValue(tree.toString(), BankCategoryData.class);
// typeMatch should enforce proper deserialization
match++;
log.log(Level.FINER, "Input data matches schema 'BankCategoryData'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'BankCategoryData'", e);
}
// deserialize InternalCategoryData
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (InternalCategoryData.class.equals(Integer.class) || InternalCategoryData.class.equals(Long.class) || InternalCategoryData.class.equals(Float.class) || InternalCategoryData.class.equals(Double.class) || InternalCategoryData.class.equals(Boolean.class) || InternalCategoryData.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |= ((InternalCategoryData.class.equals(Integer.class) || InternalCategoryData.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |= ((InternalCategoryData.class.equals(Float.class) || InternalCategoryData.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
attemptParsing |= (InternalCategoryData.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |= (InternalCategoryData.class.equals(String.class) && token == JsonToken.VALUE_STRING);
}
}
// Checks if the unique type of the oneOf json matches any of the object TypeEnum values
boolean typeMatch = Arrays.stream(InternalCategoryData.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText()));
if (attemptParsing || typeMatch) {
// Strict deserialization for oneOf models
deserialized = JSON.getMapper().readValue(tree.toString(), InternalCategoryData.class);
// typeMatch should enforce proper deserialization
match++;
log.log(Level.FINER, "Input data matches schema 'InternalCategoryData'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'InternalCategoryData'", e);
}
// deserialize IssuedCard
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (IssuedCard.class.equals(Integer.class) || IssuedCard.class.equals(Long.class) || IssuedCard.class.equals(Float.class) || IssuedCard.class.equals(Double.class) || IssuedCard.class.equals(Boolean.class) || IssuedCard.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |= ((IssuedCard.class.equals(Integer.class) || IssuedCard.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |= ((IssuedCard.class.equals(Float.class) || IssuedCard.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
attemptParsing |= (IssuedCard.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |= (IssuedCard.class.equals(String.class) && token == JsonToken.VALUE_STRING);
}
}
// Checks if the unique type of the oneOf json matches any of the object TypeEnum values
boolean typeMatch = Arrays.stream(IssuedCard.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText()));
if (attemptParsing || typeMatch) {
// Strict deserialization for oneOf models
deserialized = JSON.getMapper().readValue(tree.toString(), IssuedCard.class);
// typeMatch should enforce proper deserialization
match++;
log.log(Level.FINER, "Input data matches schema 'IssuedCard'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'IssuedCard'", e);
}
// deserialize PlatformPayment
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (PlatformPayment.class.equals(Integer.class) || PlatformPayment.class.equals(Long.class) || PlatformPayment.class.equals(Float.class) || PlatformPayment.class.equals(Double.class) || PlatformPayment.class.equals(Boolean.class) || PlatformPayment.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |= ((PlatformPayment.class.equals(Integer.class) || PlatformPayment.class.equals(Long.class)) && token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |= ((PlatformPayment.class.equals(Float.class) || PlatformPayment.class.equals(Double.class)) && token == JsonToken.VALUE_NUMBER_FLOAT);
attemptParsing |= (PlatformPayment.class.equals(Boolean.class) && (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |= (PlatformPayment.class.equals(String.class) && token == JsonToken.VALUE_STRING);
}
}
// Checks if the unique type of the oneOf json matches any of the object TypeEnum values
boolean typeMatch = Arrays.stream(PlatformPayment.TypeEnum.values()).anyMatch((t) -> t.getValue().contains(tree.findValue("type").asText()));
if (attemptParsing || typeMatch) {
// Strict deserialization for oneOf models
deserialized = JSON.getMapper().readValue(tree.toString(), PlatformPayment.class);
// typeMatch should enforce proper deserialization
match++;
log.log(Level.FINER, "Input data matches schema 'PlatformPayment'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'PlatformPayment'", e);
}
// Throw error if there is no match
if (match == 0) {
throw new IOException(String.format("Failed deserialization for TransferDataCategoryData: %d classes match result, expected 1", match));
}
// Log warning if there is more than one match
if (match > 1) {
log.log(Level.WARNING, String.format("Warning, indecisive deserialization for TransferDataCategoryData: %d classes match result, expected 1", match));
}
TransferDataCategoryData ret = new TransferDataCategoryData();
ret.setActualInstance(deserialized);
return ret;
}
/**
* Handle deserialization of the 'null' value.
*/
@Override
public TransferDataCategoryData getNullValue(DeserializationContext ctxt) throws JsonMappingException {
throw new JsonMappingException(ctxt.getParser(), "TransferDataCategoryData cannot be null");
}
}
// store a list of schema names defined in oneOf
public static final Map schemas = new HashMap();
public TransferDataCategoryData() {
super("oneOf", Boolean.FALSE);
}
public TransferDataCategoryData(BankCategoryData o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
public TransferDataCategoryData(InternalCategoryData o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
public TransferDataCategoryData(IssuedCard o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
public TransferDataCategoryData(PlatformPayment o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}
static {
schemas.put("BankCategoryData", new GenericType() {
});
schemas.put("InternalCategoryData", new GenericType() {
});
schemas.put("IssuedCard", new GenericType() {
});
schemas.put("PlatformPayment", new GenericType() {
});
JSON.registerDescendants(TransferDataCategoryData.class, Collections.unmodifiableMap(schemas));
}
@Override
public Map getSchemas() {
return TransferDataCategoryData.schemas;
}
/**
* Set the instance that matches the oneOf child schema, check
* the instance parameter is valid against the oneOf child schemas:
* BankCategoryData, InternalCategoryData, IssuedCard, PlatformPayment
*
* 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(BankCategoryData.class, instance, new HashSet>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(InternalCategoryData.class, instance, new HashSet>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(IssuedCard.class, instance, new HashSet>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(PlatformPayment.class, instance, new HashSet>())) {
super.setActualInstance(instance);
return;
}
throw new RuntimeException("Invalid instance type. Must be BankCategoryData, InternalCategoryData, IssuedCard, PlatformPayment");
}
/**
* Get the actual instance, which can be the following:
* BankCategoryData, InternalCategoryData, IssuedCard, PlatformPayment
*
* @return The actual instance (BankCategoryData, InternalCategoryData, IssuedCard, PlatformPayment)
*/
@Override
public Object getActualInstance() {
return super.getActualInstance();
}
/**
* Get the actual instance of `BankCategoryData`. If the actual instance is not `BankCategoryData`,
* the ClassCastException will be thrown.
*
* @return The actual instance of `BankCategoryData`
* @throws ClassCastException if the instance is not `BankCategoryData`
*/
public BankCategoryData getBankCategoryData() throws ClassCastException {
return (BankCategoryData)super.getActualInstance();
}
/**
* Get the actual instance of `InternalCategoryData`. If the actual instance is not `InternalCategoryData`,
* the ClassCastException will be thrown.
*
* @return The actual instance of `InternalCategoryData`
* @throws ClassCastException if the instance is not `InternalCategoryData`
*/
public InternalCategoryData getInternalCategoryData() throws ClassCastException {
return (InternalCategoryData)super.getActualInstance();
}
/**
* Get the actual instance of `IssuedCard`. If the actual instance is not `IssuedCard`,
* the ClassCastException will be thrown.
*
* @return The actual instance of `IssuedCard`
* @throws ClassCastException if the instance is not `IssuedCard`
*/
public IssuedCard getIssuedCard() throws ClassCastException {
return (IssuedCard)super.getActualInstance();
}
/**
* Get the actual instance of `PlatformPayment`. If the actual instance is not `PlatformPayment`,
* the ClassCastException will be thrown.
*
* @return The actual instance of `PlatformPayment`
* @throws ClassCastException if the instance is not `PlatformPayment`
*/
public PlatformPayment getPlatformPayment() throws ClassCastException {
return (PlatformPayment)super.getActualInstance();
}
/**
* Create an instance of TransferDataCategoryData given an JSON string
*
* @param jsonString JSON string
* @return An instance of TransferDataCategoryData
* @throws IOException if the JSON string is invalid with respect to TransferDataCategoryData
*/
public static TransferDataCategoryData fromJson(String jsonString) throws IOException {
return JSON.getMapper().readValue(jsonString, TransferDataCategoryData.class);
}
/**
* Convert an instance of TransferDataCategoryData to an JSON string
*
* @return JSON string
*/
public String toJson() throws JsonProcessingException {
return JSON.getMapper().writeValueAsString(this);
}
}