com.cashfree.pg.model.CFPaymentsEntity Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of api Show documentation
Show all versions of api Show documentation
Cashfree Payments, PG Java SDK
/*
* New Payment Gateway APIs
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2022-01-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.pg.model;
import com.cashfree.pg.JSON;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.annotations.JsonAdapter;
import com.google.gson.annotations.SerializedName;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
/** CFPaymentsEntity */
@javax.annotation.Generated(
value = "org.openapitools.codegen.languages.JavaClientCodegen",
date = "2023-03-16T14:01:52.135917+05:30[Asia/Kolkata]")
public class CFPaymentsEntity {
public static final String SERIALIZED_NAME_CF_PAYMENT_ID = "cf_payment_id";
@SerializedName(SERIALIZED_NAME_CF_PAYMENT_ID)
private Integer cfPaymentId;
public static final String SERIALIZED_NAME_ORDER_ID = "order_id";
@SerializedName(SERIALIZED_NAME_ORDER_ID)
private String orderId;
public static final String SERIALIZED_NAME_ENTITY = "entity";
@SerializedName(SERIALIZED_NAME_ENTITY)
private String entity;
public static final String SERIALIZED_NAME_IS_CAPTURED = "is_captured";
@SerializedName(SERIALIZED_NAME_IS_CAPTURED)
private Boolean isCaptured;
public static final String SERIALIZED_NAME_ORDER_AMOUNT = "order_amount";
@SerializedName(SERIALIZED_NAME_ORDER_AMOUNT)
private BigDecimal orderAmount;
public static final String SERIALIZED_NAME_PAYMENT_GROUP = "payment_group";
@SerializedName(SERIALIZED_NAME_PAYMENT_GROUP)
private String paymentGroup;
public static final String SERIALIZED_NAME_PAYMENT_CURRENCY = "payment_currency";
@SerializedName(SERIALIZED_NAME_PAYMENT_CURRENCY)
private String paymentCurrency;
public static final String SERIALIZED_NAME_PAYMENT_AMOUNT = "payment_amount";
@SerializedName(SERIALIZED_NAME_PAYMENT_AMOUNT)
private BigDecimal paymentAmount;
public static final String SERIALIZED_NAME_PAYMENT_TIME = "payment_time";
@SerializedName(SERIALIZED_NAME_PAYMENT_TIME)
private String paymentTime;
/**
* The transaction status can be one of [\"SUCCESS\", \"NOT_ATTEMPTED\",
* \"FAILED\", \"USER_DROPPED\", \"VOID\",
* \"CANCELLED\", \"PENDING\"]
*/
@JsonAdapter(PaymentStatusEnum.Adapter.class)
public enum PaymentStatusEnum {
SUCCESS("SUCCESS"),
NOT_ATTEMPTED("NOT_ATTEMPTED"),
FAILED("FAILED"),
USER_DROPPED("USER_DROPPED"),
VOID("VOID"),
CANCELLED("CANCELLED"),
PENDING("PENDING");
private String value;
PaymentStatusEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static PaymentStatusEnum fromValue(String value) {
for (PaymentStatusEnum b : PaymentStatusEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final PaymentStatusEnum enumeration)
throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public PaymentStatusEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return PaymentStatusEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_PAYMENT_STATUS = "payment_status";
@SerializedName(SERIALIZED_NAME_PAYMENT_STATUS)
private PaymentStatusEnum paymentStatus;
public static final String SERIALIZED_NAME_PAYMENT_MESSAGE = "payment_message";
@SerializedName(SERIALIZED_NAME_PAYMENT_MESSAGE)
private String paymentMessage;
public static final String SERIALIZED_NAME_BANK_REFERENCE = "bank_reference";
@SerializedName(SERIALIZED_NAME_BANK_REFERENCE)
private String bankReference;
public static final String SERIALIZED_NAME_AUTH_ID = "auth_id";
@SerializedName(SERIALIZED_NAME_AUTH_ID)
private String authId;
public static final String SERIALIZED_NAME_AUTHORIZATION = "authorization";
@SerializedName(SERIALIZED_NAME_AUTHORIZATION)
private CFAuthorizationInPaymentsEntity authorization;
public static final String SERIALIZED_NAME_PAYMENT_METHOD = "payment_method";
@SerializedName(SERIALIZED_NAME_PAYMENT_METHOD)
private CFPaymentsEntityMethod paymentMethod;
public static final String SERIALIZED_NAME_ERROR_DETAILS = "error_details";
@SerializedName(SERIALIZED_NAME_ERROR_DETAILS)
private Object errorDetails;
public static final String SERIALIZED_NAME_PAYMENT_COMPLETION_TIME = "payment_completion_time";
@SerializedName(SERIALIZED_NAME_PAYMENT_COMPLETION_TIME)
private String paymentCompletionTime;
public static final String SERIALIZED_NAME_PAYMENT_GATEWAY_DETAILS = "payment_gateway_details";
@SerializedName(SERIALIZED_NAME_PAYMENT_GATEWAY_DETAILS)
private Object paymentGatewayDetails;
public static final String SERIALIZED_NAME_PAYMENT_OFFERS = "payment_offers";
@SerializedName(SERIALIZED_NAME_PAYMENT_OFFERS)
private Object paymentOffers;
public CFPaymentsEntity() {}
public CFPaymentsEntity cfPaymentId(Integer cfPaymentId) {
this.cfPaymentId = cfPaymentId;
return this;
}
/**
* Get cfPaymentId
*
* @return cfPaymentId
*/
@javax.annotation.Nullable
public Integer getCfPaymentId() {
return cfPaymentId;
}
public void setCfPaymentId(Integer cfPaymentId) {
this.cfPaymentId = cfPaymentId;
}
public CFPaymentsEntity orderId(String orderId) {
this.orderId = orderId;
return this;
}
/**
* Get orderId
*
* @return orderId
*/
@javax.annotation.Nullable
public String getOrderId() {
return orderId;
}
public void setOrderId(String orderId) {
this.orderId = orderId;
}
public CFPaymentsEntity entity(String entity) {
this.entity = entity;
return this;
}
/**
* Get entity
*
* @return entity
*/
@javax.annotation.Nullable
public String getEntity() {
return entity;
}
public void setEntity(String entity) {
this.entity = entity;
}
public CFPaymentsEntity isCaptured(Boolean isCaptured) {
this.isCaptured = isCaptured;
return this;
}
/**
* Get isCaptured
*
* @return isCaptured
*/
@javax.annotation.Nullable
public Boolean getIsCaptured() {
return isCaptured;
}
public void setIsCaptured(Boolean isCaptured) {
this.isCaptured = isCaptured;
}
public CFPaymentsEntity orderAmount(BigDecimal orderAmount) {
this.orderAmount = orderAmount;
return this;
}
/**
* Order amount can be different from payment amount if you collect service fee from the
* customer
*
* @return orderAmount
*/
@javax.annotation.Nullable
public BigDecimal getOrderAmount() {
return orderAmount;
}
public void setOrderAmount(BigDecimal orderAmount) {
this.orderAmount = orderAmount;
}
public CFPaymentsEntity paymentGroup(String paymentGroup) {
this.paymentGroup = paymentGroup;
return this;
}
/**
* Type of payment group. One of ['upi', 'card', 'app',
* 'netbanking', 'paylater', 'cardless_emi']
*
* @return paymentGroup
*/
@javax.annotation.Nullable
public String getPaymentGroup() {
return paymentGroup;
}
public void setPaymentGroup(String paymentGroup) {
this.paymentGroup = paymentGroup;
}
public CFPaymentsEntity paymentCurrency(String paymentCurrency) {
this.paymentCurrency = paymentCurrency;
return this;
}
/**
* Get paymentCurrency
*
* @return paymentCurrency
*/
@javax.annotation.Nullable
public String getPaymentCurrency() {
return paymentCurrency;
}
public void setPaymentCurrency(String paymentCurrency) {
this.paymentCurrency = paymentCurrency;
}
public CFPaymentsEntity paymentAmount(BigDecimal paymentAmount) {
this.paymentAmount = paymentAmount;
return this;
}
/**
* Get paymentAmount
*
* @return paymentAmount
*/
@javax.annotation.Nullable
public BigDecimal getPaymentAmount() {
return paymentAmount;
}
public void setPaymentAmount(BigDecimal paymentAmount) {
this.paymentAmount = paymentAmount;
}
public CFPaymentsEntity paymentTime(String paymentTime) {
this.paymentTime = paymentTime;
return this;
}
/**
* Get paymentTime
*
* @return paymentTime
*/
@javax.annotation.Nullable
public String getPaymentTime() {
return paymentTime;
}
public void setPaymentTime(String paymentTime) {
this.paymentTime = paymentTime;
}
public CFPaymentsEntity paymentStatus(PaymentStatusEnum paymentStatus) {
this.paymentStatus = paymentStatus;
return this;
}
/**
* The transaction status can be one of [\"SUCCESS\", \"NOT_ATTEMPTED\",
* \"FAILED\", \"USER_DROPPED\", \"VOID\",
* \"CANCELLED\", \"PENDING\"]
*
* @return paymentStatus
*/
@javax.annotation.Nullable
public PaymentStatusEnum getPaymentStatus() {
return paymentStatus;
}
public void setPaymentStatus(PaymentStatusEnum paymentStatus) {
this.paymentStatus = paymentStatus;
}
public CFPaymentsEntity paymentMessage(String paymentMessage) {
this.paymentMessage = paymentMessage;
return this;
}
/**
* Get paymentMessage
*
* @return paymentMessage
*/
@javax.annotation.Nullable
public String getPaymentMessage() {
return paymentMessage;
}
public void setPaymentMessage(String paymentMessage) {
this.paymentMessage = paymentMessage;
}
public CFPaymentsEntity bankReference(String bankReference) {
this.bankReference = bankReference;
return this;
}
/**
* Get bankReference
*
* @return bankReference
*/
@javax.annotation.Nullable
public String getBankReference() {
return bankReference;
}
public void setBankReference(String bankReference) {
this.bankReference = bankReference;
}
public CFPaymentsEntity authId(String authId) {
this.authId = authId;
return this;
}
/**
* Get authId
*
* @return authId
*/
@javax.annotation.Nullable
public String getAuthId() {
return authId;
}
public void setAuthId(String authId) {
this.authId = authId;
}
public CFPaymentsEntity authorization(CFAuthorizationInPaymentsEntity authorization) {
this.authorization = authorization;
return this;
}
/**
* Get authorization
*
* @return authorization
*/
@javax.annotation.Nullable
public CFAuthorizationInPaymentsEntity getAuthorization() {
return authorization;
}
public void setAuthorization(CFAuthorizationInPaymentsEntity authorization) {
this.authorization = authorization;
}
public CFPaymentsEntity paymentMethod(CFPaymentsEntityMethod paymentMethod) {
this.paymentMethod = paymentMethod;
return this;
}
/**
* Get paymentMethod
*
* @return paymentMethod
*/
@javax.annotation.Nullable
public CFPaymentsEntityMethod getPaymentMethod() {
return paymentMethod;
}
public void setPaymentMethod(CFPaymentsEntityMethod paymentMethod) {
this.paymentMethod = paymentMethod;
}
public CFPaymentsEntity errorDetails(Object errorDetails) {
this.errorDetails = errorDetails;
return this;
}
/**
* Get errorDetails
*
* @return errorDetails
*/
@javax.annotation.Nullable
public Object getErrorDetails() {
return errorDetails;
}
public void setErrorDetails(Object errorDetails) {
this.errorDetails = errorDetails;
}
public CFPaymentsEntity paymentCompletionTime(String paymentCompletionTime) {
this.paymentCompletionTime = paymentCompletionTime;
return this;
}
/**
* Get paymentCompletionTime
*
* @return paymentCompletionTime
*/
@javax.annotation.Nullable
public String getPaymentCompletionTime() {
return paymentCompletionTime;
}
public void setPaymentCompletionTime(String paymentCompletionTime) {
this.paymentCompletionTime = paymentCompletionTime;
}
public CFPaymentsEntity paymentGatewayDetails(Object paymentGatewayDetails) {
this.paymentGatewayDetails = paymentGatewayDetails;
return this;
}
/**
* Get paymentGatewayDetails
*
* @return paymentGatewayDetails
*/
@javax.annotation.Nullable
public Object getPaymentGatewayDetails() {
return paymentGatewayDetails;
}
public void setPaymentGatewayDetails(Object paymentGatewayDetails) {
this.paymentGatewayDetails = paymentGatewayDetails;
}
public CFPaymentsEntity paymentOffers(Object paymentOffers) {
this.paymentOffers = paymentOffers;
return this;
}
/**
* Get paymentOffers
*
* @return paymentOffers
*/
@javax.annotation.Nullable
public Object getPaymentOffers() {
return paymentOffers;
}
public void setPaymentOffers(Object paymentOffers) {
this.paymentOffers = paymentOffers;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
CFPaymentsEntity cfPaymentsEntity = (CFPaymentsEntity) o;
return Objects.equals(this.cfPaymentId, cfPaymentsEntity.cfPaymentId)
&& Objects.equals(this.orderId, cfPaymentsEntity.orderId)
&& Objects.equals(this.entity, cfPaymentsEntity.entity)
&& Objects.equals(this.isCaptured, cfPaymentsEntity.isCaptured)
&& Objects.equals(this.orderAmount, cfPaymentsEntity.orderAmount)
&& Objects.equals(this.paymentGroup, cfPaymentsEntity.paymentGroup)
&& Objects.equals(this.paymentCurrency, cfPaymentsEntity.paymentCurrency)
&& Objects.equals(this.paymentAmount, cfPaymentsEntity.paymentAmount)
&& Objects.equals(this.paymentTime, cfPaymentsEntity.paymentTime)
&& Objects.equals(this.paymentStatus, cfPaymentsEntity.paymentStatus)
&& Objects.equals(this.paymentMessage, cfPaymentsEntity.paymentMessage)
&& Objects.equals(this.bankReference, cfPaymentsEntity.bankReference)
&& Objects.equals(this.authId, cfPaymentsEntity.authId)
&& Objects.equals(this.authorization, cfPaymentsEntity.authorization)
&& Objects.equals(this.paymentMethod, cfPaymentsEntity.paymentMethod)
&& Objects.equals(this.errorDetails, cfPaymentsEntity.errorDetails)
&& Objects.equals(
this.paymentCompletionTime, cfPaymentsEntity.paymentCompletionTime)
&& Objects.equals(
this.paymentGatewayDetails, cfPaymentsEntity.paymentGatewayDetails)
&& Objects.equals(this.paymentOffers, cfPaymentsEntity.paymentOffers);
}
@Override
public int hashCode() {
return Objects.hash(
cfPaymentId,
orderId,
entity,
isCaptured,
orderAmount,
paymentGroup,
paymentCurrency,
paymentAmount,
paymentTime,
paymentStatus,
paymentMessage,
bankReference,
authId,
authorization,
paymentMethod,
errorDetails,
paymentCompletionTime,
paymentGatewayDetails,
paymentOffers);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class CFPaymentsEntity {\n");
sb.append(" cfPaymentId: ").append(toIndentedString(cfPaymentId)).append("\n");
sb.append(" orderId: ").append(toIndentedString(orderId)).append("\n");
sb.append(" entity: ").append(toIndentedString(entity)).append("\n");
sb.append(" isCaptured: ").append(toIndentedString(isCaptured)).append("\n");
sb.append(" orderAmount: ").append(toIndentedString(orderAmount)).append("\n");
sb.append(" paymentGroup: ").append(toIndentedString(paymentGroup)).append("\n");
sb.append(" paymentCurrency: ").append(toIndentedString(paymentCurrency)).append("\n");
sb.append(" paymentAmount: ").append(toIndentedString(paymentAmount)).append("\n");
sb.append(" paymentTime: ").append(toIndentedString(paymentTime)).append("\n");
sb.append(" paymentStatus: ").append(toIndentedString(paymentStatus)).append("\n");
sb.append(" paymentMessage: ").append(toIndentedString(paymentMessage)).append("\n");
sb.append(" bankReference: ").append(toIndentedString(bankReference)).append("\n");
sb.append(" authId: ").append(toIndentedString(authId)).append("\n");
sb.append(" authorization: ").append(toIndentedString(authorization)).append("\n");
sb.append(" paymentMethod: ").append(toIndentedString(paymentMethod)).append("\n");
sb.append(" errorDetails: ").append(toIndentedString(errorDetails)).append("\n");
sb.append(" paymentCompletionTime: ")
.append(toIndentedString(paymentCompletionTime))
.append("\n");
sb.append(" paymentGatewayDetails: ")
.append(toIndentedString(paymentGatewayDetails))
.append("\n");
sb.append(" paymentOffers: ").append(toIndentedString(paymentOffers)).append("\n");
sb.append("}");
return sb.toString();
}
/**
* Convert the given object to string with each line indented by 4 spaces (except the first
* line).
*/
private String toIndentedString(Object o) {
if (o == null) {
return "null";
}
return o.toString().replace("\n", "\n ");
}
public static HashSet openapiFields;
public static HashSet openapiRequiredFields;
static {
// a set of all properties/fields (JSON key names)
openapiFields = new HashSet();
openapiFields.add("cf_payment_id");
openapiFields.add("order_id");
openapiFields.add("entity");
openapiFields.add("is_captured");
openapiFields.add("order_amount");
openapiFields.add("payment_group");
openapiFields.add("payment_currency");
openapiFields.add("payment_amount");
openapiFields.add("payment_time");
openapiFields.add("payment_status");
openapiFields.add("payment_message");
openapiFields.add("bank_reference");
openapiFields.add("auth_id");
openapiFields.add("authorization");
openapiFields.add("payment_method");
openapiFields.add("error_details");
openapiFields.add("payment_completion_time");
openapiFields.add("payment_gateway_details");
openapiFields.add("payment_offers");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* Validates the JSON Object and throws an exception if issues found
*
* @param jsonObj JSON Object
* @throws IOException if the JSON Object is invalid with respect to CFPaymentsEntity
*/
public static void validateJsonObject(JsonObject jsonObj) throws IOException {
if (jsonObj == null) {
if (!CFPaymentsEntity.openapiRequiredFields
.isEmpty()) { // has required fields but JSON object is null
throw new IllegalArgumentException(
String.format(
"The required field(s) %s in CFPaymentsEntity is not found in the"
+ " empty JSON string",
CFPaymentsEntity.openapiRequiredFields.toString()));
}
}
Set> entries = jsonObj.entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!CFPaymentsEntity.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(
String.format(
"The field `%s` in the JSON string is not defined in the"
+ " `CFPaymentsEntity` properties. JSON: %s",
entry.getKey(), jsonObj.toString()));
}
}
if ((jsonObj.get("order_id") != null && !jsonObj.get("order_id").isJsonNull())
&& !jsonObj.get("order_id").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `order_id` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("order_id").toString()));
}
if ((jsonObj.get("entity") != null && !jsonObj.get("entity").isJsonNull())
&& !jsonObj.get("entity").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `entity` to be a primitive type in the JSON string"
+ " but got `%s`",
jsonObj.get("entity").toString()));
}
if ((jsonObj.get("payment_group") != null && !jsonObj.get("payment_group").isJsonNull())
&& !jsonObj.get("payment_group").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `payment_group` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("payment_group").toString()));
}
if ((jsonObj.get("payment_currency") != null
&& !jsonObj.get("payment_currency").isJsonNull())
&& !jsonObj.get("payment_currency").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `payment_currency` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("payment_currency").toString()));
}
if ((jsonObj.get("payment_time") != null && !jsonObj.get("payment_time").isJsonNull())
&& !jsonObj.get("payment_time").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `payment_time` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("payment_time").toString()));
}
if ((jsonObj.get("payment_status") != null && !jsonObj.get("payment_status").isJsonNull())
&& !jsonObj.get("payment_status").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `payment_status` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("payment_status").toString()));
}
if ((jsonObj.get("payment_message") != null && !jsonObj.get("payment_message").isJsonNull())
&& !jsonObj.get("payment_message").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `payment_message` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("payment_message").toString()));
}
if ((jsonObj.get("bank_reference") != null && !jsonObj.get("bank_reference").isJsonNull())
&& !jsonObj.get("bank_reference").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `bank_reference` to be a primitive type in the"
+ " JSON string but got `%s`",
jsonObj.get("bank_reference").toString()));
}
if ((jsonObj.get("auth_id") != null && !jsonObj.get("auth_id").isJsonNull())
&& !jsonObj.get("auth_id").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `auth_id` to be a primitive type in the JSON"
+ " string but got `%s`",
jsonObj.get("auth_id").toString()));
}
// validate the optional field `authorization`
if (jsonObj.get("authorization") != null && !jsonObj.get("authorization").isJsonNull()) {
CFAuthorizationInPaymentsEntity.validateJsonObject(
jsonObj.getAsJsonObject("authorization"));
}
// validate the optional field `payment_method`
if (jsonObj.get("payment_method") != null && !jsonObj.get("payment_method").isJsonNull()) {
CFPaymentsEntityMethod.validateJsonObject(jsonObj.getAsJsonObject("payment_method"));
}
if ((jsonObj.get("payment_completion_time") != null
&& !jsonObj.get("payment_completion_time").isJsonNull())
&& !jsonObj.get("payment_completion_time").isJsonPrimitive()) {
throw new IllegalArgumentException(
String.format(
"Expected the field `payment_completion_time` to be a primitive type"
+ " in the JSON string but got `%s`",
jsonObj.get("payment_completion_time").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!CFPaymentsEntity.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'CFPaymentsEntity' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter =
gson.getDelegateAdapter(this, TypeToken.get(CFPaymentsEntity.class));
return (TypeAdapter)
new TypeAdapter() {
@Override
public void write(JsonWriter out, CFPaymentsEntity value)
throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public CFPaymentsEntity read(JsonReader in) throws IOException {
JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
validateJsonObject(jsonObj);
return thisAdapter.fromJsonTree(jsonObj);
}
}.nullSafe();
}
}
/**
* Create an instance of CFPaymentsEntity given an JSON string
*
* @param jsonString JSON string
* @return An instance of CFPaymentsEntity
* @throws IOException if the JSON string is invalid with respect to CFPaymentsEntity
*/
public static CFPaymentsEntity fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, CFPaymentsEntity.class);
}
/**
* Convert an instance of CFPaymentsEntity to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}