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

com.zuora.model.ExpandedOrders 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.ExpandedAccount;
import com.zuora.model.ExpandedOrderAction;
import com.zuora.model.ExpandedOrderLineItem;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

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;

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

  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_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 static final String SERIALIZED_NAME_DESCRIPTION = "description";
  @SerializedName(SERIALIZED_NAME_DESCRIPTION)
  private String description;

  public static final String SERIALIZED_NAME_ORDER_DATE = "orderDate";
  @SerializedName(SERIALIZED_NAME_ORDER_DATE)
  private LocalDate orderDate;

  public static final String SERIALIZED_NAME_ORDER_NUMBER = "orderNumber";
  @SerializedName(SERIALIZED_NAME_ORDER_NUMBER)
  private String orderNumber;

  public static final String SERIALIZED_NAME_ACCOUNT_ID = "accountId";
  @SerializedName(SERIALIZED_NAME_ACCOUNT_ID)
  private String accountId;

  public static final String SERIALIZED_NAME_STATUS = "status";
  @SerializedName(SERIALIZED_NAME_STATUS)
  private String status;

  public static final String SERIALIZED_NAME_STATE = "state";
  @SerializedName(SERIALIZED_NAME_STATE)
  private String state;

  public static final String SERIALIZED_NAME_CREATED_BY_MIGRATION = "createdByMigration";
  @SerializedName(SERIALIZED_NAME_CREATED_BY_MIGRATION)
  private Boolean createdByMigration;

  public static final String SERIALIZED_NAME_CATEGORY = "category";
  @SerializedName(SERIALIZED_NAME_CATEGORY)
  private String category;

  public static final String SERIALIZED_NAME_INVOICE_SCHEDULE_ID = "invoiceScheduleId";
  @SerializedName(SERIALIZED_NAME_INVOICE_SCHEDULE_ID)
  private String invoiceScheduleId;

  public static final String SERIALIZED_NAME_SCHEDULED_DATE = "scheduledDate";
  @SerializedName(SERIALIZED_NAME_SCHEDULED_DATE)
  private LocalDate scheduledDate;

  public static final String SERIALIZED_NAME_SCHEDULED_DATE_POLICY = "scheduledDatePolicy";
  @SerializedName(SERIALIZED_NAME_SCHEDULED_DATE_POLICY)
  private String scheduledDatePolicy;

  public static final String SERIALIZED_NAME_ERROR_CODE = "errorCode";
  @SerializedName(SERIALIZED_NAME_ERROR_CODE)
  private String errorCode;

  public static final String SERIALIZED_NAME_ERROR_MESSAGE = "errorMessage";
  @SerializedName(SERIALIZED_NAME_ERROR_MESSAGE)
  private String errorMessage;

  public static final String SERIALIZED_NAME_RESPONSE = "response";
  @SerializedName(SERIALIZED_NAME_RESPONSE)
  private String response;

  public static final String SERIALIZED_NAME_REVERTED_ORDER_ID = "revertedOrderId";
  @SerializedName(SERIALIZED_NAME_REVERTED_ORDER_ID)
  private String revertedOrderId;

  public static final String SERIALIZED_NAME_REVERTED_BY_ORDER_ID = "revertedByOrderId";
  @SerializedName(SERIALIZED_NAME_REVERTED_BY_ORDER_ID)
  private String revertedByOrderId;

  public static final String SERIALIZED_NAME_REVERTED_ORDER_NUMBER = "revertedOrderNumber";
  @SerializedName(SERIALIZED_NAME_REVERTED_ORDER_NUMBER)
  private String revertedOrderNumber;

  public static final String SERIALIZED_NAME_REVERSION_ORDER = "reversionOrder";
  @SerializedName(SERIALIZED_NAME_REVERSION_ORDER)
  private Boolean reversionOrder;

  public static final String SERIALIZED_NAME_REVERTED_DATE = "revertedDate";
  @SerializedName(SERIALIZED_NAME_REVERTED_DATE)
  private LocalDate revertedDate;

  public static final String SERIALIZED_NAME_ACCOUNT = "account";
  @SerializedName(SERIALIZED_NAME_ACCOUNT)
  private ExpandedAccount account;

  public static final String SERIALIZED_NAME_ORDER_LINE_ITEMS = "orderLineItems";
  @SerializedName(SERIALIZED_NAME_ORDER_LINE_ITEMS)
  private List orderLineItems;

  public static final String SERIALIZED_NAME_ORDER_ACTIONS = "orderActions";
  @SerializedName(SERIALIZED_NAME_ORDER_ACTIONS)
  private List orderActions;

  public ExpandedOrders() {
  }

  public ExpandedOrders id(String id) {
    this.id = id;
    return this;
  }

  /**
   * Get id
   * @return id
   */
  @javax.annotation.Nullable
  public String getId() {
    return id;
  }

  public void setId(String id) {
    this.id = id;
  }


  public ExpandedOrders createdById(String createdById) {
    this.createdById = createdById;
    return this;
  }

  /**
   * Get createdById
   * @return createdById
   */
  @javax.annotation.Nullable
  public String getCreatedById() {
    return createdById;
  }

  public void setCreatedById(String createdById) {
    this.createdById = createdById;
  }


  public ExpandedOrders createdDate(String createdDate) {
    this.createdDate = createdDate;
    return this;
  }

  /**
   * Get createdDate
   * @return createdDate
   */
  @javax.annotation.Nullable
  public String getCreatedDate() {
    return createdDate;
  }

  public void setCreatedDate(String createdDate) {
    this.createdDate = createdDate;
  }


  public ExpandedOrders updatedById(String updatedById) {
    this.updatedById = updatedById;
    return this;
  }

  /**
   * Get updatedById
   * @return updatedById
   */
  @javax.annotation.Nullable
  public String getUpdatedById() {
    return updatedById;
  }

  public void setUpdatedById(String updatedById) {
    this.updatedById = updatedById;
  }


  public ExpandedOrders updatedDate(String updatedDate) {
    this.updatedDate = updatedDate;
    return this;
  }

  /**
   * Get updatedDate
   * @return updatedDate
   */
  @javax.annotation.Nullable
  public String getUpdatedDate() {
    return updatedDate;
  }

  public void setUpdatedDate(String updatedDate) {
    this.updatedDate = updatedDate;
  }


  public ExpandedOrders description(String description) {
    this.description = description;
    return this;
  }

  /**
   * Get description
   * @return description
   */
  @javax.annotation.Nullable
  public String getDescription() {
    return description;
  }

  public void setDescription(String description) {
    this.description = description;
  }


  public ExpandedOrders orderDate(LocalDate orderDate) {
    this.orderDate = orderDate;
    return this;
  }

  /**
   * Get orderDate
   * @return orderDate
   */
  @javax.annotation.Nullable
  public LocalDate getOrderDate() {
    return orderDate;
  }

  public void setOrderDate(LocalDate orderDate) {
    this.orderDate = orderDate;
  }


  public ExpandedOrders orderNumber(String orderNumber) {
    this.orderNumber = orderNumber;
    return this;
  }

  /**
   * Get orderNumber
   * @return orderNumber
   */
  @javax.annotation.Nullable
  public String getOrderNumber() {
    return orderNumber;
  }

  public void setOrderNumber(String orderNumber) {
    this.orderNumber = orderNumber;
  }


  public ExpandedOrders accountId(String accountId) {
    this.accountId = accountId;
    return this;
  }

  /**
   * Get accountId
   * @return accountId
   */
  @javax.annotation.Nullable
  public String getAccountId() {
    return accountId;
  }

  public void setAccountId(String accountId) {
    this.accountId = accountId;
  }


  public ExpandedOrders status(String status) {
    this.status = status;
    return this;
  }

  /**
   * Get status
   * @return status
   */
  @javax.annotation.Nullable
  public String getStatus() {
    return status;
  }

  public void setStatus(String status) {
    this.status = status;
  }


  public ExpandedOrders state(String state) {
    this.state = state;
    return this;
  }

  /**
   * Get state
   * @return state
   */
  @javax.annotation.Nullable
  public String getState() {
    return state;
  }

  public void setState(String state) {
    this.state = state;
  }


  public ExpandedOrders createdByMigration(Boolean createdByMigration) {
    this.createdByMigration = createdByMigration;
    return this;
  }

  /**
   * Get createdByMigration
   * @return createdByMigration
   */
  @javax.annotation.Nullable
  public Boolean getCreatedByMigration() {
    return createdByMigration;
  }

  public void setCreatedByMigration(Boolean createdByMigration) {
    this.createdByMigration = createdByMigration;
  }


  public ExpandedOrders category(String category) {
    this.category = category;
    return this;
  }

  /**
   * Get category
   * @return category
   */
  @javax.annotation.Nullable
  public String getCategory() {
    return category;
  }

  public void setCategory(String category) {
    this.category = category;
  }


  public ExpandedOrders invoiceScheduleId(String invoiceScheduleId) {
    this.invoiceScheduleId = invoiceScheduleId;
    return this;
  }

  /**
   * Get invoiceScheduleId
   * @return invoiceScheduleId
   */
  @javax.annotation.Nullable
  public String getInvoiceScheduleId() {
    return invoiceScheduleId;
  }

  public void setInvoiceScheduleId(String invoiceScheduleId) {
    this.invoiceScheduleId = invoiceScheduleId;
  }


  public ExpandedOrders scheduledDate(LocalDate scheduledDate) {
    this.scheduledDate = scheduledDate;
    return this;
  }

  /**
   * Get scheduledDate
   * @return scheduledDate
   */
  @javax.annotation.Nullable
  public LocalDate getScheduledDate() {
    return scheduledDate;
  }

  public void setScheduledDate(LocalDate scheduledDate) {
    this.scheduledDate = scheduledDate;
  }


  public ExpandedOrders scheduledDatePolicy(String scheduledDatePolicy) {
    this.scheduledDatePolicy = scheduledDatePolicy;
    return this;
  }

  /**
   * Get scheduledDatePolicy
   * @return scheduledDatePolicy
   */
  @javax.annotation.Nullable
  public String getScheduledDatePolicy() {
    return scheduledDatePolicy;
  }

  public void setScheduledDatePolicy(String scheduledDatePolicy) {
    this.scheduledDatePolicy = scheduledDatePolicy;
  }


  public ExpandedOrders errorCode(String errorCode) {
    this.errorCode = errorCode;
    return this;
  }

  /**
   * Get errorCode
   * @return errorCode
   */
  @javax.annotation.Nullable
  public String getErrorCode() {
    return errorCode;
  }

  public void setErrorCode(String errorCode) {
    this.errorCode = errorCode;
  }


  public ExpandedOrders errorMessage(String errorMessage) {
    this.errorMessage = errorMessage;
    return this;
  }

  /**
   * Get errorMessage
   * @return errorMessage
   */
  @javax.annotation.Nullable
  public String getErrorMessage() {
    return errorMessage;
  }

  public void setErrorMessage(String errorMessage) {
    this.errorMessage = errorMessage;
  }


  public ExpandedOrders response(String response) {
    this.response = response;
    return this;
  }

  /**
   * Get response
   * @return response
   */
  @javax.annotation.Nullable
  public String getResponse() {
    return response;
  }

  public void setResponse(String response) {
    this.response = response;
  }


  public ExpandedOrders revertedOrderId(String revertedOrderId) {
    this.revertedOrderId = revertedOrderId;
    return this;
  }

  /**
   * Get revertedOrderId
   * @return revertedOrderId
   */
  @javax.annotation.Nullable
  public String getRevertedOrderId() {
    return revertedOrderId;
  }

  public void setRevertedOrderId(String revertedOrderId) {
    this.revertedOrderId = revertedOrderId;
  }


  public ExpandedOrders revertedByOrderId(String revertedByOrderId) {
    this.revertedByOrderId = revertedByOrderId;
    return this;
  }

  /**
   * Get revertedByOrderId
   * @return revertedByOrderId
   */
  @javax.annotation.Nullable
  public String getRevertedByOrderId() {
    return revertedByOrderId;
  }

  public void setRevertedByOrderId(String revertedByOrderId) {
    this.revertedByOrderId = revertedByOrderId;
  }


  public ExpandedOrders revertedOrderNumber(String revertedOrderNumber) {
    this.revertedOrderNumber = revertedOrderNumber;
    return this;
  }

  /**
   * Get revertedOrderNumber
   * @return revertedOrderNumber
   */
  @javax.annotation.Nullable
  public String getRevertedOrderNumber() {
    return revertedOrderNumber;
  }

  public void setRevertedOrderNumber(String revertedOrderNumber) {
    this.revertedOrderNumber = revertedOrderNumber;
  }


  public ExpandedOrders reversionOrder(Boolean reversionOrder) {
    this.reversionOrder = reversionOrder;
    return this;
  }

  /**
   * Get reversionOrder
   * @return reversionOrder
   */
  @javax.annotation.Nullable
  public Boolean getReversionOrder() {
    return reversionOrder;
  }

  public void setReversionOrder(Boolean reversionOrder) {
    this.reversionOrder = reversionOrder;
  }


  public ExpandedOrders revertedDate(LocalDate revertedDate) {
    this.revertedDate = revertedDate;
    return this;
  }

  /**
   * Get revertedDate
   * @return revertedDate
   */
  @javax.annotation.Nullable
  public LocalDate getRevertedDate() {
    return revertedDate;
  }

  public void setRevertedDate(LocalDate revertedDate) {
    this.revertedDate = revertedDate;
  }


  public ExpandedOrders account(ExpandedAccount account) {
    this.account = account;
    return this;
  }

  /**
   * Get account
   * @return account
   */
  @javax.annotation.Nullable
  public ExpandedAccount getAccount() {
    return account;
  }

  public void setAccount(ExpandedAccount account) {
    this.account = account;
  }


  public ExpandedOrders orderLineItems(List orderLineItems) {
    this.orderLineItems = orderLineItems;
    return this;
  }

  public ExpandedOrders addOrderLineItemsItem(ExpandedOrderLineItem orderLineItemsItem) {
    if (this.orderLineItems == null) {
      this.orderLineItems = new ArrayList<>();
    }
    this.orderLineItems.add(orderLineItemsItem);
    return this;
  }

  /**
   * Get orderLineItems
   * @return orderLineItems
   */
  @javax.annotation.Nullable
  public List getOrderLineItems() {
    return orderLineItems;
  }

  public void setOrderLineItems(List orderLineItems) {
    this.orderLineItems = orderLineItems;
  }


  public ExpandedOrders orderActions(List orderActions) {
    this.orderActions = orderActions;
    return this;
  }

  public ExpandedOrders addOrderActionsItem(ExpandedOrderAction orderActionsItem) {
    if (this.orderActions == null) {
      this.orderActions = new ArrayList<>();
    }
    this.orderActions.add(orderActionsItem);
    return this;
  }

  /**
   * Get orderActions
   * @return orderActions
   */
  @javax.annotation.Nullable
  public List getOrderActions() {
    return orderActions;
  }

  public void setOrderActions(List orderActions) {
    this.orderActions = orderActions;
  }

  /**
   * 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 ExpandedOrders instance itself
   */
  public ExpandedOrders 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;
    }
    ExpandedOrders expandedOrders = (ExpandedOrders) o;
    return Objects.equals(this.id, expandedOrders.id) &&
        Objects.equals(this.createdById, expandedOrders.createdById) &&
        Objects.equals(this.createdDate, expandedOrders.createdDate) &&
        Objects.equals(this.updatedById, expandedOrders.updatedById) &&
        Objects.equals(this.updatedDate, expandedOrders.updatedDate) &&
        Objects.equals(this.description, expandedOrders.description) &&
        Objects.equals(this.orderDate, expandedOrders.orderDate) &&
        Objects.equals(this.orderNumber, expandedOrders.orderNumber) &&
        Objects.equals(this.accountId, expandedOrders.accountId) &&
        Objects.equals(this.status, expandedOrders.status) &&
        Objects.equals(this.state, expandedOrders.state) &&
        Objects.equals(this.createdByMigration, expandedOrders.createdByMigration) &&
        Objects.equals(this.category, expandedOrders.category) &&
        Objects.equals(this.invoiceScheduleId, expandedOrders.invoiceScheduleId) &&
        Objects.equals(this.scheduledDate, expandedOrders.scheduledDate) &&
        Objects.equals(this.scheduledDatePolicy, expandedOrders.scheduledDatePolicy) &&
        Objects.equals(this.errorCode, expandedOrders.errorCode) &&
        Objects.equals(this.errorMessage, expandedOrders.errorMessage) &&
        Objects.equals(this.response, expandedOrders.response) &&
        Objects.equals(this.revertedOrderId, expandedOrders.revertedOrderId) &&
        Objects.equals(this.revertedByOrderId, expandedOrders.revertedByOrderId) &&
        Objects.equals(this.revertedOrderNumber, expandedOrders.revertedOrderNumber) &&
        Objects.equals(this.reversionOrder, expandedOrders.reversionOrder) &&
        Objects.equals(this.revertedDate, expandedOrders.revertedDate) &&
        Objects.equals(this.account, expandedOrders.account) &&
        Objects.equals(this.orderLineItems, expandedOrders.orderLineItems) &&
        Objects.equals(this.orderActions, expandedOrders.orderActions)&&
        Objects.equals(this.additionalProperties, expandedOrders.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(id, createdById, createdDate, updatedById, updatedDate, description, orderDate, orderNumber, accountId, status, state, createdByMigration, category, invoiceScheduleId, scheduledDate, scheduledDatePolicy, errorCode, errorMessage, response, revertedOrderId, revertedByOrderId, revertedOrderNumber, reversionOrder, revertedDate, account, orderLineItems, orderActions, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ExpandedOrders {\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    createdById: ").append(toIndentedString(createdById)).append("\n");
    sb.append("    createdDate: ").append(toIndentedString(createdDate)).append("\n");
    sb.append("    updatedById: ").append(toIndentedString(updatedById)).append("\n");
    sb.append("    updatedDate: ").append(toIndentedString(updatedDate)).append("\n");
    sb.append("    description: ").append(toIndentedString(description)).append("\n");
    sb.append("    orderDate: ").append(toIndentedString(orderDate)).append("\n");
    sb.append("    orderNumber: ").append(toIndentedString(orderNumber)).append("\n");
    sb.append("    accountId: ").append(toIndentedString(accountId)).append("\n");
    sb.append("    status: ").append(toIndentedString(status)).append("\n");
    sb.append("    state: ").append(toIndentedString(state)).append("\n");
    sb.append("    createdByMigration: ").append(toIndentedString(createdByMigration)).append("\n");
    sb.append("    category: ").append(toIndentedString(category)).append("\n");
    sb.append("    invoiceScheduleId: ").append(toIndentedString(invoiceScheduleId)).append("\n");
    sb.append("    scheduledDate: ").append(toIndentedString(scheduledDate)).append("\n");
    sb.append("    scheduledDatePolicy: ").append(toIndentedString(scheduledDatePolicy)).append("\n");
    sb.append("    errorCode: ").append(toIndentedString(errorCode)).append("\n");
    sb.append("    errorMessage: ").append(toIndentedString(errorMessage)).append("\n");
    sb.append("    response: ").append(toIndentedString(response)).append("\n");
    sb.append("    revertedOrderId: ").append(toIndentedString(revertedOrderId)).append("\n");
    sb.append("    revertedByOrderId: ").append(toIndentedString(revertedByOrderId)).append("\n");
    sb.append("    revertedOrderNumber: ").append(toIndentedString(revertedOrderNumber)).append("\n");
    sb.append("    reversionOrder: ").append(toIndentedString(reversionOrder)).append("\n");
    sb.append("    revertedDate: ").append(toIndentedString(revertedDate)).append("\n");
    sb.append("    account: ").append(toIndentedString(account)).append("\n");
    sb.append("    orderLineItems: ").append(toIndentedString(orderLineItems)).append("\n");
    sb.append("    orderActions: ").append(toIndentedString(orderActions)).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("id");
    openapiFields.add("createdById");
    openapiFields.add("createdDate");
    openapiFields.add("updatedById");
    openapiFields.add("updatedDate");
    openapiFields.add("description");
    openapiFields.add("orderDate");
    openapiFields.add("orderNumber");
    openapiFields.add("accountId");
    openapiFields.add("status");
    openapiFields.add("state");
    openapiFields.add("createdByMigration");
    openapiFields.add("category");
    openapiFields.add("invoiceScheduleId");
    openapiFields.add("scheduledDate");
    openapiFields.add("scheduledDatePolicy");
    openapiFields.add("errorCode");
    openapiFields.add("errorMessage");
    openapiFields.add("response");
    openapiFields.add("revertedOrderId");
    openapiFields.add("revertedByOrderId");
    openapiFields.add("revertedOrderNumber");
    openapiFields.add("reversionOrder");
    openapiFields.add("revertedDate");
    openapiFields.add("account");
    openapiFields.add("orderLineItems");
    openapiFields.add("orderActions");

    // 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 ExpandedOrders
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!ExpandedOrders.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in ExpandedOrders is not found in the empty JSON string", ExpandedOrders.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      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("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()));
      }
      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()));
      }
      if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString()));
      }
      if ((jsonObj.get("orderNumber") != null && !jsonObj.get("orderNumber").isJsonNull()) && !jsonObj.get("orderNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `orderNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("orderNumber").toString()));
      }
      if ((jsonObj.get("accountId") != null && !jsonObj.get("accountId").isJsonNull()) && !jsonObj.get("accountId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `accountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountId").toString()));
      }
      if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
      }
      if ((jsonObj.get("state") != null && !jsonObj.get("state").isJsonNull()) && !jsonObj.get("state").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `state` to be a primitive type in the JSON string but got `%s`", jsonObj.get("state").toString()));
      }
      if ((jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) && !jsonObj.get("category").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString()));
      }
      if ((jsonObj.get("invoiceScheduleId") != null && !jsonObj.get("invoiceScheduleId").isJsonNull()) && !jsonObj.get("invoiceScheduleId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `invoiceScheduleId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceScheduleId").toString()));
      }
      if ((jsonObj.get("scheduledDatePolicy") != null && !jsonObj.get("scheduledDatePolicy").isJsonNull()) && !jsonObj.get("scheduledDatePolicy").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `scheduledDatePolicy` to be a primitive type in the JSON string but got `%s`", jsonObj.get("scheduledDatePolicy").toString()));
      }
      if ((jsonObj.get("errorCode") != null && !jsonObj.get("errorCode").isJsonNull()) && !jsonObj.get("errorCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `errorCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("errorCode").toString()));
      }
      if ((jsonObj.get("errorMessage") != null && !jsonObj.get("errorMessage").isJsonNull()) && !jsonObj.get("errorMessage").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `errorMessage` to be a primitive type in the JSON string but got `%s`", jsonObj.get("errorMessage").toString()));
      }
      if ((jsonObj.get("response") != null && !jsonObj.get("response").isJsonNull()) && !jsonObj.get("response").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `response` to be a primitive type in the JSON string but got `%s`", jsonObj.get("response").toString()));
      }
      if ((jsonObj.get("revertedOrderId") != null && !jsonObj.get("revertedOrderId").isJsonNull()) && !jsonObj.get("revertedOrderId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `revertedOrderId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("revertedOrderId").toString()));
      }
      if ((jsonObj.get("revertedByOrderId") != null && !jsonObj.get("revertedByOrderId").isJsonNull()) && !jsonObj.get("revertedByOrderId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `revertedByOrderId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("revertedByOrderId").toString()));
      }
      if ((jsonObj.get("revertedOrderNumber") != null && !jsonObj.get("revertedOrderNumber").isJsonNull()) && !jsonObj.get("revertedOrderNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `revertedOrderNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("revertedOrderNumber").toString()));
      }
      // ensure the optional json data is an array if present
      if (jsonObj.get("orderLineItems") != null && !jsonObj.get("orderLineItems").isJsonNull() && !jsonObj.get("orderLineItems").isJsonArray()) {
        throw new IllegalArgumentException(String.format("Expected the field `orderLineItems` to be an array in the JSON string but got `%s`", jsonObj.get("orderLineItems").toString()));
      }
      // ensure the optional json data is an array if present
      if (jsonObj.get("orderActions") != null && !jsonObj.get("orderActions").isJsonNull() && !jsonObj.get("orderActions").isJsonArray()) {
        throw new IllegalArgumentException(String.format("Expected the field `orderActions` to be an array in the JSON string but got `%s`", jsonObj.get("orderActions").toString()));
      }
  }

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

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

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy