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

com.zuora.model.OrderActionRenewSubscription 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 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;

/**
 * Information about an order action of type `RenewSubscription`. 
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class OrderActionRenewSubscription {
  public static final String SERIALIZED_NAME_BILL_TO_CONTACT_ID = "billToContactId";
  @SerializedName(SERIALIZED_NAME_BILL_TO_CONTACT_ID)
  private String billToContactId;

  public static final String SERIALIZED_NAME_CLEARING_EXISTING_BILL_TO_CONTACT = "clearingExistingBillToContact";
  @SerializedName(SERIALIZED_NAME_CLEARING_EXISTING_BILL_TO_CONTACT)
  private Boolean clearingExistingBillToContact = false;

  public static final String SERIALIZED_NAME_CLEARING_EXISTING_INVOICE_GROUP_NUMBER = "clearingExistingInvoiceGroupNumber";
  @SerializedName(SERIALIZED_NAME_CLEARING_EXISTING_INVOICE_GROUP_NUMBER)
  private Boolean clearingExistingInvoiceGroupNumber = false;

  public static final String SERIALIZED_NAME_CLEARING_EXISTING_INVOICE_TEMPLATE = "clearingExistingInvoiceTemplate";
  @SerializedName(SERIALIZED_NAME_CLEARING_EXISTING_INVOICE_TEMPLATE)
  private Boolean clearingExistingInvoiceTemplate = false;

  public static final String SERIALIZED_NAME_CLEARING_EXISTING_PAYMENT_TERM = "clearingExistingPaymentTerm";
  @SerializedName(SERIALIZED_NAME_CLEARING_EXISTING_PAYMENT_TERM)
  private Boolean clearingExistingPaymentTerm = false;

  public static final String SERIALIZED_NAME_CLEARING_EXISTING_SEQUENCE_SET = "clearingExistingSequenceSet";
  @SerializedName(SERIALIZED_NAME_CLEARING_EXISTING_SEQUENCE_SET)
  private Boolean clearingExistingSequenceSet = false;

  public static final String SERIALIZED_NAME_CLEARING_EXISTING_SOLD_TO_CONTACT = "clearingExistingSoldToContact";
  @SerializedName(SERIALIZED_NAME_CLEARING_EXISTING_SOLD_TO_CONTACT)
  private Boolean clearingExistingSoldToContact = false;

  public static final String SERIALIZED_NAME_INVOICE_GROUP_NUMBER = "invoiceGroupNumber";
  @SerializedName(SERIALIZED_NAME_INVOICE_GROUP_NUMBER)
  private String invoiceGroupNumber;

  public static final String SERIALIZED_NAME_INVOICE_TEMPLATE_ID = "invoiceTemplateId";
  @SerializedName(SERIALIZED_NAME_INVOICE_TEMPLATE_ID)
  private String invoiceTemplateId;

  public static final String SERIALIZED_NAME_PAYMENT_TERM = "paymentTerm";
  @SerializedName(SERIALIZED_NAME_PAYMENT_TERM)
  private String paymentTerm;

  public static final String SERIALIZED_NAME_SEQUENCE_SET_ID = "sequenceSetId";
  @SerializedName(SERIALIZED_NAME_SEQUENCE_SET_ID)
  private String sequenceSetId;

  public static final String SERIALIZED_NAME_SOLD_TO_CONTACT_ID = "soldToContactId";
  @SerializedName(SERIALIZED_NAME_SOLD_TO_CONTACT_ID)
  private String soldToContactId;

  public static final String SERIALIZED_NAME_SHIP_TO_CONTACT_ID = "shipToContactId";
  @SerializedName(SERIALIZED_NAME_SHIP_TO_CONTACT_ID)
  private String shipToContactId;

  public static final String SERIALIZED_NAME_CLEARING_EXISTING_SHIP_TO_CONTACT = "clearingExistingShipToContact";
  @SerializedName(SERIALIZED_NAME_CLEARING_EXISTING_SHIP_TO_CONTACT)
  private Boolean clearingExistingShipToContact;

  public OrderActionRenewSubscription() {
  }

  public OrderActionRenewSubscription billToContactId(String billToContactId) {
    this.billToContactId = billToContactId;
    return this;
  }

  /**
   * The ID of the bill-to contact associated with the subscription.  **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Contact from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body. 
   * @return billToContactId
   */
  @javax.annotation.Nullable
  public String getBillToContactId() {
    return billToContactId;
  }

  public void setBillToContactId(String billToContactId) {
    this.billToContactId = billToContactId;
  }


  public OrderActionRenewSubscription clearingExistingBillToContact(Boolean clearingExistingBillToContact) {
    this.clearingExistingBillToContact = clearingExistingBillToContact;
    return this;
  }

  /**
   * Whether to clear the existing bill-to contact ID at the subscription level. This field is mutually exclusive with the `billToContactId` field.  **Note**: If you have the [Flexible Billing Attributes](https://knowledgecenter.zuora.com/Billing/Subscriptions/Flexible_Billing_Attributes) feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body. 
   * @return clearingExistingBillToContact
   */
  @javax.annotation.Nullable
  public Boolean getClearingExistingBillToContact() {
    return clearingExistingBillToContact;
  }

  public void setClearingExistingBillToContact(Boolean clearingExistingBillToContact) {
    this.clearingExistingBillToContact = clearingExistingBillToContact;
  }


  public OrderActionRenewSubscription clearingExistingInvoiceGroupNumber(Boolean clearingExistingInvoiceGroupNumber) {
    this.clearingExistingInvoiceGroupNumber = clearingExistingInvoiceGroupNumber;
    return this;
  }

  /**
   * Whether to clear the existing invoice group number at the subscription level. This field is mutually exclusive with the `invoiceGroupNumber` field.  **Note**: If you have the [Flexible Billing Attributes](https://knowledgecenter.zuora.com/Billing/Subscriptions/Flexible_Billing_Attributes) feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body. 
   * @return clearingExistingInvoiceGroupNumber
   */
  @javax.annotation.Nullable
  public Boolean getClearingExistingInvoiceGroupNumber() {
    return clearingExistingInvoiceGroupNumber;
  }

  public void setClearingExistingInvoiceGroupNumber(Boolean clearingExistingInvoiceGroupNumber) {
    this.clearingExistingInvoiceGroupNumber = clearingExistingInvoiceGroupNumber;
  }


  public OrderActionRenewSubscription clearingExistingInvoiceTemplate(Boolean clearingExistingInvoiceTemplate) {
    this.clearingExistingInvoiceTemplate = clearingExistingInvoiceTemplate;
    return this;
  }

  /**
   * Whether to clear the existing invoice template ID at the subscription level. This field is mutually exclusive with the `invoiceTemplateId` field.  **Note**: If you have the [Flexible Billing Attributes](https://knowledgecenter.zuora.com/Billing/Subscriptions/Flexible_Billing_Attributes) feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body. 
   * @return clearingExistingInvoiceTemplate
   */
  @javax.annotation.Nullable
  public Boolean getClearingExistingInvoiceTemplate() {
    return clearingExistingInvoiceTemplate;
  }

  public void setClearingExistingInvoiceTemplate(Boolean clearingExistingInvoiceTemplate) {
    this.clearingExistingInvoiceTemplate = clearingExistingInvoiceTemplate;
  }


  public OrderActionRenewSubscription clearingExistingPaymentTerm(Boolean clearingExistingPaymentTerm) {
    this.clearingExistingPaymentTerm = clearingExistingPaymentTerm;
    return this;
  }

  /**
   * Whether to clear the existing payment term at the subscription level. This field is mutually exclusive with the `paymentTerm` field.  **Note**: If you have the [Flexible Billing Attributes](https://knowledgecenter.zuora.com/Billing/Subscriptions/Flexible_Billing_Attributes) feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body. 
   * @return clearingExistingPaymentTerm
   */
  @javax.annotation.Nullable
  public Boolean getClearingExistingPaymentTerm() {
    return clearingExistingPaymentTerm;
  }

  public void setClearingExistingPaymentTerm(Boolean clearingExistingPaymentTerm) {
    this.clearingExistingPaymentTerm = clearingExistingPaymentTerm;
  }


  public OrderActionRenewSubscription clearingExistingSequenceSet(Boolean clearingExistingSequenceSet) {
    this.clearingExistingSequenceSet = clearingExistingSequenceSet;
    return this;
  }

  /**
   * Whether to clear the existing sequence set ID at the subscription level. This field is mutually exclusive with the `sequenceSetId` field.  **Note**: If you have the [Flexible Billing Attributes](https://knowledgecenter.zuora.com/Billing/Subscriptions/Flexible_Billing_Attributes) feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body. 
   * @return clearingExistingSequenceSet
   */
  @javax.annotation.Nullable
  public Boolean getClearingExistingSequenceSet() {
    return clearingExistingSequenceSet;
  }

  public void setClearingExistingSequenceSet(Boolean clearingExistingSequenceSet) {
    this.clearingExistingSequenceSet = clearingExistingSequenceSet;
  }


  public OrderActionRenewSubscription clearingExistingSoldToContact(Boolean clearingExistingSoldToContact) {
    this.clearingExistingSoldToContact = clearingExistingSoldToContact;
    return this;
  }

  /**
   * Whether to clear the existing sold-to contact ID at the subscription level. This field is mutually exclusive with the `soldToContactId` field.  **Note**: If you have the [Flexible Billing Attributes](https://knowledgecenter.zuora.com/Billing/Subscriptions/Flexible_Billing_Attributes) feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body. 
   * @return clearingExistingSoldToContact
   */
  @javax.annotation.Nullable
  public Boolean getClearingExistingSoldToContact() {
    return clearingExistingSoldToContact;
  }

  public void setClearingExistingSoldToContact(Boolean clearingExistingSoldToContact) {
    this.clearingExistingSoldToContact = clearingExistingSoldToContact;
  }


  public OrderActionRenewSubscription invoiceGroupNumber(String invoiceGroupNumber) {
    this.invoiceGroupNumber = invoiceGroupNumber;
    return this;
  }

  /**
   * The number of invoice group associated with the subscription.  **Note**: This field is available only if you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature enabled. 
   * @return invoiceGroupNumber
   */
  @javax.annotation.Nullable
  public String getInvoiceGroupNumber() {
    return invoiceGroupNumber;
  }

  public void setInvoiceGroupNumber(String invoiceGroupNumber) {
    this.invoiceGroupNumber = invoiceGroupNumber;
  }


  public OrderActionRenewSubscription invoiceTemplateId(String invoiceTemplateId) {
    this.invoiceTemplateId = invoiceTemplateId;
    return this;
  }

  /**
   * The ID of the invoice template associated with the subscription.  **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Template from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body. 
   * @return invoiceTemplateId
   */
  @javax.annotation.Nullable
  public String getInvoiceTemplateId() {
    return invoiceTemplateId;
  }

  public void setInvoiceTemplateId(String invoiceTemplateId) {
    this.invoiceTemplateId = invoiceTemplateId;
  }


  public OrderActionRenewSubscription paymentTerm(String paymentTerm) {
    this.paymentTerm = paymentTerm;
    return this;
  }

  /**
   * The name of the payment term associated with the subscription. For example, `Net 30`. The payment term determines the due dates of invoices.  **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Term from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body.. 
   * @return paymentTerm
   */
  @javax.annotation.Nullable
  public String getPaymentTerm() {
    return paymentTerm;
  }

  public void setPaymentTerm(String paymentTerm) {
    this.paymentTerm = paymentTerm;
  }


  public OrderActionRenewSubscription sequenceSetId(String sequenceSetId) {
    this.sequenceSetId = sequenceSetId;
    return this;
  }

  /**
   * The ID of the sequence set associated with the subscription.    **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Set from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body. 
   * @return sequenceSetId
   */
  @javax.annotation.Nullable
  public String getSequenceSetId() {
    return sequenceSetId;
  }

  public void setSequenceSetId(String sequenceSetId) {
    this.sequenceSetId = sequenceSetId;
  }


  public OrderActionRenewSubscription soldToContactId(String soldToContactId) {
    this.soldToContactId = soldToContactId;
    return this;
  }

  /**
   * The ID of the sold-to contact associated with the subscription.  **Note**:    - If you have the <a href=\"https://knowledgecenter.zuora.com/Zuora_Billing/Bill_your_customers/Bill_customers_at_subscription_level/Flexible_Billing_Attributes\" target=\"_blank\">Flexible Billing Attributes</a> feature disabled, this field is unavailable in the request body and the value of this field is `null` in the response body.    - If you have the Flexible Billing Attributes feature enabled, and you do not specify this field in the request or you select **Default Contact from Account** for this field during subscription creation, the value of this field is automatically set to `null` in the response body. 
   * @return soldToContactId
   */
  @javax.annotation.Nullable
  public String getSoldToContactId() {
    return soldToContactId;
  }

  public void setSoldToContactId(String soldToContactId) {
    this.soldToContactId = soldToContactId;
  }


  public OrderActionRenewSubscription shipToContactId(String shipToContactId) {
    this.shipToContactId = shipToContactId;
    return this;
  }

  /**
   * The ID of the ship-to contact associated with the subscription. 
   * @return shipToContactId
   */
  @javax.annotation.Nullable
  public String getShipToContactId() {
    return shipToContactId;
  }

  public void setShipToContactId(String shipToContactId) {
    this.shipToContactId = shipToContactId;
  }


  public OrderActionRenewSubscription clearingExistingShipToContact(Boolean clearingExistingShipToContact) {
    this.clearingExistingShipToContact = clearingExistingShipToContact;
    return this;
  }

  /**
   * Whether to clear the existing ship-to contact ID at the subscription level. This field is mutually exclusive with the `shipToContactId` field. 
   * @return clearingExistingShipToContact
   */
  @javax.annotation.Nullable
  public Boolean getClearingExistingShipToContact() {
    return clearingExistingShipToContact;
  }

  public void setClearingExistingShipToContact(Boolean clearingExistingShipToContact) {
    this.clearingExistingShipToContact = clearingExistingShipToContact;
  }

  /**
   * 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 OrderActionRenewSubscription instance itself
   */
  public OrderActionRenewSubscription 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;
    }
    OrderActionRenewSubscription orderActionRenewSubscription = (OrderActionRenewSubscription) o;
    return Objects.equals(this.billToContactId, orderActionRenewSubscription.billToContactId) &&
        Objects.equals(this.clearingExistingBillToContact, orderActionRenewSubscription.clearingExistingBillToContact) &&
        Objects.equals(this.clearingExistingInvoiceGroupNumber, orderActionRenewSubscription.clearingExistingInvoiceGroupNumber) &&
        Objects.equals(this.clearingExistingInvoiceTemplate, orderActionRenewSubscription.clearingExistingInvoiceTemplate) &&
        Objects.equals(this.clearingExistingPaymentTerm, orderActionRenewSubscription.clearingExistingPaymentTerm) &&
        Objects.equals(this.clearingExistingSequenceSet, orderActionRenewSubscription.clearingExistingSequenceSet) &&
        Objects.equals(this.clearingExistingSoldToContact, orderActionRenewSubscription.clearingExistingSoldToContact) &&
        Objects.equals(this.invoiceGroupNumber, orderActionRenewSubscription.invoiceGroupNumber) &&
        Objects.equals(this.invoiceTemplateId, orderActionRenewSubscription.invoiceTemplateId) &&
        Objects.equals(this.paymentTerm, orderActionRenewSubscription.paymentTerm) &&
        Objects.equals(this.sequenceSetId, orderActionRenewSubscription.sequenceSetId) &&
        Objects.equals(this.soldToContactId, orderActionRenewSubscription.soldToContactId) &&
        Objects.equals(this.shipToContactId, orderActionRenewSubscription.shipToContactId) &&
        Objects.equals(this.clearingExistingShipToContact, orderActionRenewSubscription.clearingExistingShipToContact)&&
        Objects.equals(this.additionalProperties, orderActionRenewSubscription.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(billToContactId, clearingExistingBillToContact, clearingExistingInvoiceGroupNumber, clearingExistingInvoiceTemplate, clearingExistingPaymentTerm, clearingExistingSequenceSet, clearingExistingSoldToContact, invoiceGroupNumber, invoiceTemplateId, paymentTerm, sequenceSetId, soldToContactId, shipToContactId, clearingExistingShipToContact, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class OrderActionRenewSubscription {\n");
    sb.append("    billToContactId: ").append(toIndentedString(billToContactId)).append("\n");
    sb.append("    clearingExistingBillToContact: ").append(toIndentedString(clearingExistingBillToContact)).append("\n");
    sb.append("    clearingExistingInvoiceGroupNumber: ").append(toIndentedString(clearingExistingInvoiceGroupNumber)).append("\n");
    sb.append("    clearingExistingInvoiceTemplate: ").append(toIndentedString(clearingExistingInvoiceTemplate)).append("\n");
    sb.append("    clearingExistingPaymentTerm: ").append(toIndentedString(clearingExistingPaymentTerm)).append("\n");
    sb.append("    clearingExistingSequenceSet: ").append(toIndentedString(clearingExistingSequenceSet)).append("\n");
    sb.append("    clearingExistingSoldToContact: ").append(toIndentedString(clearingExistingSoldToContact)).append("\n");
    sb.append("    invoiceGroupNumber: ").append(toIndentedString(invoiceGroupNumber)).append("\n");
    sb.append("    invoiceTemplateId: ").append(toIndentedString(invoiceTemplateId)).append("\n");
    sb.append("    paymentTerm: ").append(toIndentedString(paymentTerm)).append("\n");
    sb.append("    sequenceSetId: ").append(toIndentedString(sequenceSetId)).append("\n");
    sb.append("    soldToContactId: ").append(toIndentedString(soldToContactId)).append("\n");
    sb.append("    shipToContactId: ").append(toIndentedString(shipToContactId)).append("\n");
    sb.append("    clearingExistingShipToContact: ").append(toIndentedString(clearingExistingShipToContact)).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("billToContactId");
    openapiFields.add("clearingExistingBillToContact");
    openapiFields.add("clearingExistingInvoiceGroupNumber");
    openapiFields.add("clearingExistingInvoiceTemplate");
    openapiFields.add("clearingExistingPaymentTerm");
    openapiFields.add("clearingExistingSequenceSet");
    openapiFields.add("clearingExistingSoldToContact");
    openapiFields.add("invoiceGroupNumber");
    openapiFields.add("invoiceTemplateId");
    openapiFields.add("paymentTerm");
    openapiFields.add("sequenceSetId");
    openapiFields.add("soldToContactId");
    openapiFields.add("shipToContactId");
    openapiFields.add("clearingExistingShipToContact");

    // 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 OrderActionRenewSubscription
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!OrderActionRenewSubscription.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in OrderActionRenewSubscription is not found in the empty JSON string", OrderActionRenewSubscription.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("billToContactId") != null && !jsonObj.get("billToContactId").isJsonNull()) && !jsonObj.get("billToContactId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `billToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("billToContactId").toString()));
      }
      if ((jsonObj.get("invoiceGroupNumber") != null && !jsonObj.get("invoiceGroupNumber").isJsonNull()) && !jsonObj.get("invoiceGroupNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `invoiceGroupNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceGroupNumber").toString()));
      }
      if ((jsonObj.get("invoiceTemplateId") != null && !jsonObj.get("invoiceTemplateId").isJsonNull()) && !jsonObj.get("invoiceTemplateId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `invoiceTemplateId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceTemplateId").toString()));
      }
      if ((jsonObj.get("paymentTerm") != null && !jsonObj.get("paymentTerm").isJsonNull()) && !jsonObj.get("paymentTerm").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `paymentTerm` to be a primitive type in the JSON string but got `%s`", jsonObj.get("paymentTerm").toString()));
      }
      if ((jsonObj.get("sequenceSetId") != null && !jsonObj.get("sequenceSetId").isJsonNull()) && !jsonObj.get("sequenceSetId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `sequenceSetId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sequenceSetId").toString()));
      }
      if ((jsonObj.get("soldToContactId") != null && !jsonObj.get("soldToContactId").isJsonNull()) && !jsonObj.get("soldToContactId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `soldToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("soldToContactId").toString()));
      }
      if ((jsonObj.get("shipToContactId") != null && !jsonObj.get("shipToContactId").isJsonNull()) && !jsonObj.get("shipToContactId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `shipToContactId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("shipToContactId").toString()));
      }
  }

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

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

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy