com.zuora.model.OrderActionRatePlanPricingUpdate 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.DiscountPricingUpdate;
import com.zuora.model.OrderActionRatePlanChargeModelDataOverride;
import com.zuora.model.OrderActionRatePlanRecurringDeliveryPricingUpdate;
import com.zuora.model.RecurringFlatFeePricingUpdate;
import com.zuora.model.RecurringPerUnitPricingUpdate;
import com.zuora.model.RecurringTieredPricingUpdate;
import com.zuora.model.RecurringVolumePricingUpdate;
import com.zuora.model.UsageFlatFeePricingUpdate;
import com.zuora.model.UsageOveragePricingUpdate;
import com.zuora.model.UsagePerUnitPricingUpdate;
import com.zuora.model.UsageTieredPricingUpdate;
import com.zuora.model.UsageTieredWithOveragePricingUpdate;
import com.zuora.model.UsageVolumePricingUpdate;
import java.io.IOException;
import java.util.Arrays;
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;
/**
* OrderActionRatePlanPricingUpdate
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class OrderActionRatePlanPricingUpdate {
public static final String SERIALIZED_NAME_CHARGE_MODEL_DATA = "chargeModelData";
@SerializedName(SERIALIZED_NAME_CHARGE_MODEL_DATA)
private OrderActionRatePlanChargeModelDataOverride chargeModelData;
public static final String SERIALIZED_NAME_DISCOUNT = "discount";
@SerializedName(SERIALIZED_NAME_DISCOUNT)
private DiscountPricingUpdate discount;
public static final String SERIALIZED_NAME_RECURRING_DELIVERY = "recurringDelivery";
@SerializedName(SERIALIZED_NAME_RECURRING_DELIVERY)
private OrderActionRatePlanRecurringDeliveryPricingUpdate recurringDelivery;
public static final String SERIALIZED_NAME_RECURRING_FLAT_FEE = "recurringFlatFee";
@SerializedName(SERIALIZED_NAME_RECURRING_FLAT_FEE)
private RecurringFlatFeePricingUpdate recurringFlatFee;
public static final String SERIALIZED_NAME_RECURRING_PER_UNIT = "recurringPerUnit";
@SerializedName(SERIALIZED_NAME_RECURRING_PER_UNIT)
private RecurringPerUnitPricingUpdate recurringPerUnit;
public static final String SERIALIZED_NAME_RECURRING_TIERED = "recurringTiered";
@SerializedName(SERIALIZED_NAME_RECURRING_TIERED)
private RecurringTieredPricingUpdate recurringTiered;
public static final String SERIALIZED_NAME_RECURRING_VOLUME = "recurringVolume";
@SerializedName(SERIALIZED_NAME_RECURRING_VOLUME)
private RecurringVolumePricingUpdate recurringVolume;
public static final String SERIALIZED_NAME_USAGE_FLAT_FEE = "usageFlatFee";
@SerializedName(SERIALIZED_NAME_USAGE_FLAT_FEE)
private UsageFlatFeePricingUpdate usageFlatFee;
public static final String SERIALIZED_NAME_USAGE_OVERAGE = "usageOverage";
@SerializedName(SERIALIZED_NAME_USAGE_OVERAGE)
private UsageOveragePricingUpdate usageOverage;
public static final String SERIALIZED_NAME_USAGE_PER_UNIT = "usagePerUnit";
@SerializedName(SERIALIZED_NAME_USAGE_PER_UNIT)
private UsagePerUnitPricingUpdate usagePerUnit;
public static final String SERIALIZED_NAME_USAGE_TIERED = "usageTiered";
@SerializedName(SERIALIZED_NAME_USAGE_TIERED)
private UsageTieredPricingUpdate usageTiered;
public static final String SERIALIZED_NAME_USAGE_TIERED_WITH_OVERAGE = "usageTieredWithOverage";
@SerializedName(SERIALIZED_NAME_USAGE_TIERED_WITH_OVERAGE)
private UsageTieredWithOveragePricingUpdate usageTieredWithOverage;
public static final String SERIALIZED_NAME_USAGE_VOLUME = "usageVolume";
@SerializedName(SERIALIZED_NAME_USAGE_VOLUME)
private UsageVolumePricingUpdate usageVolume;
public OrderActionRatePlanPricingUpdate() {
}
public OrderActionRatePlanPricingUpdate chargeModelData(OrderActionRatePlanChargeModelDataOverride chargeModelData) {
this.chargeModelData = chargeModelData;
return this;
}
/**
* Container for charge model configuration data.
* @return chargeModelData
*/
@javax.annotation.Nullable
public OrderActionRatePlanChargeModelDataOverride getChargeModelData() {
return chargeModelData;
}
public void setChargeModelData(OrderActionRatePlanChargeModelDataOverride chargeModelData) {
this.chargeModelData = chargeModelData;
}
public OrderActionRatePlanPricingUpdate discount(DiscountPricingUpdate discount) {
this.discount = discount;
return this;
}
/**
* Pricing information about a discount charge.
* @return discount
*/
@javax.annotation.Nullable
public DiscountPricingUpdate getDiscount() {
return discount;
}
public void setDiscount(DiscountPricingUpdate discount) {
this.discount = discount;
}
public OrderActionRatePlanPricingUpdate recurringDelivery(OrderActionRatePlanRecurringDeliveryPricingUpdate recurringDelivery) {
this.recurringDelivery = recurringDelivery;
return this;
}
/**
* Pricing information about a recurring charge that uses the Delivery Pricing charge model. In this charge model, the charge has a fixed price. This field is only available if you have the Delivery Pricing charge model enabled. **Note**: The Delivery Pricing charge model is in the **Early Adopter** phase. We are actively soliciting feedback from a small set of early adopters before releasing it as generally available. If you want to join this early adopter program, submit a request at <a href=\"http://support.zuora.com/\" target=\"_blank\">Zuora Global Support</a>.
* @return recurringDelivery
*/
@javax.annotation.Nullable
public OrderActionRatePlanRecurringDeliveryPricingUpdate getRecurringDelivery() {
return recurringDelivery;
}
public void setRecurringDelivery(OrderActionRatePlanRecurringDeliveryPricingUpdate recurringDelivery) {
this.recurringDelivery = recurringDelivery;
}
public OrderActionRatePlanPricingUpdate recurringFlatFee(RecurringFlatFeePricingUpdate recurringFlatFee) {
this.recurringFlatFee = recurringFlatFee;
return this;
}
/**
* Pricing information about a recurring charge that uses the \"flat fee\" charge model. In this charge model, the charge has a fixed price.
* @return recurringFlatFee
*/
@javax.annotation.Nullable
public RecurringFlatFeePricingUpdate getRecurringFlatFee() {
return recurringFlatFee;
}
public void setRecurringFlatFee(RecurringFlatFeePricingUpdate recurringFlatFee) {
this.recurringFlatFee = recurringFlatFee;
}
public OrderActionRatePlanPricingUpdate recurringPerUnit(RecurringPerUnitPricingUpdate recurringPerUnit) {
this.recurringPerUnit = recurringPerUnit;
return this;
}
/**
* Pricing information about a recurring charge that uses the \"per unit\" charge model. In this charge model, the charge has a fixed price per unit purchased.
* @return recurringPerUnit
*/
@javax.annotation.Nullable
public RecurringPerUnitPricingUpdate getRecurringPerUnit() {
return recurringPerUnit;
}
public void setRecurringPerUnit(RecurringPerUnitPricingUpdate recurringPerUnit) {
this.recurringPerUnit = recurringPerUnit;
}
public OrderActionRatePlanPricingUpdate recurringTiered(RecurringTieredPricingUpdate recurringTiered) {
this.recurringTiered = recurringTiered;
return this;
}
/**
* Pricing information about a recurring charge that uses the \"tiered pricing\" charge model. In this charge model, the charge has cumulative pricing tiers that become effective as units are purchased.
* @return recurringTiered
*/
@javax.annotation.Nullable
public RecurringTieredPricingUpdate getRecurringTiered() {
return recurringTiered;
}
public void setRecurringTiered(RecurringTieredPricingUpdate recurringTiered) {
this.recurringTiered = recurringTiered;
}
public OrderActionRatePlanPricingUpdate recurringVolume(RecurringVolumePricingUpdate recurringVolume) {
this.recurringVolume = recurringVolume;
return this;
}
/**
* Pricing information about a recurring charge that uses the \"volume pricing\" charge model. In this charge model, the charge has a variable price per unit, depending on how many units are purchased.
* @return recurringVolume
*/
@javax.annotation.Nullable
public RecurringVolumePricingUpdate getRecurringVolume() {
return recurringVolume;
}
public void setRecurringVolume(RecurringVolumePricingUpdate recurringVolume) {
this.recurringVolume = recurringVolume;
}
public OrderActionRatePlanPricingUpdate usageFlatFee(UsageFlatFeePricingUpdate usageFlatFee) {
this.usageFlatFee = usageFlatFee;
return this;
}
/**
* Pricing information about a usage charge that uses the \"flat fee\" charge model. In this charge model, the charge has a fixed price.
* @return usageFlatFee
*/
@javax.annotation.Nullable
public UsageFlatFeePricingUpdate getUsageFlatFee() {
return usageFlatFee;
}
public void setUsageFlatFee(UsageFlatFeePricingUpdate usageFlatFee) {
this.usageFlatFee = usageFlatFee;
}
public OrderActionRatePlanPricingUpdate usageOverage(UsageOveragePricingUpdate usageOverage) {
this.usageOverage = usageOverage;
return this;
}
/**
* Pricing information about a usage charge that uses the \"overage\" charge model. In this charge model, the charge has an allowance of free units and a fixed price per additional unit consumed.
* @return usageOverage
*/
@javax.annotation.Nullable
public UsageOveragePricingUpdate getUsageOverage() {
return usageOverage;
}
public void setUsageOverage(UsageOveragePricingUpdate usageOverage) {
this.usageOverage = usageOverage;
}
public OrderActionRatePlanPricingUpdate usagePerUnit(UsagePerUnitPricingUpdate usagePerUnit) {
this.usagePerUnit = usagePerUnit;
return this;
}
/**
* Pricing information about a usage charge that uses the \"per unit\" charge model. In this charge model, the charge has a fixed price per unit consumed.
* @return usagePerUnit
*/
@javax.annotation.Nullable
public UsagePerUnitPricingUpdate getUsagePerUnit() {
return usagePerUnit;
}
public void setUsagePerUnit(UsagePerUnitPricingUpdate usagePerUnit) {
this.usagePerUnit = usagePerUnit;
}
public OrderActionRatePlanPricingUpdate usageTiered(UsageTieredPricingUpdate usageTiered) {
this.usageTiered = usageTiered;
return this;
}
/**
* Pricing information about a usage charge that uses the \"tiered pricing\" charge model. In this charge model, the charge has cumulative pricing tiers that become effective as units are consumed.
* @return usageTiered
*/
@javax.annotation.Nullable
public UsageTieredPricingUpdate getUsageTiered() {
return usageTiered;
}
public void setUsageTiered(UsageTieredPricingUpdate usageTiered) {
this.usageTiered = usageTiered;
}
public OrderActionRatePlanPricingUpdate usageTieredWithOverage(UsageTieredWithOveragePricingUpdate usageTieredWithOverage) {
this.usageTieredWithOverage = usageTieredWithOverage;
return this;
}
/**
* Pricing information about a usage charge that uses the \"tiered with overage\" charge model. In this charge model, the charge has cumulative pricing tiers that become effective as units are consumed. The charge also has a fixed price per unit consumed beyond the limit of the final tier.
* @return usageTieredWithOverage
*/
@javax.annotation.Nullable
public UsageTieredWithOveragePricingUpdate getUsageTieredWithOverage() {
return usageTieredWithOverage;
}
public void setUsageTieredWithOverage(UsageTieredWithOveragePricingUpdate usageTieredWithOverage) {
this.usageTieredWithOverage = usageTieredWithOverage;
}
public OrderActionRatePlanPricingUpdate usageVolume(UsageVolumePricingUpdate usageVolume) {
this.usageVolume = usageVolume;
return this;
}
/**
* Pricing information about a usage charge that uses the \"volume pricing\" charge model. In this charge model, the charge has a variable price per unit, depending on how many units are consumed.
* @return usageVolume
*/
@javax.annotation.Nullable
public UsageVolumePricingUpdate getUsageVolume() {
return usageVolume;
}
public void setUsageVolume(UsageVolumePricingUpdate usageVolume) {
this.usageVolume = usageVolume;
}
/**
* 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 OrderActionRatePlanPricingUpdate instance itself
*/
public OrderActionRatePlanPricingUpdate 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;
}
OrderActionRatePlanPricingUpdate orderActionRatePlanPricingUpdate = (OrderActionRatePlanPricingUpdate) o;
return Objects.equals(this.chargeModelData, orderActionRatePlanPricingUpdate.chargeModelData) &&
Objects.equals(this.discount, orderActionRatePlanPricingUpdate.discount) &&
Objects.equals(this.recurringDelivery, orderActionRatePlanPricingUpdate.recurringDelivery) &&
Objects.equals(this.recurringFlatFee, orderActionRatePlanPricingUpdate.recurringFlatFee) &&
Objects.equals(this.recurringPerUnit, orderActionRatePlanPricingUpdate.recurringPerUnit) &&
Objects.equals(this.recurringTiered, orderActionRatePlanPricingUpdate.recurringTiered) &&
Objects.equals(this.recurringVolume, orderActionRatePlanPricingUpdate.recurringVolume) &&
Objects.equals(this.usageFlatFee, orderActionRatePlanPricingUpdate.usageFlatFee) &&
Objects.equals(this.usageOverage, orderActionRatePlanPricingUpdate.usageOverage) &&
Objects.equals(this.usagePerUnit, orderActionRatePlanPricingUpdate.usagePerUnit) &&
Objects.equals(this.usageTiered, orderActionRatePlanPricingUpdate.usageTiered) &&
Objects.equals(this.usageTieredWithOverage, orderActionRatePlanPricingUpdate.usageTieredWithOverage) &&
Objects.equals(this.usageVolume, orderActionRatePlanPricingUpdate.usageVolume)&&
Objects.equals(this.additionalProperties, orderActionRatePlanPricingUpdate.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(chargeModelData, discount, recurringDelivery, recurringFlatFee, recurringPerUnit, recurringTiered, recurringVolume, usageFlatFee, usageOverage, usagePerUnit, usageTiered, usageTieredWithOverage, usageVolume, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class OrderActionRatePlanPricingUpdate {\n");
sb.append(" chargeModelData: ").append(toIndentedString(chargeModelData)).append("\n");
sb.append(" discount: ").append(toIndentedString(discount)).append("\n");
sb.append(" recurringDelivery: ").append(toIndentedString(recurringDelivery)).append("\n");
sb.append(" recurringFlatFee: ").append(toIndentedString(recurringFlatFee)).append("\n");
sb.append(" recurringPerUnit: ").append(toIndentedString(recurringPerUnit)).append("\n");
sb.append(" recurringTiered: ").append(toIndentedString(recurringTiered)).append("\n");
sb.append(" recurringVolume: ").append(toIndentedString(recurringVolume)).append("\n");
sb.append(" usageFlatFee: ").append(toIndentedString(usageFlatFee)).append("\n");
sb.append(" usageOverage: ").append(toIndentedString(usageOverage)).append("\n");
sb.append(" usagePerUnit: ").append(toIndentedString(usagePerUnit)).append("\n");
sb.append(" usageTiered: ").append(toIndentedString(usageTiered)).append("\n");
sb.append(" usageTieredWithOverage: ").append(toIndentedString(usageTieredWithOverage)).append("\n");
sb.append(" usageVolume: ").append(toIndentedString(usageVolume)).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("chargeModelData");
openapiFields.add("discount");
openapiFields.add("recurringDelivery");
openapiFields.add("recurringFlatFee");
openapiFields.add("recurringPerUnit");
openapiFields.add("recurringTiered");
openapiFields.add("recurringVolume");
openapiFields.add("usageFlatFee");
openapiFields.add("usageOverage");
openapiFields.add("usagePerUnit");
openapiFields.add("usageTiered");
openapiFields.add("usageTieredWithOverage");
openapiFields.add("usageVolume");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* 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 OrderActionRatePlanPricingUpdate
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!OrderActionRatePlanPricingUpdate.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in OrderActionRatePlanPricingUpdate is not found in the empty JSON string", OrderActionRatePlanPricingUpdate.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
// validate the optional field `chargeModelData`
if (jsonObj.get("chargeModelData") != null && !jsonObj.get("chargeModelData").isJsonNull()) {
OrderActionRatePlanChargeModelDataOverride.validateJsonElement(jsonObj.get("chargeModelData"));
}
// validate the optional field `discount`
if (jsonObj.get("discount") != null && !jsonObj.get("discount").isJsonNull()) {
DiscountPricingUpdate.validateJsonElement(jsonObj.get("discount"));
}
// validate the optional field `recurringDelivery`
if (jsonObj.get("recurringDelivery") != null && !jsonObj.get("recurringDelivery").isJsonNull()) {
OrderActionRatePlanRecurringDeliveryPricingUpdate.validateJsonElement(jsonObj.get("recurringDelivery"));
}
// validate the optional field `recurringFlatFee`
if (jsonObj.get("recurringFlatFee") != null && !jsonObj.get("recurringFlatFee").isJsonNull()) {
RecurringFlatFeePricingUpdate.validateJsonElement(jsonObj.get("recurringFlatFee"));
}
// validate the optional field `recurringPerUnit`
if (jsonObj.get("recurringPerUnit") != null && !jsonObj.get("recurringPerUnit").isJsonNull()) {
RecurringPerUnitPricingUpdate.validateJsonElement(jsonObj.get("recurringPerUnit"));
}
// validate the optional field `recurringTiered`
if (jsonObj.get("recurringTiered") != null && !jsonObj.get("recurringTiered").isJsonNull()) {
RecurringTieredPricingUpdate.validateJsonElement(jsonObj.get("recurringTiered"));
}
// validate the optional field `recurringVolume`
if (jsonObj.get("recurringVolume") != null && !jsonObj.get("recurringVolume").isJsonNull()) {
RecurringVolumePricingUpdate.validateJsonElement(jsonObj.get("recurringVolume"));
}
// validate the optional field `usageFlatFee`
if (jsonObj.get("usageFlatFee") != null && !jsonObj.get("usageFlatFee").isJsonNull()) {
UsageFlatFeePricingUpdate.validateJsonElement(jsonObj.get("usageFlatFee"));
}
// validate the optional field `usageOverage`
if (jsonObj.get("usageOverage") != null && !jsonObj.get("usageOverage").isJsonNull()) {
UsageOveragePricingUpdate.validateJsonElement(jsonObj.get("usageOverage"));
}
// validate the optional field `usagePerUnit`
if (jsonObj.get("usagePerUnit") != null && !jsonObj.get("usagePerUnit").isJsonNull()) {
UsagePerUnitPricingUpdate.validateJsonElement(jsonObj.get("usagePerUnit"));
}
// validate the optional field `usageTiered`
if (jsonObj.get("usageTiered") != null && !jsonObj.get("usageTiered").isJsonNull()) {
UsageTieredPricingUpdate.validateJsonElement(jsonObj.get("usageTiered"));
}
// validate the optional field `usageTieredWithOverage`
if (jsonObj.get("usageTieredWithOverage") != null && !jsonObj.get("usageTieredWithOverage").isJsonNull()) {
UsageTieredWithOveragePricingUpdate.validateJsonElement(jsonObj.get("usageTieredWithOverage"));
}
// validate the optional field `usageVolume`
if (jsonObj.get("usageVolume") != null && !jsonObj.get("usageVolume").isJsonNull()) {
UsageVolumePricingUpdate.validateJsonElement(jsonObj.get("usageVolume"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!OrderActionRatePlanPricingUpdate.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'OrderActionRatePlanPricingUpdate' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(OrderActionRatePlanPricingUpdate.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, OrderActionRatePlanPricingUpdate 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 OrderActionRatePlanPricingUpdate read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
OrderActionRatePlanPricingUpdate 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 OrderActionRatePlanPricingUpdate given an JSON string
*
* @param jsonString JSON string
* @return An instance of OrderActionRatePlanPricingUpdate
* @throws IOException if the JSON string is invalid with respect to OrderActionRatePlanPricingUpdate
*/
public static OrderActionRatePlanPricingUpdate fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, OrderActionRatePlanPricingUpdate.class);
}
/**
* Convert an instance of OrderActionRatePlanPricingUpdate to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy