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

com.zuora.model.ExpandedRatingResult 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.ExpandedInvoiceItem;
import com.zuora.model.ExpandedRatePlanCharge;
import com.zuora.model.ExpandedSubscription;
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;

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

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

  public static final String SERIALIZED_NAME_SUBSCRIPTION_ID = "subscriptionId";
  @SerializedName(SERIALIZED_NAME_SUBSCRIPTION_ID)
  private String subscriptionId;

  public static final String SERIALIZED_NAME_RATE_PLAN_CHARGE_ID = "ratePlanChargeId";
  @SerializedName(SERIALIZED_NAME_RATE_PLAN_CHARGE_ID)
  private String ratePlanChargeId;

  public static final String SERIALIZED_NAME_QUANTITY = "quantity";
  @SerializedName(SERIALIZED_NAME_QUANTITY)
  private BigDecimal quantity;

  public static final String SERIALIZED_NAME_AMOUNT = "amount";
  @SerializedName(SERIALIZED_NAME_AMOUNT)
  private BigDecimal amount;

  public static final String SERIALIZED_NAME_SERVICE_START_DATE = "serviceStartDate";
  @SerializedName(SERIALIZED_NAME_SERVICE_START_DATE)
  private LocalDate serviceStartDate;

  public static final String SERIALIZED_NAME_SERVICE_END_DATE = "serviceEndDate";
  @SerializedName(SERIALIZED_NAME_SERVICE_END_DATE)
  private LocalDate serviceEndDate;

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

  public static final String SERIALIZED_NAME_IS_PARTIAL = "isPartial";
  @SerializedName(SERIALIZED_NAME_IS_PARTIAL)
  private Boolean isPartial;

  public static final String SERIALIZED_NAME_CHARGE_SEGMENT_NUMBER = "chargeSegmentNumber";
  @SerializedName(SERIALIZED_NAME_CHARGE_SEGMENT_NUMBER)
  private Integer chargeSegmentNumber;

  public static final String SERIALIZED_NAME_CREATED_BY_I_D = "createdByID";
  @SerializedName(SERIALIZED_NAME_CREATED_BY_I_D)
  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_I_D = "updatedByID";
  @SerializedName(SERIALIZED_NAME_UPDATED_BY_I_D)
  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_INVOICE_ITEM_ID = "invoiceItemId";
  @SerializedName(SERIALIZED_NAME_INVOICE_ITEM_ID)
  private String invoiceItemId;

  public static final String SERIALIZED_NAME_ACTUAL_PERIOD_START_DATE = "actualPeriodStartDate";
  @SerializedName(SERIALIZED_NAME_ACTUAL_PERIOD_START_DATE)
  private LocalDate actualPeriodStartDate;

  public static final String SERIALIZED_NAME_ACTUAL_PERIOD_END_DATE = "actualPeriodEndDate";
  @SerializedName(SERIALIZED_NAME_ACTUAL_PERIOD_END_DATE)
  private LocalDate actualPeriodEndDate;

  public static final String SERIALIZED_NAME_BILLING_CYCLE_DAY = "billingCycleDay";
  @SerializedName(SERIALIZED_NAME_BILLING_CYCLE_DAY)
  private Integer billingCycleDay;

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

  public static final String SERIALIZED_NAME_RATE_PLAN_CHARGE = "ratePlanCharge";
  @SerializedName(SERIALIZED_NAME_RATE_PLAN_CHARGE)
  private ExpandedRatePlanCharge ratePlanCharge;

  public static final String SERIALIZED_NAME_SUBSCRIPTION = "subscription";
  @SerializedName(SERIALIZED_NAME_SUBSCRIPTION)
  private ExpandedSubscription subscription;

  public static final String SERIALIZED_NAME_INVOICE_ITEM = "invoiceItem";
  @SerializedName(SERIALIZED_NAME_INVOICE_ITEM)
  private ExpandedInvoiceItem invoiceItem;

  public ExpandedRatingResult() {
  }

  public ExpandedRatingResult 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 ExpandedRatingResult 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 ExpandedRatingResult subscriptionId(String subscriptionId) {
    this.subscriptionId = subscriptionId;
    return this;
  }

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

  public void setSubscriptionId(String subscriptionId) {
    this.subscriptionId = subscriptionId;
  }


  public ExpandedRatingResult ratePlanChargeId(String ratePlanChargeId) {
    this.ratePlanChargeId = ratePlanChargeId;
    return this;
  }

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

  public void setRatePlanChargeId(String ratePlanChargeId) {
    this.ratePlanChargeId = ratePlanChargeId;
  }


  public ExpandedRatingResult quantity(BigDecimal quantity) {
    this.quantity = quantity;
    return this;
  }

  /**
   * Get quantity
   * @return quantity
   */
  @javax.annotation.Nullable
  public BigDecimal getQuantity() {
    return quantity;
  }

  public void setQuantity(BigDecimal quantity) {
    this.quantity = quantity;
  }


  public ExpandedRatingResult amount(BigDecimal amount) {
    this.amount = amount;
    return this;
  }

  /**
   * Get amount
   * @return amount
   */
  @javax.annotation.Nullable
  public BigDecimal getAmount() {
    return amount;
  }

  public void setAmount(BigDecimal amount) {
    this.amount = amount;
  }


  public ExpandedRatingResult serviceStartDate(LocalDate serviceStartDate) {
    this.serviceStartDate = serviceStartDate;
    return this;
  }

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

  public void setServiceStartDate(LocalDate serviceStartDate) {
    this.serviceStartDate = serviceStartDate;
  }


  public ExpandedRatingResult serviceEndDate(LocalDate serviceEndDate) {
    this.serviceEndDate = serviceEndDate;
    return this;
  }

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

  public void setServiceEndDate(LocalDate serviceEndDate) {
    this.serviceEndDate = serviceEndDate;
  }


  public ExpandedRatingResult 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 ExpandedRatingResult isPartial(Boolean isPartial) {
    this.isPartial = isPartial;
    return this;
  }

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

  public void setIsPartial(Boolean isPartial) {
    this.isPartial = isPartial;
  }


  public ExpandedRatingResult chargeSegmentNumber(Integer chargeSegmentNumber) {
    this.chargeSegmentNumber = chargeSegmentNumber;
    return this;
  }

  /**
   * Get chargeSegmentNumber
   * @return chargeSegmentNumber
   */
  @javax.annotation.Nullable
  public Integer getChargeSegmentNumber() {
    return chargeSegmentNumber;
  }

  public void setChargeSegmentNumber(Integer chargeSegmentNumber) {
    this.chargeSegmentNumber = chargeSegmentNumber;
  }


  public ExpandedRatingResult 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 ExpandedRatingResult 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 ExpandedRatingResult 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 ExpandedRatingResult 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 ExpandedRatingResult invoiceItemId(String invoiceItemId) {
    this.invoiceItemId = invoiceItemId;
    return this;
  }

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

  public void setInvoiceItemId(String invoiceItemId) {
    this.invoiceItemId = invoiceItemId;
  }


  public ExpandedRatingResult actualPeriodStartDate(LocalDate actualPeriodStartDate) {
    this.actualPeriodStartDate = actualPeriodStartDate;
    return this;
  }

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

  public void setActualPeriodStartDate(LocalDate actualPeriodStartDate) {
    this.actualPeriodStartDate = actualPeriodStartDate;
  }


  public ExpandedRatingResult actualPeriodEndDate(LocalDate actualPeriodEndDate) {
    this.actualPeriodEndDate = actualPeriodEndDate;
    return this;
  }

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

  public void setActualPeriodEndDate(LocalDate actualPeriodEndDate) {
    this.actualPeriodEndDate = actualPeriodEndDate;
  }


  public ExpandedRatingResult billingCycleDay(Integer billingCycleDay) {
    this.billingCycleDay = billingCycleDay;
    return this;
  }

  /**
   * Get billingCycleDay
   * @return billingCycleDay
   */
  @javax.annotation.Nullable
  public Integer getBillingCycleDay() {
    return billingCycleDay;
  }

  public void setBillingCycleDay(Integer billingCycleDay) {
    this.billingCycleDay = billingCycleDay;
  }


  public ExpandedRatingResult 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 ExpandedRatingResult ratePlanCharge(ExpandedRatePlanCharge ratePlanCharge) {
    this.ratePlanCharge = ratePlanCharge;
    return this;
  }

  /**
   * Get ratePlanCharge
   * @return ratePlanCharge
   */
  @javax.annotation.Nullable
  public ExpandedRatePlanCharge getRatePlanCharge() {
    return ratePlanCharge;
  }

  public void setRatePlanCharge(ExpandedRatePlanCharge ratePlanCharge) {
    this.ratePlanCharge = ratePlanCharge;
  }


  public ExpandedRatingResult subscription(ExpandedSubscription subscription) {
    this.subscription = subscription;
    return this;
  }

  /**
   * Get subscription
   * @return subscription
   */
  @javax.annotation.Nullable
  public ExpandedSubscription getSubscription() {
    return subscription;
  }

  public void setSubscription(ExpandedSubscription subscription) {
    this.subscription = subscription;
  }


  public ExpandedRatingResult invoiceItem(ExpandedInvoiceItem invoiceItem) {
    this.invoiceItem = invoiceItem;
    return this;
  }

  /**
   * Get invoiceItem
   * @return invoiceItem
   */
  @javax.annotation.Nullable
  public ExpandedInvoiceItem getInvoiceItem() {
    return invoiceItem;
  }

  public void setInvoiceItem(ExpandedInvoiceItem invoiceItem) {
    this.invoiceItem = invoiceItem;
  }

  /**
   * 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 ExpandedRatingResult instance itself
   */
  public ExpandedRatingResult 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;
    }
    ExpandedRatingResult expandedRatingResult = (ExpandedRatingResult) o;
    return Objects.equals(this.id, expandedRatingResult.id) &&
        Objects.equals(this.accountId, expandedRatingResult.accountId) &&
        Objects.equals(this.subscriptionId, expandedRatingResult.subscriptionId) &&
        Objects.equals(this.ratePlanChargeId, expandedRatingResult.ratePlanChargeId) &&
        Objects.equals(this.quantity, expandedRatingResult.quantity) &&
        Objects.equals(this.amount, expandedRatingResult.amount) &&
        Objects.equals(this.serviceStartDate, expandedRatingResult.serviceStartDate) &&
        Objects.equals(this.serviceEndDate, expandedRatingResult.serviceEndDate) &&
        Objects.equals(this.status, expandedRatingResult.status) &&
        Objects.equals(this.isPartial, expandedRatingResult.isPartial) &&
        Objects.equals(this.chargeSegmentNumber, expandedRatingResult.chargeSegmentNumber) &&
        Objects.equals(this.createdByID, expandedRatingResult.createdByID) &&
        Objects.equals(this.createdDate, expandedRatingResult.createdDate) &&
        Objects.equals(this.updatedByID, expandedRatingResult.updatedByID) &&
        Objects.equals(this.updatedDate, expandedRatingResult.updatedDate) &&
        Objects.equals(this.invoiceItemId, expandedRatingResult.invoiceItemId) &&
        Objects.equals(this.actualPeriodStartDate, expandedRatingResult.actualPeriodStartDate) &&
        Objects.equals(this.actualPeriodEndDate, expandedRatingResult.actualPeriodEndDate) &&
        Objects.equals(this.billingCycleDay, expandedRatingResult.billingCycleDay) &&
        Objects.equals(this.account, expandedRatingResult.account) &&
        Objects.equals(this.ratePlanCharge, expandedRatingResult.ratePlanCharge) &&
        Objects.equals(this.subscription, expandedRatingResult.subscription) &&
        Objects.equals(this.invoiceItem, expandedRatingResult.invoiceItem)&&
        Objects.equals(this.additionalProperties, expandedRatingResult.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(id, accountId, subscriptionId, ratePlanChargeId, quantity, amount, serviceStartDate, serviceEndDate, status, isPartial, chargeSegmentNumber, createdByID, createdDate, updatedByID, updatedDate, invoiceItemId, actualPeriodStartDate, actualPeriodEndDate, billingCycleDay, account, ratePlanCharge, subscription, invoiceItem, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ExpandedRatingResult {\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    accountId: ").append(toIndentedString(accountId)).append("\n");
    sb.append("    subscriptionId: ").append(toIndentedString(subscriptionId)).append("\n");
    sb.append("    ratePlanChargeId: ").append(toIndentedString(ratePlanChargeId)).append("\n");
    sb.append("    quantity: ").append(toIndentedString(quantity)).append("\n");
    sb.append("    amount: ").append(toIndentedString(amount)).append("\n");
    sb.append("    serviceStartDate: ").append(toIndentedString(serviceStartDate)).append("\n");
    sb.append("    serviceEndDate: ").append(toIndentedString(serviceEndDate)).append("\n");
    sb.append("    status: ").append(toIndentedString(status)).append("\n");
    sb.append("    isPartial: ").append(toIndentedString(isPartial)).append("\n");
    sb.append("    chargeSegmentNumber: ").append(toIndentedString(chargeSegmentNumber)).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("    invoiceItemId: ").append(toIndentedString(invoiceItemId)).append("\n");
    sb.append("    actualPeriodStartDate: ").append(toIndentedString(actualPeriodStartDate)).append("\n");
    sb.append("    actualPeriodEndDate: ").append(toIndentedString(actualPeriodEndDate)).append("\n");
    sb.append("    billingCycleDay: ").append(toIndentedString(billingCycleDay)).append("\n");
    sb.append("    account: ").append(toIndentedString(account)).append("\n");
    sb.append("    ratePlanCharge: ").append(toIndentedString(ratePlanCharge)).append("\n");
    sb.append("    subscription: ").append(toIndentedString(subscription)).append("\n");
    sb.append("    invoiceItem: ").append(toIndentedString(invoiceItem)).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("accountId");
    openapiFields.add("subscriptionId");
    openapiFields.add("ratePlanChargeId");
    openapiFields.add("quantity");
    openapiFields.add("amount");
    openapiFields.add("serviceStartDate");
    openapiFields.add("serviceEndDate");
    openapiFields.add("status");
    openapiFields.add("isPartial");
    openapiFields.add("chargeSegmentNumber");
    openapiFields.add("createdByID");
    openapiFields.add("createdDate");
    openapiFields.add("updatedByID");
    openapiFields.add("updatedDate");
    openapiFields.add("invoiceItemId");
    openapiFields.add("actualPeriodStartDate");
    openapiFields.add("actualPeriodEndDate");
    openapiFields.add("billingCycleDay");
    openapiFields.add("account");
    openapiFields.add("ratePlanCharge");
    openapiFields.add("subscription");
    openapiFields.add("invoiceItem");

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

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

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

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy