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

com.zuora.model.GetCreditMemoTaxItemResponse Maven / Gradle / Ivy

There is a newer version: 3.2.1
Show newest version
/*
 * 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.GetCreditMemoTaxItemFinanceInformation;
import com.zuora.model.TaxRateType;
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;

/**
 * GetCreditMemoTaxItemResponse
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class GetCreditMemoTaxItemResponse {
  public static final String SERIALIZED_NAME_APPLIED_AMOUNT = "appliedAmount";
  @SerializedName(SERIALIZED_NAME_APPLIED_AMOUNT)
  private BigDecimal appliedAmount;

  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 GetCreditMemoTaxItemFinanceInformation financeInformation;

  public static final String SERIALIZED_NAME_ID = "id";
  @SerializedName(SERIALIZED_NAME_ID)
  private String id;

  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_NAME = "name";
  @SerializedName(SERIALIZED_NAME_NAME)
  private String name;

  public static final String SERIALIZED_NAME_REFUND_AMOUNT = "refundAmount";
  @SerializedName(SERIALIZED_NAME_REFUND_AMOUNT)
  private BigDecimal refundAmount;

  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_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_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_UNAPPLIED_AMOUNT = "unappliedAmount";
  @SerializedName(SERIALIZED_NAME_UNAPPLIED_AMOUNT)
  private BigDecimal unappliedAmount;

  public GetCreditMemoTaxItemResponse() {
  }

  public GetCreditMemoTaxItemResponse appliedAmount(BigDecimal appliedAmount) {
    this.appliedAmount = appliedAmount;
    return this;
  }

  /**
   * The applied amount of the taxation item. 
   * @return appliedAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getAppliedAmount() {
    return appliedAmount;
  }

  public void setAppliedAmount(BigDecimal appliedAmount) {
    this.appliedAmount = appliedAmount;
  }


  public GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse financeInformation(GetCreditMemoTaxItemFinanceInformation financeInformation) {
    this.financeInformation = financeInformation;
    return this;
  }

  /**
   * Get financeInformation
   * @return financeInformation
   */
  @javax.annotation.Nullable
  public GetCreditMemoTaxItemFinanceInformation getFinanceInformation() {
    return financeInformation;
  }

  public void setFinanceInformation(GetCreditMemoTaxItemFinanceInformation financeInformation) {
    this.financeInformation = financeInformation;
  }


  public GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse refundAmount(BigDecimal refundAmount) {
    this.refundAmount = refundAmount;
    return this;
  }

  /**
   * The amount of the refund on the taxation item. 
   * @return refundAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getRefundAmount() {
    return refundAmount;
  }

  public void setRefundAmount(BigDecimal refundAmount) {
    this.refundAmount = refundAmount;
  }


  public GetCreditMemoTaxItemResponse sourceTaxItemId(String sourceTaxItemId) {
    this.sourceTaxItemId = sourceTaxItemId;
    return this;
  }

  /**
   * The ID of the source taxation item. 
   * @return sourceTaxItemId
   */
  @javax.annotation.Nullable
  public String getSourceTaxItemId() {
    return sourceTaxItemId;
  }

  public void setSourceTaxItemId(String sourceTaxItemId) {
    this.sourceTaxItemId = sourceTaxItemId;
  }


  public GetCreditMemoTaxItemResponse taxAmount(BigDecimal taxAmount) {
    this.taxAmount = taxAmount;
    return this;
  }

  /**
   * The amount of taxation. 
   * @return taxAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getTaxAmount() {
    return taxAmount;
  }

  public void setTaxAmount(BigDecimal taxAmount) {
    this.taxAmount = taxAmount;
  }


  public GetCreditMemoTaxItemResponse taxCode(String taxCode) {
    this.taxCode = taxCode;
    return this;
  }

  /**
   * The tax code identifies which tax rules and tax rates to apply to a specific credit memo. 
   * @return taxCode
   */
  @javax.annotation.Nullable
  public String getTaxCode() {
    return taxCode;
  }

  public void setTaxCode(String taxCode) {
    this.taxCode = taxCode;
  }


  public GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse taxDate(LocalDate taxDate) {
    this.taxDate = taxDate;
    return this;
  }

  /**
   * The date that the tax is applied to the credit memo, in `yyyy-mm-dd` format. 
   * @return taxDate
   */
  @javax.annotation.Nullable
  public LocalDate getTaxDate() {
    return taxDate;
  }

  public void setTaxDate(LocalDate taxDate) {
    this.taxDate = taxDate;
  }


  public GetCreditMemoTaxItemResponse taxRate(BigDecimal taxRate) {
    this.taxRate = taxRate;
    return this;
  }

  /**
   * The tax rate applied to the credit memo. 
   * @return taxRate
   */
  @javax.annotation.Nullable
  public BigDecimal getTaxRate() {
    return taxRate;
  }

  public void setTaxRate(BigDecimal taxRate) {
    this.taxRate = taxRate;
  }


  public GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse unappliedAmount(BigDecimal unappliedAmount) {
    this.unappliedAmount = unappliedAmount;
    return this;
  }

  /**
   * The unapplied amount of the taxation item. 
   * @return unappliedAmount
   */
  @javax.annotation.Nullable
  public BigDecimal getUnappliedAmount() {
    return unappliedAmount;
  }

  public void setUnappliedAmount(BigDecimal unappliedAmount) {
    this.unappliedAmount = unappliedAmount;
  }

  /**
   * 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 GetCreditMemoTaxItemResponse instance itself
   */
  public GetCreditMemoTaxItemResponse 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;
    }
    GetCreditMemoTaxItemResponse getCreditMemoTaxItemResponse = (GetCreditMemoTaxItemResponse) o;
    return Objects.equals(this.appliedAmount, getCreditMemoTaxItemResponse.appliedAmount) &&
        Objects.equals(this.exemptAmount, getCreditMemoTaxItemResponse.exemptAmount) &&
        Objects.equals(this.financeInformation, getCreditMemoTaxItemResponse.financeInformation) &&
        Objects.equals(this.id, getCreditMemoTaxItemResponse.id) &&
        Objects.equals(this.jurisdiction, getCreditMemoTaxItemResponse.jurisdiction) &&
        Objects.equals(this.locationCode, getCreditMemoTaxItemResponse.locationCode) &&
        Objects.equals(this.name, getCreditMemoTaxItemResponse.name) &&
        Objects.equals(this.refundAmount, getCreditMemoTaxItemResponse.refundAmount) &&
        Objects.equals(this.sourceTaxItemId, getCreditMemoTaxItemResponse.sourceTaxItemId) &&
        Objects.equals(this.taxAmount, getCreditMemoTaxItemResponse.taxAmount) &&
        Objects.equals(this.taxCode, getCreditMemoTaxItemResponse.taxCode) &&
        Objects.equals(this.taxCodeDescription, getCreditMemoTaxItemResponse.taxCodeDescription) &&
        Objects.equals(this.taxDate, getCreditMemoTaxItemResponse.taxDate) &&
        Objects.equals(this.taxRate, getCreditMemoTaxItemResponse.taxRate) &&
        Objects.equals(this.taxRateDescription, getCreditMemoTaxItemResponse.taxRateDescription) &&
        Objects.equals(this.taxRateType, getCreditMemoTaxItemResponse.taxRateType) &&
        Objects.equals(this.unappliedAmount, getCreditMemoTaxItemResponse.unappliedAmount)&&
        Objects.equals(this.additionalProperties, getCreditMemoTaxItemResponse.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(appliedAmount, exemptAmount, financeInformation, id, jurisdiction, locationCode, name, refundAmount, sourceTaxItemId, taxAmount, taxCode, taxCodeDescription, taxDate, taxRate, taxRateDescription, taxRateType, unappliedAmount, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class GetCreditMemoTaxItemResponse {\n");
    sb.append("    appliedAmount: ").append(toIndentedString(appliedAmount)).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("    jurisdiction: ").append(toIndentedString(jurisdiction)).append("\n");
    sb.append("    locationCode: ").append(toIndentedString(locationCode)).append("\n");
    sb.append("    name: ").append(toIndentedString(name)).append("\n");
    sb.append("    refundAmount: ").append(toIndentedString(refundAmount)).append("\n");
    sb.append("    sourceTaxItemId: ").append(toIndentedString(sourceTaxItemId)).append("\n");
    sb.append("    taxAmount: ").append(toIndentedString(taxAmount)).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("    taxRate: ").append(toIndentedString(taxRate)).append("\n");
    sb.append("    taxRateDescription: ").append(toIndentedString(taxRateDescription)).append("\n");
    sb.append("    taxRateType: ").append(toIndentedString(taxRateType)).append("\n");
    sb.append("    unappliedAmount: ").append(toIndentedString(unappliedAmount)).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("appliedAmount");
    openapiFields.add("exemptAmount");
    openapiFields.add("financeInformation");
    openapiFields.add("id");
    openapiFields.add("jurisdiction");
    openapiFields.add("locationCode");
    openapiFields.add("name");
    openapiFields.add("refundAmount");
    openapiFields.add("sourceTaxItemId");
    openapiFields.add("taxAmount");
    openapiFields.add("taxCode");
    openapiFields.add("taxCodeDescription");
    openapiFields.add("taxDate");
    openapiFields.add("taxRate");
    openapiFields.add("taxRateDescription");
    openapiFields.add("taxRateType");
    openapiFields.add("unappliedAmount");

    // 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 GetCreditMemoTaxItemResponse
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!GetCreditMemoTaxItemResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in GetCreditMemoTaxItemResponse is not found in the empty JSON string", GetCreditMemoTaxItemResponse.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      // validate the optional field `financeInformation`
      if (jsonObj.get("financeInformation") != null && !jsonObj.get("financeInformation").isJsonNull()) {
        GetCreditMemoTaxItemFinanceInformation.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("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("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("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("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"));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!GetCreditMemoTaxItemResponse.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'GetCreditMemoTaxItemResponse' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(GetCreditMemoTaxItemResponse.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             JsonObject jsonObj = jsonElement.getAsJsonObject();
             // store additional fields in the deserialized instance
             GetCreditMemoTaxItemResponse 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 GetCreditMemoTaxItemResponse given an JSON string
   *
   * @param jsonString JSON string
   * @return An instance of GetCreditMemoTaxItemResponse
   * @throws IOException if the JSON string is invalid with respect to GetCreditMemoTaxItemResponse
   */
  public static GetCreditMemoTaxItemResponse fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, GetCreditMemoTaxItemResponse.class);
  }

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy