com.zuora.model.PreviewOrderOrderAction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zuora-sdk-java Show documentation
Show all versions of zuora-sdk-java Show documentation
The SDK of JAVA language for Zuora pricing system
/*
* Zuora API Reference
* REST API reference for the Zuora Billing, Payments, and Central Platform! Check out the [REST API Overview](https://www.zuora.com/developer/api-references/api/overview/).
*
* The version of the OpenAPI document: 2024-05-20
* 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.zuora.model;
import java.util.Objects;
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 com.zuora.model.CreateOrderChangePlan;
import com.zuora.model.CreateOrderResume;
import com.zuora.model.CreateOrderSuspend;
import com.zuora.model.CreateOrderTermsAndConditions;
import com.zuora.model.OrderActionCancelSubscription;
import com.zuora.model.OrderActionOwnerTransfer;
import com.zuora.model.OrderActionRemoveProduct;
import com.zuora.model.OrderActionRenewSubscription;
import com.zuora.model.OrderActionType;
import com.zuora.model.PreviewOrderCreateSubscription;
import com.zuora.model.PreviewOrderRatePlanOverride;
import com.zuora.model.PreviewOrderRatePlanUpdate;
import com.zuora.model.TriggerDate;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
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.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.zuora.JSON;
/**
* PreviewOrderOrderAction
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class PreviewOrderOrderAction {
public static final String SERIALIZED_NAME_ADD_PRODUCT = "addProduct";
@SerializedName(SERIALIZED_NAME_ADD_PRODUCT)
private PreviewOrderRatePlanOverride addProduct;
public static final String SERIALIZED_NAME_CANCEL_SUBSCRIPTION = "cancelSubscription";
@SerializedName(SERIALIZED_NAME_CANCEL_SUBSCRIPTION)
private OrderActionCancelSubscription cancelSubscription;
public static final String SERIALIZED_NAME_CHANGE_PLAN = "changePlan";
@SerializedName(SERIALIZED_NAME_CHANGE_PLAN)
private CreateOrderChangePlan changePlan;
public static final String SERIALIZED_NAME_CHANGE_REASON = "changeReason";
@SerializedName(SERIALIZED_NAME_CHANGE_REASON)
private String changeReason;
public static final String SERIALIZED_NAME_CREATE_SUBSCRIPTION = "createSubscription";
@SerializedName(SERIALIZED_NAME_CREATE_SUBSCRIPTION)
private PreviewOrderCreateSubscription createSubscription;
public static final String SERIALIZED_NAME_CUSTOM_FIELDS = "customFields";
@SerializedName(SERIALIZED_NAME_CUSTOM_FIELDS)
private Map customFields;
public static final String SERIALIZED_NAME_OWNER_TRANSFER = "ownerTransfer";
@SerializedName(SERIALIZED_NAME_OWNER_TRANSFER)
private OrderActionOwnerTransfer ownerTransfer;
public static final String SERIALIZED_NAME_REMOVE_PRODUCT = "removeProduct";
@SerializedName(SERIALIZED_NAME_REMOVE_PRODUCT)
private OrderActionRemoveProduct removeProduct;
public static final String SERIALIZED_NAME_RENEW_SUBSCRIPTION = "renewSubscription";
@SerializedName(SERIALIZED_NAME_RENEW_SUBSCRIPTION)
private OrderActionRenewSubscription renewSubscription;
public static final String SERIALIZED_NAME_RESUME = "resume";
@SerializedName(SERIALIZED_NAME_RESUME)
private CreateOrderResume resume;
public static final String SERIALIZED_NAME_SUSPEND = "suspend";
@SerializedName(SERIALIZED_NAME_SUSPEND)
private CreateOrderSuspend suspend;
public static final String SERIALIZED_NAME_TERMS_AND_CONDITIONS = "termsAndConditions";
@SerializedName(SERIALIZED_NAME_TERMS_AND_CONDITIONS)
private CreateOrderTermsAndConditions termsAndConditions;
public static final String SERIALIZED_NAME_TRIGGER_DATES = "triggerDates";
@SerializedName(SERIALIZED_NAME_TRIGGER_DATES)
private List triggerDates;
public static final String SERIALIZED_NAME_TYPE = "type";
@SerializedName(SERIALIZED_NAME_TYPE)
private OrderActionType type;
public static final String SERIALIZED_NAME_UPDATE_PRODUCT = "updateProduct";
@SerializedName(SERIALIZED_NAME_UPDATE_PRODUCT)
private PreviewOrderRatePlanUpdate updateProduct;
public PreviewOrderOrderAction() {
}
public PreviewOrderOrderAction addProduct(PreviewOrderRatePlanOverride addProduct) {
this.addProduct = addProduct;
return this;
}
/**
* Get addProduct
* @return addProduct
*/
@javax.annotation.Nullable
public PreviewOrderRatePlanOverride getAddProduct() {
return addProduct;
}
public void setAddProduct(PreviewOrderRatePlanOverride addProduct) {
this.addProduct = addProduct;
}
public PreviewOrderOrderAction cancelSubscription(OrderActionCancelSubscription cancelSubscription) {
this.cancelSubscription = cancelSubscription;
return this;
}
/**
* Get cancelSubscription
* @return cancelSubscription
*/
@javax.annotation.Nullable
public OrderActionCancelSubscription getCancelSubscription() {
return cancelSubscription;
}
public void setCancelSubscription(OrderActionCancelSubscription cancelSubscription) {
this.cancelSubscription = cancelSubscription;
}
public PreviewOrderOrderAction changePlan(CreateOrderChangePlan changePlan) {
this.changePlan = changePlan;
return this;
}
/**
* Get changePlan
* @return changePlan
*/
@javax.annotation.Nullable
public CreateOrderChangePlan getChangePlan() {
return changePlan;
}
public void setChangePlan(CreateOrderChangePlan changePlan) {
this.changePlan = changePlan;
}
public PreviewOrderOrderAction changeReason(String changeReason) {
this.changeReason = changeReason;
return this;
}
/**
* The change reason set for an order action when an order is created.
* @return changeReason
*/
@javax.annotation.Nullable
public String getChangeReason() {
return changeReason;
}
public void setChangeReason(String changeReason) {
this.changeReason = changeReason;
}
public PreviewOrderOrderAction createSubscription(PreviewOrderCreateSubscription createSubscription) {
this.createSubscription = createSubscription;
return this;
}
/**
* Get createSubscription
* @return createSubscription
*/
@javax.annotation.Nullable
public PreviewOrderCreateSubscription getCreateSubscription() {
return createSubscription;
}
public void setCreateSubscription(PreviewOrderCreateSubscription createSubscription) {
this.createSubscription = createSubscription;
}
public PreviewOrderOrderAction customFields(Map customFields) {
this.customFields = customFields;
return this;
}
public PreviewOrderOrderAction putCustomFieldsItem(String key, Object customFieldsItem) {
if (this.customFields == null) {
this.customFields = new HashMap<>();
}
this.customFields.put(key, customFieldsItem);
return this;
}
/**
* Container for custom fields of an Order Action object.
* @return customFields
*/
@javax.annotation.Nullable
public Map getCustomFields() {
return customFields;
}
public void setCustomFields(Map customFields) {
this.customFields = customFields;
}
public PreviewOrderOrderAction ownerTransfer(OrderActionOwnerTransfer ownerTransfer) {
this.ownerTransfer = ownerTransfer;
return this;
}
/**
* Get ownerTransfer
* @return ownerTransfer
*/
@javax.annotation.Nullable
public OrderActionOwnerTransfer getOwnerTransfer() {
return ownerTransfer;
}
public void setOwnerTransfer(OrderActionOwnerTransfer ownerTransfer) {
this.ownerTransfer = ownerTransfer;
}
public PreviewOrderOrderAction removeProduct(OrderActionRemoveProduct removeProduct) {
this.removeProduct = removeProduct;
return this;
}
/**
* Get removeProduct
* @return removeProduct
*/
@javax.annotation.Nullable
public OrderActionRemoveProduct getRemoveProduct() {
return removeProduct;
}
public void setRemoveProduct(OrderActionRemoveProduct removeProduct) {
this.removeProduct = removeProduct;
}
public PreviewOrderOrderAction renewSubscription(OrderActionRenewSubscription renewSubscription) {
this.renewSubscription = renewSubscription;
return this;
}
/**
* Get renewSubscription
* @return renewSubscription
*/
@javax.annotation.Nullable
public OrderActionRenewSubscription getRenewSubscription() {
return renewSubscription;
}
public void setRenewSubscription(OrderActionRenewSubscription renewSubscription) {
this.renewSubscription = renewSubscription;
}
public PreviewOrderOrderAction resume(CreateOrderResume resume) {
this.resume = resume;
return this;
}
/**
* Get resume
* @return resume
*/
@javax.annotation.Nullable
public CreateOrderResume getResume() {
return resume;
}
public void setResume(CreateOrderResume resume) {
this.resume = resume;
}
public PreviewOrderOrderAction suspend(CreateOrderSuspend suspend) {
this.suspend = suspend;
return this;
}
/**
* Get suspend
* @return suspend
*/
@javax.annotation.Nullable
public CreateOrderSuspend getSuspend() {
return suspend;
}
public void setSuspend(CreateOrderSuspend suspend) {
this.suspend = suspend;
}
public PreviewOrderOrderAction termsAndConditions(CreateOrderTermsAndConditions termsAndConditions) {
this.termsAndConditions = termsAndConditions;
return this;
}
/**
* Get termsAndConditions
* @return termsAndConditions
*/
@javax.annotation.Nullable
public CreateOrderTermsAndConditions getTermsAndConditions() {
return termsAndConditions;
}
public void setTermsAndConditions(CreateOrderTermsAndConditions termsAndConditions) {
this.termsAndConditions = termsAndConditions;
}
public PreviewOrderOrderAction triggerDates(List triggerDates) {
this.triggerDates = triggerDates;
return this;
}
public PreviewOrderOrderAction addTriggerDatesItem(TriggerDate triggerDatesItem) {
if (this.triggerDates == null) {
this.triggerDates = new ArrayList<>();
}
this.triggerDates.add(triggerDatesItem);
return this;
}
/**
* Container for the contract effective, service activation, and customer acceptance dates of the order action. If the service activation date is set as a required field in Default Subscription Settings, skipping this field in a `CreateSubscription` order action of your JSON request will result in a `Pending` order and a `Pending Activation` subscription. If the customer acceptance date is set as a required field in Default Subscription Settings, skipping this field in a `CreateSubscription` order action of your JSON request will result in a `Pending` order and a `Pending Acceptance` subscription. If the service activation date field is at the same time required and skipped (or set as null), it will be a `Pending Activation` subscription.
* @return triggerDates
*/
@javax.annotation.Nullable
public List getTriggerDates() {
return triggerDates;
}
public void setTriggerDates(List triggerDates) {
this.triggerDates = triggerDates;
}
public PreviewOrderOrderAction type(OrderActionType type) {
this.type = type;
return this;
}
/**
* Get type
* @return type
*/
@javax.annotation.Nonnull
public OrderActionType getType() {
return type;
}
public void setType(OrderActionType type) {
this.type = type;
}
public PreviewOrderOrderAction updateProduct(PreviewOrderRatePlanUpdate updateProduct) {
this.updateProduct = updateProduct;
return this;
}
/**
* Get updateProduct
* @return updateProduct
*/
@javax.annotation.Nullable
public PreviewOrderRatePlanUpdate getUpdateProduct() {
return updateProduct;
}
public void setUpdateProduct(PreviewOrderRatePlanUpdate updateProduct) {
this.updateProduct = updateProduct;
}
/**
* A container for additional, undeclared properties.
* This is a holder for any undeclared properties as specified with
* the 'additionalProperties' keyword in the OAS document.
*/
private Map additionalProperties;
/**
* Set the additional (undeclared) property with the specified name and value.
* If the property does not already exist, create it otherwise replace it.
*
* @param key name of the property
* @param value value of the property
* @return the PreviewOrderOrderAction instance itself
*/
public PreviewOrderOrderAction putAdditionalProperty(String key, Object value) {
if (this.additionalProperties == null) {
this.additionalProperties = new HashMap();
}
this.additionalProperties.put(key, value);
return this;
}
/**
* Return the additional (undeclared) property.
*
* @return a map of objects
*/
public Map getAdditionalProperties() {
return additionalProperties;
}
/**
* Return the additional (undeclared) property with the specified name.
*
* @param key name of the property
* @return an object
*/
public Object getAdditionalProperty(String key) {
if (this.additionalProperties == null) {
return null;
}
return this.additionalProperties.get(key);
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
PreviewOrderOrderAction previewOrderOrderAction = (PreviewOrderOrderAction) o;
return Objects.equals(this.addProduct, previewOrderOrderAction.addProduct) &&
Objects.equals(this.cancelSubscription, previewOrderOrderAction.cancelSubscription) &&
Objects.equals(this.changePlan, previewOrderOrderAction.changePlan) &&
Objects.equals(this.changeReason, previewOrderOrderAction.changeReason) &&
Objects.equals(this.createSubscription, previewOrderOrderAction.createSubscription) &&
Objects.equals(this.customFields, previewOrderOrderAction.customFields) &&
Objects.equals(this.ownerTransfer, previewOrderOrderAction.ownerTransfer) &&
Objects.equals(this.removeProduct, previewOrderOrderAction.removeProduct) &&
Objects.equals(this.renewSubscription, previewOrderOrderAction.renewSubscription) &&
Objects.equals(this.resume, previewOrderOrderAction.resume) &&
Objects.equals(this.suspend, previewOrderOrderAction.suspend) &&
Objects.equals(this.termsAndConditions, previewOrderOrderAction.termsAndConditions) &&
Objects.equals(this.triggerDates, previewOrderOrderAction.triggerDates) &&
Objects.equals(this.type, previewOrderOrderAction.type) &&
Objects.equals(this.updateProduct, previewOrderOrderAction.updateProduct)&&
Objects.equals(this.additionalProperties, previewOrderOrderAction.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(addProduct, cancelSubscription, changePlan, changeReason, createSubscription, customFields, ownerTransfer, removeProduct, renewSubscription, resume, suspend, termsAndConditions, triggerDates, type, updateProduct, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class PreviewOrderOrderAction {\n");
sb.append(" addProduct: ").append(toIndentedString(addProduct)).append("\n");
sb.append(" cancelSubscription: ").append(toIndentedString(cancelSubscription)).append("\n");
sb.append(" changePlan: ").append(toIndentedString(changePlan)).append("\n");
sb.append(" changeReason: ").append(toIndentedString(changeReason)).append("\n");
sb.append(" createSubscription: ").append(toIndentedString(createSubscription)).append("\n");
sb.append(" customFields: ").append(toIndentedString(customFields)).append("\n");
sb.append(" ownerTransfer: ").append(toIndentedString(ownerTransfer)).append("\n");
sb.append(" removeProduct: ").append(toIndentedString(removeProduct)).append("\n");
sb.append(" renewSubscription: ").append(toIndentedString(renewSubscription)).append("\n");
sb.append(" resume: ").append(toIndentedString(resume)).append("\n");
sb.append(" suspend: ").append(toIndentedString(suspend)).append("\n");
sb.append(" termsAndConditions: ").append(toIndentedString(termsAndConditions)).append("\n");
sb.append(" triggerDates: ").append(toIndentedString(triggerDates)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" updateProduct: ").append(toIndentedString(updateProduct)).append("\n");
sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).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("addProduct");
openapiFields.add("cancelSubscription");
openapiFields.add("changePlan");
openapiFields.add("changeReason");
openapiFields.add("createSubscription");
openapiFields.add("customFields");
openapiFields.add("ownerTransfer");
openapiFields.add("removeProduct");
openapiFields.add("renewSubscription");
openapiFields.add("resume");
openapiFields.add("suspend");
openapiFields.add("termsAndConditions");
openapiFields.add("triggerDates");
openapiFields.add("type");
openapiFields.add("updateProduct");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("type");
}
/**
* 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 PreviewOrderOrderAction
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!PreviewOrderOrderAction.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in PreviewOrderOrderAction is not found in the empty JSON string", PreviewOrderOrderAction.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : PreviewOrderOrderAction.openapiRequiredFields) {
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
// validate the optional field `addProduct`
if (jsonObj.get("addProduct") != null && !jsonObj.get("addProduct").isJsonNull()) {
PreviewOrderRatePlanOverride.validateJsonElement(jsonObj.get("addProduct"));
}
// validate the optional field `cancelSubscription`
if (jsonObj.get("cancelSubscription") != null && !jsonObj.get("cancelSubscription").isJsonNull()) {
OrderActionCancelSubscription.validateJsonElement(jsonObj.get("cancelSubscription"));
}
// validate the optional field `changePlan`
if (jsonObj.get("changePlan") != null && !jsonObj.get("changePlan").isJsonNull()) {
CreateOrderChangePlan.validateJsonElement(jsonObj.get("changePlan"));
}
if ((jsonObj.get("changeReason") != null && !jsonObj.get("changeReason").isJsonNull()) && !jsonObj.get("changeReason").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `changeReason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("changeReason").toString()));
}
// validate the optional field `createSubscription`
if (jsonObj.get("createSubscription") != null && !jsonObj.get("createSubscription").isJsonNull()) {
PreviewOrderCreateSubscription.validateJsonElement(jsonObj.get("createSubscription"));
}
// validate the optional field `ownerTransfer`
if (jsonObj.get("ownerTransfer") != null && !jsonObj.get("ownerTransfer").isJsonNull()) {
OrderActionOwnerTransfer.validateJsonElement(jsonObj.get("ownerTransfer"));
}
// validate the optional field `removeProduct`
if (jsonObj.get("removeProduct") != null && !jsonObj.get("removeProduct").isJsonNull()) {
OrderActionRemoveProduct.validateJsonElement(jsonObj.get("removeProduct"));
}
// validate the optional field `renewSubscription`
if (jsonObj.get("renewSubscription") != null && !jsonObj.get("renewSubscription").isJsonNull()) {
OrderActionRenewSubscription.validateJsonElement(jsonObj.get("renewSubscription"));
}
// validate the optional field `resume`
if (jsonObj.get("resume") != null && !jsonObj.get("resume").isJsonNull()) {
CreateOrderResume.validateJsonElement(jsonObj.get("resume"));
}
// validate the optional field `suspend`
if (jsonObj.get("suspend") != null && !jsonObj.get("suspend").isJsonNull()) {
CreateOrderSuspend.validateJsonElement(jsonObj.get("suspend"));
}
// validate the optional field `termsAndConditions`
if (jsonObj.get("termsAndConditions") != null && !jsonObj.get("termsAndConditions").isJsonNull()) {
CreateOrderTermsAndConditions.validateJsonElement(jsonObj.get("termsAndConditions"));
}
if (jsonObj.get("triggerDates") != null && !jsonObj.get("triggerDates").isJsonNull()) {
JsonArray jsonArraytriggerDates = jsonObj.getAsJsonArray("triggerDates");
if (jsonArraytriggerDates != null) {
// ensure the json data is an array
if (!jsonObj.get("triggerDates").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `triggerDates` to be an array in the JSON string but got `%s`", jsonObj.get("triggerDates").toString()));
}
// validate the optional field `triggerDates` (array)
for (int i = 0; i < jsonArraytriggerDates.size(); i++) {
TriggerDate.validateJsonElement(jsonArraytriggerDates.get(i));
};
}
}
if (!jsonObj.get("type").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString()));
}
// validate the required field `type`
OrderActionType.validateJsonElement(jsonObj.get("type"));
// validate the optional field `updateProduct`
if (jsonObj.get("updateProduct") != null && !jsonObj.get("updateProduct").isJsonNull()) {
PreviewOrderRatePlanUpdate.validateJsonElement(jsonObj.get("updateProduct"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!PreviewOrderOrderAction.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'PreviewOrderOrderAction' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(PreviewOrderOrderAction.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, PreviewOrderOrderAction value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
obj.remove("additionalProperties");
// support null values
out.beginObject();
Iterator iterator = obj.entrySet().iterator();
while(iterator.hasNext()) {
Map.Entry e = (Map.Entry) iterator.next();
out.name((String)e.getKey());
elementAdapter.write(out, e.getValue());
}
// end
// serialize additional properties
if (value.getAdditionalProperties() != null) {
// support null values
boolean oldSerializeNulls = out.getSerializeNulls();
out.setSerializeNulls(true); //force serialize
// end
for (Map.Entry entry : value.getAdditionalProperties().entrySet()) {
if (entry.getValue() instanceof String)
obj.addProperty(entry.getKey(), (String) entry.getValue());
else if (entry.getValue() instanceof Number)
obj.addProperty(entry.getKey(), (Number) entry.getValue());
else if (entry.getValue() instanceof Boolean)
obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
else if (entry.getValue() instanceof Character)
obj.addProperty(entry.getKey(), (Character) entry.getValue());
else if (entry.getValue() == null)
obj.add(entry.getKey(), null);
else {
JsonElement jsonElement = gson.toJsonTree(entry.getValue());
if (jsonElement.isJsonArray()) {
obj.add(entry.getKey(), jsonElement.getAsJsonArray());
} else {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
}
}
out.name((String)entry.getKey());
elementAdapter.write(out, obj.get(entry.getKey()));
}
out.setSerializeNulls(oldSerializeNulls); //restore
}
out.endObject();
}
@Override
public PreviewOrderOrderAction read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
PreviewOrderOrderAction instance = thisAdapter.fromJsonTree(jsonObj);
for (Map.Entry entry : jsonObj.entrySet()) {
if (!openapiFields.contains(entry.getKey())) {
if (entry.getValue().isJsonPrimitive()) { // primitive type
if (entry.getValue().getAsJsonPrimitive().isString())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
else if (entry.getValue().getAsJsonPrimitive().isNumber())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
else if (entry.getValue().getAsJsonPrimitive().isBoolean())
instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
else
throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
} else if (entry.getValue().isJsonArray()) {
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
} else { // JSON object
instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
}
}
}
return instance;
}
}.nullSafe();
}
}
/**
* Create an instance of PreviewOrderOrderAction given an JSON string
*
* @param jsonString JSON string
* @return An instance of PreviewOrderOrderAction
* @throws IOException if the JSON string is invalid with respect to PreviewOrderOrderAction
*/
public static PreviewOrderOrderAction fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, PreviewOrderOrderAction.class);
}
/**
* Convert an instance of PreviewOrderOrderAction to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy