All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cashfree.model.PaymentEntityPaymentMethod Maven / Gradle / Ivy

The newest version!
/*
 * Cashfree Payment Gateway APIs
 * Cashfree's Payment Gateway APIs provide developers with a streamlined pathway to integrate advanced payment processing capabilities into their applications, platforms and websites.
 *
 * The version of the OpenAPI document: 2023-08-01
 * 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.cashfree.model;

import java.util.Objects;
import com.cashfree.model.PaymentMethodAppInPaymentsEntity;
import com.cashfree.model.PaymentMethodAppInPaymentsEntityApp;
import com.cashfree.model.PaymentMethodBankTransferInPaymentsEntity;
import com.cashfree.model.PaymentMethodBankTransferInPaymentsEntityBanktransfer;
import com.cashfree.model.PaymentMethodCardEMIInPaymentsEntity;
import com.cashfree.model.PaymentMethodCardEMIInPaymentsEntityEmi;
import com.cashfree.model.PaymentMethodCardInPaymentsEntity;
import com.cashfree.model.PaymentMethodCardInPaymentsEntityCard;
import com.cashfree.model.PaymentMethodCardlessEMIInPaymentsEntity;
import com.cashfree.model.PaymentMethodNetBankingInPaymentsEntity;
import com.cashfree.model.PaymentMethodNetBankingInPaymentsEntityNetbanking;
import com.cashfree.model.PaymentMethodPaylaterInPaymentsEntity;
import com.cashfree.model.PaymentMethodUPIInPaymentsEntity;
import com.cashfree.model.PaymentMethodUPIInPaymentsEntityUpi;
import com.google.gson.TypeAdapter;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.IOException;
import java.util.Arrays;



import java.io.IOException;
import java.lang.reflect.Type;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.JsonPrimitive;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonArray;
import com.google.gson.JsonParseException;

import com.cashfree.JSON;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-10-07T11:53:02.829012Z[Etc/UTC]")
public class PaymentEntityPaymentMethod extends AbstractOpenApiSchema {
    private static final Logger log = Logger.getLogger(PaymentEntityPaymentMethod.class.getName());

    public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
        @SuppressWarnings("unchecked")
        @Override
        public  TypeAdapter create(Gson gson, TypeToken type) {
            if (!PaymentEntityPaymentMethod.class.isAssignableFrom(type.getRawType())) {
                return null; // this class only serializes 'PaymentEntityPaymentMethod' and its subtypes
            }
            final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
            final TypeAdapter adapterPaymentMethodCardInPaymentsEntity = gson.getDelegateAdapter(this, TypeToken.get(PaymentMethodCardInPaymentsEntity.class));
            final TypeAdapter adapterPaymentMethodNetBankingInPaymentsEntity = gson.getDelegateAdapter(this, TypeToken.get(PaymentMethodNetBankingInPaymentsEntity.class));
            final TypeAdapter adapterPaymentMethodUPIInPaymentsEntity = gson.getDelegateAdapter(this, TypeToken.get(PaymentMethodUPIInPaymentsEntity.class));
            final TypeAdapter adapterPaymentMethodAppInPaymentsEntity = gson.getDelegateAdapter(this, TypeToken.get(PaymentMethodAppInPaymentsEntity.class));
            final TypeAdapter adapterPaymentMethodCardlessEMIInPaymentsEntity = gson.getDelegateAdapter(this, TypeToken.get(PaymentMethodCardlessEMIInPaymentsEntity.class));
            final TypeAdapter adapterPaymentMethodPaylaterInPaymentsEntity = gson.getDelegateAdapter(this, TypeToken.get(PaymentMethodPaylaterInPaymentsEntity.class));
            final TypeAdapter adapterPaymentMethodCardEMIInPaymentsEntity = gson.getDelegateAdapter(this, TypeToken.get(PaymentMethodCardEMIInPaymentsEntity.class));
            final TypeAdapter adapterPaymentMethodBankTransferInPaymentsEntity = gson.getDelegateAdapter(this, TypeToken.get(PaymentMethodBankTransferInPaymentsEntity.class));

            return (TypeAdapter) new TypeAdapter() {
                @Override
                public void write(JsonWriter out, PaymentEntityPaymentMethod value) throws IOException {
                    if (value == null || value.getActualInstance() == null) {
                        elementAdapter.write(out, null);
                        return;
                    }

                    // check if the actual instance is of the type `PaymentMethodCardInPaymentsEntity`
                    if (value.getActualInstance() instanceof PaymentMethodCardInPaymentsEntity) {
                      JsonElement element = adapterPaymentMethodCardInPaymentsEntity.toJsonTree((PaymentMethodCardInPaymentsEntity)value.getActualInstance());
                      elementAdapter.write(out, element);
                      return;
                    }
                    // check if the actual instance is of the type `PaymentMethodNetBankingInPaymentsEntity`
                    if (value.getActualInstance() instanceof PaymentMethodNetBankingInPaymentsEntity) {
                      JsonElement element = adapterPaymentMethodNetBankingInPaymentsEntity.toJsonTree((PaymentMethodNetBankingInPaymentsEntity)value.getActualInstance());
                      elementAdapter.write(out, element);
                      return;
                    }
                    // check if the actual instance is of the type `PaymentMethodUPIInPaymentsEntity`
                    if (value.getActualInstance() instanceof PaymentMethodUPIInPaymentsEntity) {
                      JsonElement element = adapterPaymentMethodUPIInPaymentsEntity.toJsonTree((PaymentMethodUPIInPaymentsEntity)value.getActualInstance());
                      elementAdapter.write(out, element);
                      return;
                    }
                    // check if the actual instance is of the type `PaymentMethodAppInPaymentsEntity`
                    if (value.getActualInstance() instanceof PaymentMethodAppInPaymentsEntity) {
                      JsonElement element = adapterPaymentMethodAppInPaymentsEntity.toJsonTree((PaymentMethodAppInPaymentsEntity)value.getActualInstance());
                      elementAdapter.write(out, element);
                      return;
                    }
                    // check if the actual instance is of the type `PaymentMethodCardlessEMIInPaymentsEntity`
                    if (value.getActualInstance() instanceof PaymentMethodCardlessEMIInPaymentsEntity) {
                      JsonElement element = adapterPaymentMethodCardlessEMIInPaymentsEntity.toJsonTree((PaymentMethodCardlessEMIInPaymentsEntity)value.getActualInstance());
                      elementAdapter.write(out, element);
                      return;
                    }
                    // check if the actual instance is of the type `PaymentMethodPaylaterInPaymentsEntity`
                    if (value.getActualInstance() instanceof PaymentMethodPaylaterInPaymentsEntity) {
                      JsonElement element = adapterPaymentMethodPaylaterInPaymentsEntity.toJsonTree((PaymentMethodPaylaterInPaymentsEntity)value.getActualInstance());
                      elementAdapter.write(out, element);
                      return;
                    }
                    // check if the actual instance is of the type `PaymentMethodCardEMIInPaymentsEntity`
                    if (value.getActualInstance() instanceof PaymentMethodCardEMIInPaymentsEntity) {
                      JsonElement element = adapterPaymentMethodCardEMIInPaymentsEntity.toJsonTree((PaymentMethodCardEMIInPaymentsEntity)value.getActualInstance());
                      elementAdapter.write(out, element);
                      return;
                    }
                    // check if the actual instance is of the type `PaymentMethodBankTransferInPaymentsEntity`
                    if (value.getActualInstance() instanceof PaymentMethodBankTransferInPaymentsEntity) {
                      JsonElement element = adapterPaymentMethodBankTransferInPaymentsEntity.toJsonTree((PaymentMethodBankTransferInPaymentsEntity)value.getActualInstance());
                      elementAdapter.write(out, element);
                      return;
                    }
                    throw new IOException("Failed to serialize as the type doesn't match oneOf schemas: PaymentMethodAppInPaymentsEntity, PaymentMethodBankTransferInPaymentsEntity, PaymentMethodCardEMIInPaymentsEntity, PaymentMethodCardInPaymentsEntity, PaymentMethodCardlessEMIInPaymentsEntity, PaymentMethodNetBankingInPaymentsEntity, PaymentMethodPaylaterInPaymentsEntity, PaymentMethodUPIInPaymentsEntity");
                }

                @Override
                public PaymentEntityPaymentMethod read(JsonReader in) throws IOException {
                    Object deserialized = null;
                    JsonElement jsonElement = elementAdapter.read(in);

                    int match = 0;
                    ArrayList errorMessages = new ArrayList<>();
                    TypeAdapter actualAdapter = elementAdapter;

                    // deserialize PaymentMethodCardInPaymentsEntity
                    try {
                      // validate the JSON object to see if any exception is thrown
                      if(PaymentMethodCardInPaymentsEntity.validateJsonElementForOneOf(jsonElement)) {
                          actualAdapter = adapterPaymentMethodCardInPaymentsEntity;
                      }
                      match++;
                      log.log(Level.FINER, "Input data matches schema 'PaymentMethodCardInPaymentsEntity'");
                    } catch (Exception e) {
                      // deserialization failed, continue
                      errorMessages.add(String.format("Deserialization for PaymentMethodCardInPaymentsEntity failed with `%s`.", e.getMessage()));
                      log.log(Level.FINER, "Input data does not match schema 'PaymentMethodCardInPaymentsEntity'", e);
                    }
                    // deserialize PaymentMethodNetBankingInPaymentsEntity
                    try {
                      // validate the JSON object to see if any exception is thrown
                      if(PaymentMethodNetBankingInPaymentsEntity.validateJsonElementForOneOf(jsonElement)) {
                          actualAdapter = adapterPaymentMethodNetBankingInPaymentsEntity;
                      }
                      match++;
                      log.log(Level.FINER, "Input data matches schema 'PaymentMethodNetBankingInPaymentsEntity'");
                    } catch (Exception e) {
                      // deserialization failed, continue
                      errorMessages.add(String.format("Deserialization for PaymentMethodNetBankingInPaymentsEntity failed with `%s`.", e.getMessage()));
                      log.log(Level.FINER, "Input data does not match schema 'PaymentMethodNetBankingInPaymentsEntity'", e);
                    }
                    // deserialize PaymentMethodUPIInPaymentsEntity
                    try {
                      // validate the JSON object to see if any exception is thrown
                      if(PaymentMethodUPIInPaymentsEntity.validateJsonElementForOneOf(jsonElement)) {
                          actualAdapter = adapterPaymentMethodUPIInPaymentsEntity;
                      }
                      match++;
                      log.log(Level.FINER, "Input data matches schema 'PaymentMethodUPIInPaymentsEntity'");
                    } catch (Exception e) {
                      // deserialization failed, continue
                      errorMessages.add(String.format("Deserialization for PaymentMethodUPIInPaymentsEntity failed with `%s`.", e.getMessage()));
                      log.log(Level.FINER, "Input data does not match schema 'PaymentMethodUPIInPaymentsEntity'", e);
                    }
                    // deserialize PaymentMethodAppInPaymentsEntity
                    try {
                      // validate the JSON object to see if any exception is thrown
                      if(PaymentMethodAppInPaymentsEntity.validateJsonElementForOneOf(jsonElement)) {
                          actualAdapter = adapterPaymentMethodAppInPaymentsEntity;
                      }
                      match++;
                      log.log(Level.FINER, "Input data matches schema 'PaymentMethodAppInPaymentsEntity'");
                    } catch (Exception e) {
                      // deserialization failed, continue
                      errorMessages.add(String.format("Deserialization for PaymentMethodAppInPaymentsEntity failed with `%s`.", e.getMessage()));
                      log.log(Level.FINER, "Input data does not match schema 'PaymentMethodAppInPaymentsEntity'", e);
                    }
                    // deserialize PaymentMethodCardlessEMIInPaymentsEntity
                    try {
                      // validate the JSON object to see if any exception is thrown
                      if(PaymentMethodCardlessEMIInPaymentsEntity.validateJsonElementForOneOf(jsonElement)) {
                          actualAdapter = adapterPaymentMethodCardlessEMIInPaymentsEntity;
                      }
                      match++;
                      log.log(Level.FINER, "Input data matches schema 'PaymentMethodCardlessEMIInPaymentsEntity'");
                    } catch (Exception e) {
                      // deserialization failed, continue
                      errorMessages.add(String.format("Deserialization for PaymentMethodCardlessEMIInPaymentsEntity failed with `%s`.", e.getMessage()));
                      log.log(Level.FINER, "Input data does not match schema 'PaymentMethodCardlessEMIInPaymentsEntity'", e);
                    }
                    // deserialize PaymentMethodPaylaterInPaymentsEntity
                    try {
                      // validate the JSON object to see if any exception is thrown
                      if(PaymentMethodPaylaterInPaymentsEntity.validateJsonElementForOneOf(jsonElement)) {
                          actualAdapter = adapterPaymentMethodPaylaterInPaymentsEntity;
                      }
                      match++;
                      log.log(Level.FINER, "Input data matches schema 'PaymentMethodPaylaterInPaymentsEntity'");
                    } catch (Exception e) {
                      // deserialization failed, continue
                      errorMessages.add(String.format("Deserialization for PaymentMethodPaylaterInPaymentsEntity failed with `%s`.", e.getMessage()));
                      log.log(Level.FINER, "Input data does not match schema 'PaymentMethodPaylaterInPaymentsEntity'", e);
                    }
                    // deserialize PaymentMethodCardEMIInPaymentsEntity
                    try {
                      // validate the JSON object to see if any exception is thrown
                      if(PaymentMethodCardEMIInPaymentsEntity.validateJsonElementForOneOf(jsonElement)) {
                          actualAdapter = adapterPaymentMethodCardEMIInPaymentsEntity;
                      }
                      match++;
                      log.log(Level.FINER, "Input data matches schema 'PaymentMethodCardEMIInPaymentsEntity'");
                    } catch (Exception e) {
                      // deserialization failed, continue
                      errorMessages.add(String.format("Deserialization for PaymentMethodCardEMIInPaymentsEntity failed with `%s`.", e.getMessage()));
                      log.log(Level.FINER, "Input data does not match schema 'PaymentMethodCardEMIInPaymentsEntity'", e);
                    }
                    // deserialize PaymentMethodBankTransferInPaymentsEntity
                    try {
                      // validate the JSON object to see if any exception is thrown
                      if(PaymentMethodBankTransferInPaymentsEntity.validateJsonElementForOneOf(jsonElement)) {
                          actualAdapter = adapterPaymentMethodBankTransferInPaymentsEntity;
                      }
                      match++;
                      log.log(Level.FINER, "Input data matches schema 'PaymentMethodBankTransferInPaymentsEntity'");
                    } catch (Exception e) {
                      // deserialization failed, continue
                      errorMessages.add(String.format("Deserialization for PaymentMethodBankTransferInPaymentsEntity failed with `%s`.", e.getMessage()));
                      log.log(Level.FINER, "Input data does not match schema 'PaymentMethodBankTransferInPaymentsEntity'", e);
                    }

                    // if (match == 1) {
                        PaymentEntityPaymentMethod ret = new PaymentEntityPaymentMethod();
                        ret.setActualInstance(actualAdapter.fromJsonTree(jsonElement));
                        return ret;
                    // }

                    // throw new IOException(String.format("Failed deserialization for PaymentEntityPaymentMethod: %d classes match result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", match, errorMessages, jsonElement.toString()));
                }
            }.nullSafe();
        }
    }

    // store a list of schema names defined in oneOf
    public static final Map> schemas = new HashMap>();

    public PaymentEntityPaymentMethod() {
        super("oneOf", Boolean.FALSE);
    }

    public PaymentEntityPaymentMethod(PaymentMethodAppInPaymentsEntity o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public PaymentEntityPaymentMethod(PaymentMethodBankTransferInPaymentsEntity o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public PaymentEntityPaymentMethod(PaymentMethodCardEMIInPaymentsEntity o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public PaymentEntityPaymentMethod(PaymentMethodCardInPaymentsEntity o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public PaymentEntityPaymentMethod(PaymentMethodCardlessEMIInPaymentsEntity o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public PaymentEntityPaymentMethod(PaymentMethodNetBankingInPaymentsEntity o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public PaymentEntityPaymentMethod(PaymentMethodPaylaterInPaymentsEntity o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    public PaymentEntityPaymentMethod(PaymentMethodUPIInPaymentsEntity o) {
        super("oneOf", Boolean.FALSE);
        setActualInstance(o);
    }

    static {
        schemas.put("PaymentMethodCardInPaymentsEntity", PaymentMethodCardInPaymentsEntity.class);
        schemas.put("PaymentMethodNetBankingInPaymentsEntity", PaymentMethodNetBankingInPaymentsEntity.class);
        schemas.put("PaymentMethodUPIInPaymentsEntity", PaymentMethodUPIInPaymentsEntity.class);
        schemas.put("PaymentMethodAppInPaymentsEntity", PaymentMethodAppInPaymentsEntity.class);
        schemas.put("PaymentMethodCardlessEMIInPaymentsEntity", PaymentMethodCardlessEMIInPaymentsEntity.class);
        schemas.put("PaymentMethodPaylaterInPaymentsEntity", PaymentMethodPaylaterInPaymentsEntity.class);
        schemas.put("PaymentMethodCardEMIInPaymentsEntity", PaymentMethodCardEMIInPaymentsEntity.class);
        schemas.put("PaymentMethodBankTransferInPaymentsEntity", PaymentMethodBankTransferInPaymentsEntity.class);
    }

    @Override
    public Map> getSchemas() {
        return PaymentEntityPaymentMethod.schemas;
    }

    /**
     * Set the instance that matches the oneOf child schema, check
     * the instance parameter is valid against the oneOf child schemas:
     * PaymentMethodAppInPaymentsEntity, PaymentMethodBankTransferInPaymentsEntity, PaymentMethodCardEMIInPaymentsEntity, PaymentMethodCardInPaymentsEntity, PaymentMethodCardlessEMIInPaymentsEntity, PaymentMethodNetBankingInPaymentsEntity, PaymentMethodPaylaterInPaymentsEntity, PaymentMethodUPIInPaymentsEntity
     *
     * It could be an instance of the 'oneOf' schemas.
     */
    @Override
    public void setActualInstance(Object instance) {
        if (instance instanceof PaymentMethodCardInPaymentsEntity) {
            super.setActualInstance(instance);
            return;
        }

        if (instance instanceof PaymentMethodNetBankingInPaymentsEntity) {
            super.setActualInstance(instance);
            return;
        }

        if (instance instanceof PaymentMethodUPIInPaymentsEntity) {
            super.setActualInstance(instance);
            return;
        }

        if (instance instanceof PaymentMethodAppInPaymentsEntity) {
            super.setActualInstance(instance);
            return;
        }

        if (instance instanceof PaymentMethodCardlessEMIInPaymentsEntity) {
            super.setActualInstance(instance);
            return;
        }

        if (instance instanceof PaymentMethodPaylaterInPaymentsEntity) {
            super.setActualInstance(instance);
            return;
        }

        if (instance instanceof PaymentMethodCardEMIInPaymentsEntity) {
            super.setActualInstance(instance);
            return;
        }

        if (instance instanceof PaymentMethodBankTransferInPaymentsEntity) {
            super.setActualInstance(instance);
            return;
        }

        throw new RuntimeException("Invalid instance type. Must be PaymentMethodAppInPaymentsEntity, PaymentMethodBankTransferInPaymentsEntity, PaymentMethodCardEMIInPaymentsEntity, PaymentMethodCardInPaymentsEntity, PaymentMethodCardlessEMIInPaymentsEntity, PaymentMethodNetBankingInPaymentsEntity, PaymentMethodPaylaterInPaymentsEntity, PaymentMethodUPIInPaymentsEntity");
    }

    /**
     * Get the actual instance, which can be the following:
     * PaymentMethodAppInPaymentsEntity, PaymentMethodBankTransferInPaymentsEntity, PaymentMethodCardEMIInPaymentsEntity, PaymentMethodCardInPaymentsEntity, PaymentMethodCardlessEMIInPaymentsEntity, PaymentMethodNetBankingInPaymentsEntity, PaymentMethodPaylaterInPaymentsEntity, PaymentMethodUPIInPaymentsEntity
     *
     * @return The actual instance (PaymentMethodAppInPaymentsEntity, PaymentMethodBankTransferInPaymentsEntity, PaymentMethodCardEMIInPaymentsEntity, PaymentMethodCardInPaymentsEntity, PaymentMethodCardlessEMIInPaymentsEntity, PaymentMethodNetBankingInPaymentsEntity, PaymentMethodPaylaterInPaymentsEntity, PaymentMethodUPIInPaymentsEntity)
     */
    @Override
    public Object getActualInstance() {
        return super.getActualInstance();
    }

    /**
     * Get the actual instance of `PaymentMethodCardInPaymentsEntity`. If the actual instance is not `PaymentMethodCardInPaymentsEntity`,
     * the ClassCastException will be thrown.
     *
     * @return The actual instance of `PaymentMethodCardInPaymentsEntity`
     * @throws ClassCastException if the instance is not `PaymentMethodCardInPaymentsEntity`
     */
    public PaymentMethodCardInPaymentsEntity getPaymentMethodCardInPaymentsEntity() throws ClassCastException {
        return (PaymentMethodCardInPaymentsEntity)super.getActualInstance();
    }
    /**
     * Get the actual instance of `PaymentMethodNetBankingInPaymentsEntity`. If the actual instance is not `PaymentMethodNetBankingInPaymentsEntity`,
     * the ClassCastException will be thrown.
     *
     * @return The actual instance of `PaymentMethodNetBankingInPaymentsEntity`
     * @throws ClassCastException if the instance is not `PaymentMethodNetBankingInPaymentsEntity`
     */
    public PaymentMethodNetBankingInPaymentsEntity getPaymentMethodNetBankingInPaymentsEntity() throws ClassCastException {
        return (PaymentMethodNetBankingInPaymentsEntity)super.getActualInstance();
    }
    /**
     * Get the actual instance of `PaymentMethodUPIInPaymentsEntity`. If the actual instance is not `PaymentMethodUPIInPaymentsEntity`,
     * the ClassCastException will be thrown.
     *
     * @return The actual instance of `PaymentMethodUPIInPaymentsEntity`
     * @throws ClassCastException if the instance is not `PaymentMethodUPIInPaymentsEntity`
     */
    public PaymentMethodUPIInPaymentsEntity getPaymentMethodUPIInPaymentsEntity() throws ClassCastException {
        return (PaymentMethodUPIInPaymentsEntity)super.getActualInstance();
    }
    /**
     * Get the actual instance of `PaymentMethodAppInPaymentsEntity`. If the actual instance is not `PaymentMethodAppInPaymentsEntity`,
     * the ClassCastException will be thrown.
     *
     * @return The actual instance of `PaymentMethodAppInPaymentsEntity`
     * @throws ClassCastException if the instance is not `PaymentMethodAppInPaymentsEntity`
     */
    public PaymentMethodAppInPaymentsEntity getPaymentMethodAppInPaymentsEntity() throws ClassCastException {
        return (PaymentMethodAppInPaymentsEntity)super.getActualInstance();
    }
    /**
     * Get the actual instance of `PaymentMethodCardlessEMIInPaymentsEntity`. If the actual instance is not `PaymentMethodCardlessEMIInPaymentsEntity`,
     * the ClassCastException will be thrown.
     *
     * @return The actual instance of `PaymentMethodCardlessEMIInPaymentsEntity`
     * @throws ClassCastException if the instance is not `PaymentMethodCardlessEMIInPaymentsEntity`
     */
    public PaymentMethodCardlessEMIInPaymentsEntity getPaymentMethodCardlessEMIInPaymentsEntity() throws ClassCastException {
        return (PaymentMethodCardlessEMIInPaymentsEntity)super.getActualInstance();
    }
    /**
     * Get the actual instance of `PaymentMethodPaylaterInPaymentsEntity`. If the actual instance is not `PaymentMethodPaylaterInPaymentsEntity`,
     * the ClassCastException will be thrown.
     *
     * @return The actual instance of `PaymentMethodPaylaterInPaymentsEntity`
     * @throws ClassCastException if the instance is not `PaymentMethodPaylaterInPaymentsEntity`
     */
    public PaymentMethodPaylaterInPaymentsEntity getPaymentMethodPaylaterInPaymentsEntity() throws ClassCastException {
        return (PaymentMethodPaylaterInPaymentsEntity)super.getActualInstance();
    }
    /**
     * Get the actual instance of `PaymentMethodCardEMIInPaymentsEntity`. If the actual instance is not `PaymentMethodCardEMIInPaymentsEntity`,
     * the ClassCastException will be thrown.
     *
     * @return The actual instance of `PaymentMethodCardEMIInPaymentsEntity`
     * @throws ClassCastException if the instance is not `PaymentMethodCardEMIInPaymentsEntity`
     */
    public PaymentMethodCardEMIInPaymentsEntity getPaymentMethodCardEMIInPaymentsEntity() throws ClassCastException {
        return (PaymentMethodCardEMIInPaymentsEntity)super.getActualInstance();
    }
    /**
     * Get the actual instance of `PaymentMethodBankTransferInPaymentsEntity`. If the actual instance is not `PaymentMethodBankTransferInPaymentsEntity`,
     * the ClassCastException will be thrown.
     *
     * @return The actual instance of `PaymentMethodBankTransferInPaymentsEntity`
     * @throws ClassCastException if the instance is not `PaymentMethodBankTransferInPaymentsEntity`
     */
    public PaymentMethodBankTransferInPaymentsEntity getPaymentMethodBankTransferInPaymentsEntity() throws ClassCastException {
        return (PaymentMethodBankTransferInPaymentsEntity)super.getActualInstance();
    }

 /**
  * Validates the JSON Element and throws an exception if issues found
  *
  * @param jsonElement JSON Element
  * @throws IOException if the JSON Element is invalid with respect to PaymentEntityPaymentMethod
  */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
    // validate oneOf schemas one by one
    int validCount = 0;
    ArrayList errorMessages = new ArrayList<>();
    // validate the json string with PaymentMethodCardInPaymentsEntity
    try {
      PaymentMethodCardInPaymentsEntity.validateJsonElement(jsonElement);
      validCount++;
    } catch (Exception e) {
      errorMessages.add(String.format("Deserialization for PaymentMethodCardInPaymentsEntity failed with `%s`.", e.getMessage()));
      // continue to the next one
    }
    // validate the json string with PaymentMethodNetBankingInPaymentsEntity
    try {
      PaymentMethodNetBankingInPaymentsEntity.validateJsonElement(jsonElement);
      validCount++;
    } catch (Exception e) {
      errorMessages.add(String.format("Deserialization for PaymentMethodNetBankingInPaymentsEntity failed with `%s`.", e.getMessage()));
      // continue to the next one
    }
    // validate the json string with PaymentMethodUPIInPaymentsEntity
    try {
      PaymentMethodUPIInPaymentsEntity.validateJsonElement(jsonElement);
      validCount++;
    } catch (Exception e) {
      errorMessages.add(String.format("Deserialization for PaymentMethodUPIInPaymentsEntity failed with `%s`.", e.getMessage()));
      // continue to the next one
    }
    // validate the json string with PaymentMethodAppInPaymentsEntity
    try {
      PaymentMethodAppInPaymentsEntity.validateJsonElement(jsonElement);
      validCount++;
    } catch (Exception e) {
      errorMessages.add(String.format("Deserialization for PaymentMethodAppInPaymentsEntity failed with `%s`.", e.getMessage()));
      // continue to the next one
    }
    // validate the json string with PaymentMethodCardlessEMIInPaymentsEntity
    try {
      PaymentMethodCardlessEMIInPaymentsEntity.validateJsonElement(jsonElement);
      validCount++;
    } catch (Exception e) {
      errorMessages.add(String.format("Deserialization for PaymentMethodCardlessEMIInPaymentsEntity failed with `%s`.", e.getMessage()));
      // continue to the next one
    }
    // validate the json string with PaymentMethodPaylaterInPaymentsEntity
    try {
      PaymentMethodPaylaterInPaymentsEntity.validateJsonElement(jsonElement);
      validCount++;
    } catch (Exception e) {
      errorMessages.add(String.format("Deserialization for PaymentMethodPaylaterInPaymentsEntity failed with `%s`.", e.getMessage()));
      // continue to the next one
    }
    // validate the json string with PaymentMethodCardEMIInPaymentsEntity
    try {
      PaymentMethodCardEMIInPaymentsEntity.validateJsonElement(jsonElement);
      validCount++;
    } catch (Exception e) {
      errorMessages.add(String.format("Deserialization for PaymentMethodCardEMIInPaymentsEntity failed with `%s`.", e.getMessage()));
      // continue to the next one
    }
    // validate the json string with PaymentMethodBankTransferInPaymentsEntity
    try {
      PaymentMethodBankTransferInPaymentsEntity.validateJsonElement(jsonElement);
      validCount++;
    } catch (Exception e) {
      errorMessages.add(String.format("Deserialization for PaymentMethodBankTransferInPaymentsEntity failed with `%s`.", e.getMessage()));
      // continue to the next one
    }
    // if (validCount != 1) {
    //  throw new IOException(String.format("The JSON string is invalid for PaymentEntityPaymentMethod with oneOf schemas: PaymentMethodAppInPaymentsEntity, PaymentMethodBankTransferInPaymentsEntity, PaymentMethodCardEMIInPaymentsEntity, PaymentMethodCardInPaymentsEntity, PaymentMethodCardlessEMIInPaymentsEntity, PaymentMethodNetBankingInPaymentsEntity, PaymentMethodPaylaterInPaymentsEntity, PaymentMethodUPIInPaymentsEntity. %d class(es) match the result, expected 1. Detailed failure message for oneOf schemas: %s. JSON: %s", validCount, errorMessages, jsonElement.toString()));
    // }
  }

 /**
  * Create an instance of PaymentEntityPaymentMethod given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of PaymentEntityPaymentMethod
  * @throws IOException if the JSON string is invalid with respect to PaymentEntityPaymentMethod
  */
  public static PaymentEntityPaymentMethod fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, PaymentEntityPaymentMethod.class);
  }

 /**
  * Convert an instance of PaymentEntityPaymentMethod to an JSON string
  *
  * @return JSON string
  */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy