com.zuora.model.TaxationItem 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.TaxMode;
import com.zuora.model.TaxRateType;
import com.zuora.model.TaxationItemFinanceInformation;
import java.io.IOException;
import java.math.BigDecimal;
import java.time.LocalDate;
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;
/**
* TaxationItem
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class TaxationItem {
public static final String SERIALIZED_NAME_CREATED_BY_ID = "createdById";
@SerializedName(SERIALIZED_NAME_CREATED_BY_ID)
private String createdById;
public static final String SERIALIZED_NAME_CREATED_DATE = "createdDate";
@SerializedName(SERIALIZED_NAME_CREATED_DATE)
private String createdDate;
public static final String SERIALIZED_NAME_EXEMPT_AMOUNT = "exemptAmount";
@SerializedName(SERIALIZED_NAME_EXEMPT_AMOUNT)
private BigDecimal exemptAmount;
public static final String SERIALIZED_NAME_FINANCE_INFORMATION = "financeInformation";
@SerializedName(SERIALIZED_NAME_FINANCE_INFORMATION)
private TaxationItemFinanceInformation financeInformation;
public static final String SERIALIZED_NAME_ID = "id";
@SerializedName(SERIALIZED_NAME_ID)
private String id;
public static final String SERIALIZED_NAME_INVOICE_ITEM_ID = "invoiceItemId";
@SerializedName(SERIALIZED_NAME_INVOICE_ITEM_ID)
private String invoiceItemId;
public static final String SERIALIZED_NAME_JURISDICTION = "jurisdiction";
@SerializedName(SERIALIZED_NAME_JURISDICTION)
private String jurisdiction;
public static final String SERIALIZED_NAME_LOCATION_CODE = "locationCode";
@SerializedName(SERIALIZED_NAME_LOCATION_CODE)
private String locationCode;
public static final String SERIALIZED_NAME_MEMO_ITEM_ID = "memoItemId";
@SerializedName(SERIALIZED_NAME_MEMO_ITEM_ID)
private String memoItemId;
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_SOURCE_TAX_ITEM_ID = "sourceTaxItemId";
@SerializedName(SERIALIZED_NAME_SOURCE_TAX_ITEM_ID)
private String sourceTaxItemId;
public static final String SERIALIZED_NAME_TAX_AMOUNT = "taxAmount";
@SerializedName(SERIALIZED_NAME_TAX_AMOUNT)
private BigDecimal taxAmount;
public static final String SERIALIZED_NAME_APPLICABLE_TAX_UN_ROUNDED = "applicableTaxUnRounded";
@SerializedName(SERIALIZED_NAME_APPLICABLE_TAX_UN_ROUNDED)
private BigDecimal applicableTaxUnRounded;
public static final String SERIALIZED_NAME_COUNTRY = "country";
@SerializedName(SERIALIZED_NAME_COUNTRY)
private String country;
public static final String SERIALIZED_NAME_TAX_CODE = "taxCode";
@SerializedName(SERIALIZED_NAME_TAX_CODE)
private String taxCode;
public static final String SERIALIZED_NAME_TAX_CODE_DESCRIPTION = "taxCodeDescription";
@SerializedName(SERIALIZED_NAME_TAX_CODE_DESCRIPTION)
private String taxCodeDescription;
public static final String SERIALIZED_NAME_TAX_DATE = "taxDate";
@SerializedName(SERIALIZED_NAME_TAX_DATE)
private LocalDate taxDate;
public static final String SERIALIZED_NAME_TAX_MODE = "taxMode";
@SerializedName(SERIALIZED_NAME_TAX_MODE)
private TaxMode taxMode;
public static final String SERIALIZED_NAME_TAX_RATE = "taxRate";
@SerializedName(SERIALIZED_NAME_TAX_RATE)
private BigDecimal taxRate;
public static final String SERIALIZED_NAME_TAX_RATE_DESCRIPTION = "taxRateDescription";
@SerializedName(SERIALIZED_NAME_TAX_RATE_DESCRIPTION)
private String taxRateDescription;
public static final String SERIALIZED_NAME_TAX_RATE_TYPE = "taxRateType";
@SerializedName(SERIALIZED_NAME_TAX_RATE_TYPE)
private TaxRateType taxRateType;
public static final String SERIALIZED_NAME_UPDATED_BY_ID = "updatedById";
@SerializedName(SERIALIZED_NAME_UPDATED_BY_ID)
private String updatedById;
public static final String SERIALIZED_NAME_UPDATED_DATE = "updatedDate";
@SerializedName(SERIALIZED_NAME_UPDATED_DATE)
private String updatedDate;
public TaxationItem() {
}
public TaxationItem createdById(String createdById) {
this.createdById = createdById;
return this;
}
/**
* The ID of the Zuora user who created the taxation item.
* @return createdById
*/
@javax.annotation.Nullable
public String getCreatedById() {
return createdById;
}
public void setCreatedById(String createdById) {
this.createdById = createdById;
}
public TaxationItem createdDate(String createdDate) {
this.createdDate = createdDate;
return this;
}
/**
* The date and time when the taxation item was created in the Zuora system, in `yyyy-mm-dd hh:mm:ss` format.
* @return createdDate
*/
@javax.annotation.Nullable
public String getCreatedDate() {
return createdDate;
}
public void setCreatedDate(String createdDate) {
this.createdDate = createdDate;
}
public TaxationItem exemptAmount(BigDecimal exemptAmount) {
this.exemptAmount = exemptAmount;
return this;
}
/**
* The calculated tax amount excluded due to the exemption.
* @return exemptAmount
*/
@javax.annotation.Nullable
public BigDecimal getExemptAmount() {
return exemptAmount;
}
public void setExemptAmount(BigDecimal exemptAmount) {
this.exemptAmount = exemptAmount;
}
public TaxationItem financeInformation(TaxationItemFinanceInformation financeInformation) {
this.financeInformation = financeInformation;
return this;
}
/**
* Get financeInformation
* @return financeInformation
*/
@javax.annotation.Nullable
public TaxationItemFinanceInformation getFinanceInformation() {
return financeInformation;
}
public void setFinanceInformation(TaxationItemFinanceInformation financeInformation) {
this.financeInformation = financeInformation;
}
public TaxationItem id(String id) {
this.id = id;
return this;
}
/**
* The ID of the taxation item.
* @return id
*/
@javax.annotation.Nullable
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public TaxationItem invoiceItemId(String invoiceItemId) {
this.invoiceItemId = invoiceItemId;
return this;
}
/**
* The ID of the invoice associated with the taxation item.
* @return invoiceItemId
*/
@javax.annotation.Nullable
public String getInvoiceItemId() {
return invoiceItemId;
}
public void setInvoiceItemId(String invoiceItemId) {
this.invoiceItemId = invoiceItemId;
}
public TaxationItem jurisdiction(String jurisdiction) {
this.jurisdiction = jurisdiction;
return this;
}
/**
* The jurisdiction that applies the tax or VAT. This value is typically a state, province, county, or city.
* @return jurisdiction
*/
@javax.annotation.Nullable
public String getJurisdiction() {
return jurisdiction;
}
public void setJurisdiction(String jurisdiction) {
this.jurisdiction = jurisdiction;
}
public TaxationItem locationCode(String locationCode) {
this.locationCode = locationCode;
return this;
}
/**
* The identifier for the location based on the value of the `taxCode` field.
* @return locationCode
*/
@javax.annotation.Nullable
public String getLocationCode() {
return locationCode;
}
public void setLocationCode(String locationCode) {
this.locationCode = locationCode;
}
public TaxationItem memoItemId(String memoItemId) {
this.memoItemId = memoItemId;
return this;
}
/**
* The identifier for the memo item which is related to this tax item
* @return memoItemId
*/
@javax.annotation.Nullable
public String getMemoItemId() {
return memoItemId;
}
public void setMemoItemId(String memoItemId) {
this.memoItemId = memoItemId;
}
public TaxationItem name(String name) {
this.name = name;
return this;
}
/**
* The name of the taxation item.
* @return name
*/
@javax.annotation.Nullable
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public TaxationItem sourceTaxItemId(String sourceTaxItemId) {
this.sourceTaxItemId = sourceTaxItemId;
return this;
}
/**
* The identifier for which tax item the credit memo/debit memo was given to
* @return sourceTaxItemId
*/
@javax.annotation.Nullable
public String getSourceTaxItemId() {
return sourceTaxItemId;
}
public void setSourceTaxItemId(String sourceTaxItemId) {
this.sourceTaxItemId = sourceTaxItemId;
}
public TaxationItem taxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
return this;
}
/**
* The amount of the tax applied to the invoice.
* @return taxAmount
*/
@javax.annotation.Nullable
public BigDecimal getTaxAmount() {
return taxAmount;
}
public void setTaxAmount(BigDecimal taxAmount) {
this.taxAmount = taxAmount;
}
public TaxationItem applicableTaxUnRounded(BigDecimal applicableTaxUnRounded) {
this.applicableTaxUnRounded = applicableTaxUnRounded;
return this;
}
/**
* The unrounded amount of the tax.
* @return applicableTaxUnRounded
*/
@javax.annotation.Nullable
public BigDecimal getApplicableTaxUnRounded() {
return applicableTaxUnRounded;
}
public void setApplicableTaxUnRounded(BigDecimal applicableTaxUnRounded) {
this.applicableTaxUnRounded = applicableTaxUnRounded;
}
public TaxationItem country(String country) {
this.country = country;
return this;
}
/**
* The field which contains country code.
* @return country
*/
@javax.annotation.Nullable
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public TaxationItem taxCode(String taxCode) {
this.taxCode = taxCode;
return this;
}
/**
* The tax code identifies which tax rules and tax rates to apply to a specific invoice.
* @return taxCode
*/
@javax.annotation.Nullable
public String getTaxCode() {
return taxCode;
}
public void setTaxCode(String taxCode) {
this.taxCode = taxCode;
}
public TaxationItem taxCodeDescription(String taxCodeDescription) {
this.taxCodeDescription = taxCodeDescription;
return this;
}
/**
* The description of the tax code.
* @return taxCodeDescription
*/
@javax.annotation.Nullable
public String getTaxCodeDescription() {
return taxCodeDescription;
}
public void setTaxCodeDescription(String taxCodeDescription) {
this.taxCodeDescription = taxCodeDescription;
}
public TaxationItem taxDate(LocalDate taxDate) {
this.taxDate = taxDate;
return this;
}
/**
* The date when the tax is applied to the invoice.
* @return taxDate
*/
@javax.annotation.Nullable
public LocalDate getTaxDate() {
return taxDate;
}
public void setTaxDate(LocalDate taxDate) {
this.taxDate = taxDate;
}
public TaxationItem taxMode(TaxMode taxMode) {
this.taxMode = taxMode;
return this;
}
/**
* Get taxMode
* @return taxMode
*/
@javax.annotation.Nullable
public TaxMode getTaxMode() {
return taxMode;
}
public void setTaxMode(TaxMode taxMode) {
this.taxMode = taxMode;
}
public TaxationItem taxRate(BigDecimal taxRate) {
this.taxRate = taxRate;
return this;
}
/**
* The tax rate applied to the invoice.
* @return taxRate
*/
@javax.annotation.Nullable
public BigDecimal getTaxRate() {
return taxRate;
}
public void setTaxRate(BigDecimal taxRate) {
this.taxRate = taxRate;
}
public TaxationItem taxRateDescription(String taxRateDescription) {
this.taxRateDescription = taxRateDescription;
return this;
}
/**
* The description of the tax rate.
* @return taxRateDescription
*/
@javax.annotation.Nullable
public String getTaxRateDescription() {
return taxRateDescription;
}
public void setTaxRateDescription(String taxRateDescription) {
this.taxRateDescription = taxRateDescription;
}
public TaxationItem taxRateType(TaxRateType taxRateType) {
this.taxRateType = taxRateType;
return this;
}
/**
* Get taxRateType
* @return taxRateType
*/
@javax.annotation.Nullable
public TaxRateType getTaxRateType() {
return taxRateType;
}
public void setTaxRateType(TaxRateType taxRateType) {
this.taxRateType = taxRateType;
}
public TaxationItem updatedById(String updatedById) {
this.updatedById = updatedById;
return this;
}
/**
* The ID of the Zuora user who last updated the taxation item.
* @return updatedById
*/
@javax.annotation.Nullable
public String getUpdatedById() {
return updatedById;
}
public void setUpdatedById(String updatedById) {
this.updatedById = updatedById;
}
public TaxationItem updatedDate(String updatedDate) {
this.updatedDate = updatedDate;
return this;
}
/**
* The date and time when the taxation item was last updated, in `yyyy-mm-dd hh:mm:ss` format.
* @return updatedDate
*/
@javax.annotation.Nullable
public String getUpdatedDate() {
return updatedDate;
}
public void setUpdatedDate(String updatedDate) {
this.updatedDate = updatedDate;
}
/**
* 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 TaxationItem instance itself
*/
public TaxationItem 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;
}
TaxationItem taxationItem = (TaxationItem) o;
return Objects.equals(this.createdById, taxationItem.createdById) &&
Objects.equals(this.createdDate, taxationItem.createdDate) &&
Objects.equals(this.exemptAmount, taxationItem.exemptAmount) &&
Objects.equals(this.financeInformation, taxationItem.financeInformation) &&
Objects.equals(this.id, taxationItem.id) &&
Objects.equals(this.invoiceItemId, taxationItem.invoiceItemId) &&
Objects.equals(this.jurisdiction, taxationItem.jurisdiction) &&
Objects.equals(this.locationCode, taxationItem.locationCode) &&
Objects.equals(this.memoItemId, taxationItem.memoItemId) &&
Objects.equals(this.name, taxationItem.name) &&
Objects.equals(this.sourceTaxItemId, taxationItem.sourceTaxItemId) &&
Objects.equals(this.taxAmount, taxationItem.taxAmount) &&
Objects.equals(this.applicableTaxUnRounded, taxationItem.applicableTaxUnRounded) &&
Objects.equals(this.country, taxationItem.country) &&
Objects.equals(this.taxCode, taxationItem.taxCode) &&
Objects.equals(this.taxCodeDescription, taxationItem.taxCodeDescription) &&
Objects.equals(this.taxDate, taxationItem.taxDate) &&
Objects.equals(this.taxMode, taxationItem.taxMode) &&
Objects.equals(this.taxRate, taxationItem.taxRate) &&
Objects.equals(this.taxRateDescription, taxationItem.taxRateDescription) &&
Objects.equals(this.taxRateType, taxationItem.taxRateType) &&
Objects.equals(this.updatedById, taxationItem.updatedById) &&
Objects.equals(this.updatedDate, taxationItem.updatedDate)&&
Objects.equals(this.additionalProperties, taxationItem.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(createdById, createdDate, exemptAmount, financeInformation, id, invoiceItemId, jurisdiction, locationCode, memoItemId, name, sourceTaxItemId, taxAmount, applicableTaxUnRounded, country, taxCode, taxCodeDescription, taxDate, taxMode, taxRate, taxRateDescription, taxRateType, updatedById, updatedDate, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TaxationItem {\n");
sb.append(" createdById: ").append(toIndentedString(createdById)).append("\n");
sb.append(" createdDate: ").append(toIndentedString(createdDate)).append("\n");
sb.append(" exemptAmount: ").append(toIndentedString(exemptAmount)).append("\n");
sb.append(" financeInformation: ").append(toIndentedString(financeInformation)).append("\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" invoiceItemId: ").append(toIndentedString(invoiceItemId)).append("\n");
sb.append(" jurisdiction: ").append(toIndentedString(jurisdiction)).append("\n");
sb.append(" locationCode: ").append(toIndentedString(locationCode)).append("\n");
sb.append(" memoItemId: ").append(toIndentedString(memoItemId)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" sourceTaxItemId: ").append(toIndentedString(sourceTaxItemId)).append("\n");
sb.append(" taxAmount: ").append(toIndentedString(taxAmount)).append("\n");
sb.append(" applicableTaxUnRounded: ").append(toIndentedString(applicableTaxUnRounded)).append("\n");
sb.append(" country: ").append(toIndentedString(country)).append("\n");
sb.append(" taxCode: ").append(toIndentedString(taxCode)).append("\n");
sb.append(" taxCodeDescription: ").append(toIndentedString(taxCodeDescription)).append("\n");
sb.append(" taxDate: ").append(toIndentedString(taxDate)).append("\n");
sb.append(" taxMode: ").append(toIndentedString(taxMode)).append("\n");
sb.append(" taxRate: ").append(toIndentedString(taxRate)).append("\n");
sb.append(" taxRateDescription: ").append(toIndentedString(taxRateDescription)).append("\n");
sb.append(" taxRateType: ").append(toIndentedString(taxRateType)).append("\n");
sb.append(" updatedById: ").append(toIndentedString(updatedById)).append("\n");
sb.append(" updatedDate: ").append(toIndentedString(updatedDate)).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("createdById");
openapiFields.add("createdDate");
openapiFields.add("exemptAmount");
openapiFields.add("financeInformation");
openapiFields.add("id");
openapiFields.add("invoiceItemId");
openapiFields.add("jurisdiction");
openapiFields.add("locationCode");
openapiFields.add("memoItemId");
openapiFields.add("name");
openapiFields.add("sourceTaxItemId");
openapiFields.add("taxAmount");
openapiFields.add("applicableTaxUnRounded");
openapiFields.add("country");
openapiFields.add("taxCode");
openapiFields.add("taxCodeDescription");
openapiFields.add("taxDate");
openapiFields.add("taxMode");
openapiFields.add("taxRate");
openapiFields.add("taxRateDescription");
openapiFields.add("taxRateType");
openapiFields.add("updatedById");
openapiFields.add("updatedDate");
// 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 TaxationItem
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!TaxationItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in TaxationItem is not found in the empty JSON string", TaxationItem.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("createdById") != null && !jsonObj.get("createdById").isJsonNull()) && !jsonObj.get("createdById").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `createdById` to be a primitive type in the JSON string but got `%s`", jsonObj.get("createdById").toString()));
}
if ((jsonObj.get("createdDate") != null && !jsonObj.get("createdDate").isJsonNull()) && !jsonObj.get("createdDate").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `createdDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("createdDate").toString()));
}
// validate the optional field `financeInformation`
if (jsonObj.get("financeInformation") != null && !jsonObj.get("financeInformation").isJsonNull()) {
TaxationItemFinanceInformation.validateJsonElement(jsonObj.get("financeInformation"));
}
if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString()));
}
if ((jsonObj.get("invoiceItemId") != null && !jsonObj.get("invoiceItemId").isJsonNull()) && !jsonObj.get("invoiceItemId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `invoiceItemId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceItemId").toString()));
}
if ((jsonObj.get("jurisdiction") != null && !jsonObj.get("jurisdiction").isJsonNull()) && !jsonObj.get("jurisdiction").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `jurisdiction` to be a primitive type in the JSON string but got `%s`", jsonObj.get("jurisdiction").toString()));
}
if ((jsonObj.get("locationCode") != null && !jsonObj.get("locationCode").isJsonNull()) && !jsonObj.get("locationCode").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `locationCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("locationCode").toString()));
}
if ((jsonObj.get("memoItemId") != null && !jsonObj.get("memoItemId").isJsonNull()) && !jsonObj.get("memoItemId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `memoItemId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("memoItemId").toString()));
}
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
}
if ((jsonObj.get("sourceTaxItemId") != null && !jsonObj.get("sourceTaxItemId").isJsonNull()) && !jsonObj.get("sourceTaxItemId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `sourceTaxItemId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sourceTaxItemId").toString()));
}
if ((jsonObj.get("country") != null && !jsonObj.get("country").isJsonNull()) && !jsonObj.get("country").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `country` to be a primitive type in the JSON string but got `%s`", jsonObj.get("country").toString()));
}
if ((jsonObj.get("taxCode") != null && !jsonObj.get("taxCode").isJsonNull()) && !jsonObj.get("taxCode").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxCode").toString()));
}
if ((jsonObj.get("taxCodeDescription") != null && !jsonObj.get("taxCodeDescription").isJsonNull()) && !jsonObj.get("taxCodeDescription").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxCodeDescription` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxCodeDescription").toString()));
}
if ((jsonObj.get("taxMode") != null && !jsonObj.get("taxMode").isJsonNull()) && !jsonObj.get("taxMode").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxMode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxMode").toString()));
}
// validate the optional field `taxMode`
if (jsonObj.get("taxMode") != null && !jsonObj.get("taxMode").isJsonNull()) {
TaxMode.validateJsonElement(jsonObj.get("taxMode"));
}
if ((jsonObj.get("taxRateDescription") != null && !jsonObj.get("taxRateDescription").isJsonNull()) && !jsonObj.get("taxRateDescription").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxRateDescription` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxRateDescription").toString()));
}
if ((jsonObj.get("taxRateType") != null && !jsonObj.get("taxRateType").isJsonNull()) && !jsonObj.get("taxRateType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taxRateType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taxRateType").toString()));
}
// validate the optional field `taxRateType`
if (jsonObj.get("taxRateType") != null && !jsonObj.get("taxRateType").isJsonNull()) {
TaxRateType.validateJsonElement(jsonObj.get("taxRateType"));
}
if ((jsonObj.get("updatedById") != null && !jsonObj.get("updatedById").isJsonNull()) && !jsonObj.get("updatedById").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `updatedById` to be a primitive type in the JSON string but got `%s`", jsonObj.get("updatedById").toString()));
}
if ((jsonObj.get("updatedDate") != null && !jsonObj.get("updatedDate").isJsonNull()) && !jsonObj.get("updatedDate").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `updatedDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("updatedDate").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!TaxationItem.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'TaxationItem' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(TaxationItem.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, TaxationItem 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 TaxationItem read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
TaxationItem 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 TaxationItem given an JSON string
*
* @param jsonString JSON string
* @return An instance of TaxationItem
* @throws IOException if the JSON string is invalid with respect to TaxationItem
*/
public static TaxationItem fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, TaxationItem.class);
}
/**
* Convert an instance of TaxationItem to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy