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

com.zuora.model.GetUsageResponse 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.time.OffsetDateTime;
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;

/**
 * GetUsageResponse
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class GetUsageResponse {
  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_ACCOUNT_NUMBER = "AccountNumber";
  @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER)
  private String accountNumber;

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

  public static final String SERIALIZED_NAME_SUBSCRIPTION_NUMBER = "SubscriptionNumber";
  @SerializedName(SERIALIZED_NAME_SUBSCRIPTION_NUMBER)
  private String subscriptionNumber;

  public static final String SERIALIZED_NAME_CHARGE_ID = "ChargeId";
  @SerializedName(SERIALIZED_NAME_CHARGE_ID)
  private String chargeId;

  public static final String SERIALIZED_NAME_CHARGE_NUMBER = "ChargeNumber";
  @SerializedName(SERIALIZED_NAME_CHARGE_NUMBER)
  private String chargeNumber;

  public static final String SERIALIZED_NAME_START_DATE_TIME = "StartDateTime";
  @SerializedName(SERIALIZED_NAME_START_DATE_TIME)
  private OffsetDateTime startDateTime;

  public static final String SERIALIZED_NAME_END_DATE_TIME = "EndDateTime";
  @SerializedName(SERIALIZED_NAME_END_DATE_TIME)
  private OffsetDateTime endDateTime;

  public static final String SERIALIZED_NAME_U_O_M = "UOM";
  @SerializedName(SERIALIZED_NAME_U_O_M)
  private String UOM;

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

  public static final String SERIALIZED_NAME_SOURCE_TYPE = "SourceType";
  @SerializedName(SERIALIZED_NAME_SOURCE_TYPE)
  private String sourceType;

  public static final String SERIALIZED_NAME_RBE_STATUS = "RbeStatus";
  @SerializedName(SERIALIZED_NAME_RBE_STATUS)
  private String rbeStatus;

  public static final String SERIALIZED_NAME_DESCRIPTION = "Description";
  @SerializedName(SERIALIZED_NAME_DESCRIPTION)
  private String description;

  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 OffsetDateTime 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 OffsetDateTime updatedDate;

  public static final String SERIALIZED_NAME_SUBMISSION_DATE_TIME = "SubmissionDateTime";
  @SerializedName(SERIALIZED_NAME_SUBMISSION_DATE_TIME)
  private OffsetDateTime submissionDateTime;

  public GetUsageResponse() {
  }

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

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

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


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

  /**
   *  The ID of the account associated with the usage data. This field is required if no value is specified for the `AccountNumber` field. **Character limit**: 32 **Values**: a valid account ID
   * @return accountId
   */
  @javax.annotation.Nullable
  public String getAccountId() {
    return accountId;
  }

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


  public GetUsageResponse accountNumber(String accountNumber) {
    this.accountNumber = accountNumber;
    return this;
  }

  /**
   *  The number of the account associated with the usage data. This field is required if no value is specified for the `AccountId` field. **Character limit**: 50 **Values**: a valid account number
   * @return accountNumber
   */
  @javax.annotation.Nullable
  public String getAccountNumber() {
    return accountNumber;
  }

  public void setAccountNumber(String accountNumber) {
    this.accountNumber = accountNumber;
  }


  public GetUsageResponse subscriptionId(String subscriptionId) {
    this.subscriptionId = subscriptionId;
    return this;
  }

  /**
   *  The original ID of the subscription that contains the fees related to the usage data. **Character limit**: 32 **Values**: a valid subscription ID
   * @return subscriptionId
   */
  @javax.annotation.Nullable
  public String getSubscriptionId() {
    return subscriptionId;
  }

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


  public GetUsageResponse subscriptionNumber(String subscriptionNumber) {
    this.subscriptionNumber = subscriptionNumber;
    return this;
  }

  /**
   * The unique identifier number of the subscription that contains the fees related to the usage data. 
   * @return subscriptionNumber
   */
  @javax.annotation.Nullable
  public String getSubscriptionNumber() {
    return subscriptionNumber;
  }

  public void setSubscriptionNumber(String subscriptionNumber) {
    this.subscriptionNumber = subscriptionNumber;
  }


  public GetUsageResponse chargeId(String chargeId) {
    this.chargeId = chargeId;
    return this;
  }

  /**
   *  The OrginalId of the rate plan charge related to the usage record, e.g., `2c9081a03c63c94c013c6873357a0117` **Character limit**: 32 **Values**: a valid rate plan charge OriginalID 
   * @return chargeId
   */
  @javax.annotation.Nullable
  public String getChargeId() {
    return chargeId;
  }

  public void setChargeId(String chargeId) {
    this.chargeId = chargeId;
  }


  public GetUsageResponse chargeNumber(String chargeNumber) {
    this.chargeNumber = chargeNumber;
    return this;
  }

  /**
   * Number of the rate-plan charge that pays for this usage. 
   * @return chargeNumber
   */
  @javax.annotation.Nullable
  public String getChargeNumber() {
    return chargeNumber;
  }

  public void setChargeNumber(String chargeNumber) {
    this.chargeNumber = chargeNumber;
  }


  public GetUsageResponse startDateTime(OffsetDateTime startDateTime) {
    this.startDateTime = startDateTime;
    return this;
  }

  /**
   *  The start date and time of a range of time when usage is tracked. Zuora uses this field value to determine the usage date. Unlike the `EndDateTime`, the `StartDateTime` field does affect usage calculation. **Character limit**: 29 **Values**: a valid date and time value
   * @return startDateTime
   */
  @javax.annotation.Nullable
  public OffsetDateTime getStartDateTime() {
    return startDateTime;
  }

  public void setStartDateTime(OffsetDateTime startDateTime) {
    this.startDateTime = startDateTime;
  }


  public GetUsageResponse endDateTime(OffsetDateTime endDateTime) {
    this.endDateTime = endDateTime;
    return this;
  }

  /**
   *  The end date and time of a range of time when usage is tracked. Use this field for reporting; this field doesn't affect usage calculation. **Character limit**: 29 **Values**: a valid date and time value
   * @return endDateTime
   */
  @javax.annotation.Nullable
  public OffsetDateTime getEndDateTime() {
    return endDateTime;
  }

  public void setEndDateTime(OffsetDateTime endDateTime) {
    this.endDateTime = endDateTime;
  }


  public GetUsageResponse UOM(String UOM) {
    this.UOM = UOM;
    return this;
  }

  /**
   *  Specifies the units to measure usage. Units of measure are configured in the web-based UI. Your values depend on your configuration in **Billing Settings**. **Character limit**: **Values**: a valid unit of measure
   * @return UOM
   */
  @javax.annotation.Nullable
  public String getUOM() {
    return UOM;
  }

  public void setUOM(String UOM) {
    this.UOM = UOM;
  }


  public GetUsageResponse quantity(Double quantity) {
    this.quantity = quantity;
    return this;
  }

  /**
   *  Indicates the number of units used. **Character limit**: 16 **Values**: a valid decimal amount equal to or greater than 0
   * @return quantity
   */
  @javax.annotation.Nullable
  public Double getQuantity() {
    return quantity;
  }

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


  public GetUsageResponse sourceType(String sourceType) {
    this.sourceType = sourceType;
    return this;
  }

  /**
   *  Indicates if the usage records were imported from the web-based UI or the API. **Character limit**: 6 **Values**: automatically generated to be one of the following values: `API`, `Import`
   * @return sourceType
   */
  @javax.annotation.Nullable
  public String getSourceType() {
    return sourceType;
  }

  public void setSourceType(String sourceType) {
    this.sourceType = sourceType;
  }


  public GetUsageResponse rbeStatus(String rbeStatus) {
    this.rbeStatus = rbeStatus;
    return this;
  }

  /**
   *  Indicates if the rating and billing engine (RBE) processed usage data for an invoice. **Character limit**: 9 **Values**: automatically generated to be one of the following values: `Importing`, `Pending`, `Processed`
   * @return rbeStatus
   */
  @javax.annotation.Nullable
  public String getRbeStatus() {
    return rbeStatus;
  }

  public void setRbeStatus(String rbeStatus) {
    this.rbeStatus = rbeStatus;
  }


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

  /**
   * A description of the usage record. 
   * @return description
   */
  @javax.annotation.Nullable
  public String getDescription() {
    return description;
  }

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


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

  /**
   *  The user ID of the person who uploaded the usage records. **Character limit**: 32 **Values**: automatically generated
   * @return createdById
   */
  @javax.annotation.Nullable
  public String getCreatedById() {
    return createdById;
  }

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


  public GetUsageResponse createdDate(OffsetDateTime createdDate) {
    this.createdDate = createdDate;
    return this;
  }

  /**
   *  The date when the usage was generated. **Character limit**: 29 **Values**: automatically generated
   * @return createdDate
   */
  @javax.annotation.Nullable
  public OffsetDateTime getCreatedDate() {
    return createdDate;
  }

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


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

  /**
   *  The ID of the user who last updated the usage upload. **Character limit**: 32 **Values**: automatically generated
   * @return updatedById
   */
  @javax.annotation.Nullable
  public String getUpdatedById() {
    return updatedById;
  }

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


  public GetUsageResponse updatedDate(OffsetDateTime updatedDate) {
    this.updatedDate = updatedDate;
    return this;
  }

  /**
   *  The date when the usage upload was last updated. **Character limit**: 29 **Values**: automatically generated
   * @return updatedDate
   */
  @javax.annotation.Nullable
  public OffsetDateTime getUpdatedDate() {
    return updatedDate;
  }

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


  public GetUsageResponse submissionDateTime(OffsetDateTime submissionDateTime) {
    this.submissionDateTime = submissionDateTime;
    return this;
  }

  /**
   * Date when usage was submitted. 
   * @return submissionDateTime
   */
  @javax.annotation.Nullable
  public OffsetDateTime getSubmissionDateTime() {
    return submissionDateTime;
  }

  public void setSubmissionDateTime(OffsetDateTime submissionDateTime) {
    this.submissionDateTime = submissionDateTime;
  }

  /**
   * 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 GetUsageResponse instance itself
   */
  public GetUsageResponse 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;
    }
    GetUsageResponse getUsageResponse = (GetUsageResponse) o;
    return Objects.equals(this.id, getUsageResponse.id) &&
        Objects.equals(this.accountId, getUsageResponse.accountId) &&
        Objects.equals(this.accountNumber, getUsageResponse.accountNumber) &&
        Objects.equals(this.subscriptionId, getUsageResponse.subscriptionId) &&
        Objects.equals(this.subscriptionNumber, getUsageResponse.subscriptionNumber) &&
        Objects.equals(this.chargeId, getUsageResponse.chargeId) &&
        Objects.equals(this.chargeNumber, getUsageResponse.chargeNumber) &&
        Objects.equals(this.startDateTime, getUsageResponse.startDateTime) &&
        Objects.equals(this.endDateTime, getUsageResponse.endDateTime) &&
        Objects.equals(this.UOM, getUsageResponse.UOM) &&
        Objects.equals(this.quantity, getUsageResponse.quantity) &&
        Objects.equals(this.sourceType, getUsageResponse.sourceType) &&
        Objects.equals(this.rbeStatus, getUsageResponse.rbeStatus) &&
        Objects.equals(this.description, getUsageResponse.description) &&
        Objects.equals(this.createdById, getUsageResponse.createdById) &&
        Objects.equals(this.createdDate, getUsageResponse.createdDate) &&
        Objects.equals(this.updatedById, getUsageResponse.updatedById) &&
        Objects.equals(this.updatedDate, getUsageResponse.updatedDate) &&
        Objects.equals(this.submissionDateTime, getUsageResponse.submissionDateTime)&&
        Objects.equals(this.additionalProperties, getUsageResponse.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(id, accountId, accountNumber, subscriptionId, subscriptionNumber, chargeId, chargeNumber, startDateTime, endDateTime, UOM, quantity, sourceType, rbeStatus, description, createdById, createdDate, updatedById, updatedDate, submissionDateTime, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class GetUsageResponse {\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    accountId: ").append(toIndentedString(accountId)).append("\n");
    sb.append("    accountNumber: ").append(toIndentedString(accountNumber)).append("\n");
    sb.append("    subscriptionId: ").append(toIndentedString(subscriptionId)).append("\n");
    sb.append("    subscriptionNumber: ").append(toIndentedString(subscriptionNumber)).append("\n");
    sb.append("    chargeId: ").append(toIndentedString(chargeId)).append("\n");
    sb.append("    chargeNumber: ").append(toIndentedString(chargeNumber)).append("\n");
    sb.append("    startDateTime: ").append(toIndentedString(startDateTime)).append("\n");
    sb.append("    endDateTime: ").append(toIndentedString(endDateTime)).append("\n");
    sb.append("    UOM: ").append(toIndentedString(UOM)).append("\n");
    sb.append("    quantity: ").append(toIndentedString(quantity)).append("\n");
    sb.append("    sourceType: ").append(toIndentedString(sourceType)).append("\n");
    sb.append("    rbeStatus: ").append(toIndentedString(rbeStatus)).append("\n");
    sb.append("    description: ").append(toIndentedString(description)).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("    submissionDateTime: ").append(toIndentedString(submissionDateTime)).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("AccountNumber");
    openapiFields.add("SubscriptionId");
    openapiFields.add("SubscriptionNumber");
    openapiFields.add("ChargeId");
    openapiFields.add("ChargeNumber");
    openapiFields.add("StartDateTime");
    openapiFields.add("EndDateTime");
    openapiFields.add("UOM");
    openapiFields.add("Quantity");
    openapiFields.add("SourceType");
    openapiFields.add("RbeStatus");
    openapiFields.add("Description");
    openapiFields.add("CreatedById");
    openapiFields.add("CreatedDate");
    openapiFields.add("UpdatedById");
    openapiFields.add("UpdatedDate");
    openapiFields.add("SubmissionDateTime");

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

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

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

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy