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

com.zuora.model.SubscriptionChangeLog 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.ChangeLogField;
import com.zuora.model.RatePlanChangeLog;
import java.io.IOException;
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;

/**
 * Represents the order information that will be returned in the GET call.
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class SubscriptionChangeLog {
  public static final String SERIALIZED_NAME_SUBSCRIPTION_NUMBER = "subscriptionNumber";
  @SerializedName(SERIALIZED_NAME_SUBSCRIPTION_NUMBER)
  private String subscriptionNumber;

  public static final String SERIALIZED_NAME_ACCOUNT_NUMBER = "accountNumber";
  @SerializedName(SERIALIZED_NAME_ACCOUNT_NUMBER)
  private String accountNumber;

  public static final String SERIALIZED_NAME_INVOICE_OWNER_ACCOUNT_NUMBER = "invoiceOwnerAccountNumber";
  @SerializedName(SERIALIZED_NAME_INVOICE_OWNER_ACCOUNT_NUMBER)
  private String invoiceOwnerAccountNumber;

  public static final String SERIALIZED_NAME_CURRENCY = "currency";
  @SerializedName(SERIALIZED_NAME_CURRENCY)
  private String currency;

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

  public static final String SERIALIZED_NAME_VERSION = "version";
  @SerializedName(SERIALIZED_NAME_VERSION)
  private String version;

  public static final String SERIALIZED_NAME_CHANGED_TIME = "changedTime";
  @SerializedName(SERIALIZED_NAME_CHANGED_TIME)
  private String changedTime;

  public static final String SERIALIZED_NAME_TYPE = "type";
  @SerializedName(SERIALIZED_NAME_TYPE)
  private String type;

  public static final String SERIALIZED_NAME_EXTERNAL_SUBSCRIPTION_ID = "externalSubscriptionId";
  @SerializedName(SERIALIZED_NAME_EXTERNAL_SUBSCRIPTION_ID)
  private String externalSubscriptionId;

  public static final String SERIALIZED_NAME_SUBSCRIPTION_START_DATE = "subscriptionStartDate";
  @SerializedName(SERIALIZED_NAME_SUBSCRIPTION_START_DATE)
  private String subscriptionStartDate;

  public static final String SERIALIZED_NAME_SUBSCRIPTION_END_DATE = "subscriptionEndDate";
  @SerializedName(SERIALIZED_NAME_SUBSCRIPTION_END_DATE)
  private String subscriptionEndDate;

  public static final String SERIALIZED_NAME_TERM_START_DATE = "termStartDate";
  @SerializedName(SERIALIZED_NAME_TERM_START_DATE)
  private String termStartDate;

  public static final String SERIALIZED_NAME_TERM_END_DATE = "termEndDate";
  @SerializedName(SERIALIZED_NAME_TERM_END_DATE)
  private String termEndDate;

  public static final String SERIALIZED_NAME_RATE_PLANS = "ratePlans";
  @SerializedName(SERIALIZED_NAME_RATE_PLANS)
  private List ratePlans;

  public static final String SERIALIZED_NAME_FIELDS = "fields";
  @SerializedName(SERIALIZED_NAME_FIELDS)
  private List fields;

  public SubscriptionChangeLog() {
  }

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

  /**
   * Subscription number.
   * @return subscriptionNumber
   */
  @javax.annotation.Nullable
  public String getSubscriptionNumber() {
    return subscriptionNumber;
  }

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


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

  /**
   * Account number.
   * @return accountNumber
   */
  @javax.annotation.Nullable
  public String getAccountNumber() {
    return accountNumber;
  }

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


  public SubscriptionChangeLog invoiceOwnerAccountNumber(String invoiceOwnerAccountNumber) {
    this.invoiceOwnerAccountNumber = invoiceOwnerAccountNumber;
    return this;
  }

  /**
   * Invoice owner account number of the subscription.
   * @return invoiceOwnerAccountNumber
   */
  @javax.annotation.Nullable
  public String getInvoiceOwnerAccountNumber() {
    return invoiceOwnerAccountNumber;
  }

  public void setInvoiceOwnerAccountNumber(String invoiceOwnerAccountNumber) {
    this.invoiceOwnerAccountNumber = invoiceOwnerAccountNumber;
  }


  public SubscriptionChangeLog currency(String currency) {
    this.currency = currency;
    return this;
  }

  /**
   * The currency of the subscription.
   * @return currency
   */
  @javax.annotation.Nullable
  public String getCurrency() {
    return currency;
  }

  public void setCurrency(String currency) {
    this.currency = currency;
  }


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

  /**
   * The order number of the order which created this subscription.
   * @return orderNumber
   */
  @javax.annotation.Nullable
  public String getOrderNumber() {
    return orderNumber;
  }

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


  public SubscriptionChangeLog version(String version) {
    this.version = version;
    return this;
  }

  /**
   * The version of the subscription.
   * @return version
   */
  @javax.annotation.Nullable
  public String getVersion() {
    return version;
  }

  public void setVersion(String version) {
    this.version = version;
  }


  public SubscriptionChangeLog changedTime(String changedTime) {
    this.changedTime = changedTime;
    return this;
  }

  /**
   * The create time of the subscription.
   * @return changedTime
   */
  @javax.annotation.Nullable
  public String getChangedTime() {
    return changedTime;
  }

  public void setChangedTime(String changedTime) {
    this.changedTime = changedTime;
  }


  public SubscriptionChangeLog type(String type) {
    this.type = type;
    return this;
  }

  /**
   * The type of the subscription.
   * @return type
   */
  @javax.annotation.Nullable
  public String getType() {
    return type;
  }

  public void setType(String type) {
    this.type = type;
  }


  public SubscriptionChangeLog externalSubscriptionId(String externalSubscriptionId) {
    this.externalSubscriptionId = externalSubscriptionId;
    return this;
  }

  /**
   * External subscription id.
   * @return externalSubscriptionId
   */
  @javax.annotation.Nullable
  public String getExternalSubscriptionId() {
    return externalSubscriptionId;
  }

  public void setExternalSubscriptionId(String externalSubscriptionId) {
    this.externalSubscriptionId = externalSubscriptionId;
  }


  public SubscriptionChangeLog subscriptionStartDate(String subscriptionStartDate) {
    this.subscriptionStartDate = subscriptionStartDate;
    return this;
  }

  /**
   * Start date of the subscription.
   * @return subscriptionStartDate
   */
  @javax.annotation.Nullable
  public String getSubscriptionStartDate() {
    return subscriptionStartDate;
  }

  public void setSubscriptionStartDate(String subscriptionStartDate) {
    this.subscriptionStartDate = subscriptionStartDate;
  }


  public SubscriptionChangeLog subscriptionEndDate(String subscriptionEndDate) {
    this.subscriptionEndDate = subscriptionEndDate;
    return this;
  }

  /**
   * End date of the subscription.
   * @return subscriptionEndDate
   */
  @javax.annotation.Nullable
  public String getSubscriptionEndDate() {
    return subscriptionEndDate;
  }

  public void setSubscriptionEndDate(String subscriptionEndDate) {
    this.subscriptionEndDate = subscriptionEndDate;
  }


  public SubscriptionChangeLog termStartDate(String termStartDate) {
    this.termStartDate = termStartDate;
    return this;
  }

  /**
   * Term start date of the subscription.
   * @return termStartDate
   */
  @javax.annotation.Nullable
  public String getTermStartDate() {
    return termStartDate;
  }

  public void setTermStartDate(String termStartDate) {
    this.termStartDate = termStartDate;
  }


  public SubscriptionChangeLog termEndDate(String termEndDate) {
    this.termEndDate = termEndDate;
    return this;
  }

  /**
   * Term end date of the subscription.
   * @return termEndDate
   */
  @javax.annotation.Nullable
  public String getTermEndDate() {
    return termEndDate;
  }

  public void setTermEndDate(String termEndDate) {
    this.termEndDate = termEndDate;
  }


  public SubscriptionChangeLog ratePlans(List ratePlans) {
    this.ratePlans = ratePlans;
    return this;
  }

  public SubscriptionChangeLog addRatePlansItem(RatePlanChangeLog ratePlansItem) {
    if (this.ratePlans == null) {
      this.ratePlans = new ArrayList<>();
    }
    this.ratePlans.add(ratePlansItem);
    return this;
  }

  /**
   * Represents the rate plans in this subscription.
   * @return ratePlans
   */
  @javax.annotation.Nullable
  public List getRatePlans() {
    return ratePlans;
  }

  public void setRatePlans(List ratePlans) {
    this.ratePlans = ratePlans;
  }


  public SubscriptionChangeLog fields(List fields) {
    this.fields = fields;
    return this;
  }

  public SubscriptionChangeLog addFieldsItem(ChangeLogField fieldsItem) {
    if (this.fields == null) {
      this.fields = new ArrayList<>();
    }
    this.fields.add(fieldsItem);
    return this;
  }

  /**
   * Represents the fields which the value is changed for this charge.
   * @return fields
   */
  @javax.annotation.Nullable
  public List getFields() {
    return fields;
  }

  public void setFields(List fields) {
    this.fields = fields;
  }

  /**
   * 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 SubscriptionChangeLog instance itself
   */
  public SubscriptionChangeLog 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;
    }
    SubscriptionChangeLog subscriptionChangeLog = (SubscriptionChangeLog) o;
    return Objects.equals(this.subscriptionNumber, subscriptionChangeLog.subscriptionNumber) &&
        Objects.equals(this.accountNumber, subscriptionChangeLog.accountNumber) &&
        Objects.equals(this.invoiceOwnerAccountNumber, subscriptionChangeLog.invoiceOwnerAccountNumber) &&
        Objects.equals(this.currency, subscriptionChangeLog.currency) &&
        Objects.equals(this.orderNumber, subscriptionChangeLog.orderNumber) &&
        Objects.equals(this.version, subscriptionChangeLog.version) &&
        Objects.equals(this.changedTime, subscriptionChangeLog.changedTime) &&
        Objects.equals(this.type, subscriptionChangeLog.type) &&
        Objects.equals(this.externalSubscriptionId, subscriptionChangeLog.externalSubscriptionId) &&
        Objects.equals(this.subscriptionStartDate, subscriptionChangeLog.subscriptionStartDate) &&
        Objects.equals(this.subscriptionEndDate, subscriptionChangeLog.subscriptionEndDate) &&
        Objects.equals(this.termStartDate, subscriptionChangeLog.termStartDate) &&
        Objects.equals(this.termEndDate, subscriptionChangeLog.termEndDate) &&
        Objects.equals(this.ratePlans, subscriptionChangeLog.ratePlans) &&
        Objects.equals(this.fields, subscriptionChangeLog.fields)&&
        Objects.equals(this.additionalProperties, subscriptionChangeLog.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(subscriptionNumber, accountNumber, invoiceOwnerAccountNumber, currency, orderNumber, version, changedTime, type, externalSubscriptionId, subscriptionStartDate, subscriptionEndDate, termStartDate, termEndDate, ratePlans, fields, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class SubscriptionChangeLog {\n");
    sb.append("    subscriptionNumber: ").append(toIndentedString(subscriptionNumber)).append("\n");
    sb.append("    accountNumber: ").append(toIndentedString(accountNumber)).append("\n");
    sb.append("    invoiceOwnerAccountNumber: ").append(toIndentedString(invoiceOwnerAccountNumber)).append("\n");
    sb.append("    currency: ").append(toIndentedString(currency)).append("\n");
    sb.append("    orderNumber: ").append(toIndentedString(orderNumber)).append("\n");
    sb.append("    version: ").append(toIndentedString(version)).append("\n");
    sb.append("    changedTime: ").append(toIndentedString(changedTime)).append("\n");
    sb.append("    type: ").append(toIndentedString(type)).append("\n");
    sb.append("    externalSubscriptionId: ").append(toIndentedString(externalSubscriptionId)).append("\n");
    sb.append("    subscriptionStartDate: ").append(toIndentedString(subscriptionStartDate)).append("\n");
    sb.append("    subscriptionEndDate: ").append(toIndentedString(subscriptionEndDate)).append("\n");
    sb.append("    termStartDate: ").append(toIndentedString(termStartDate)).append("\n");
    sb.append("    termEndDate: ").append(toIndentedString(termEndDate)).append("\n");
    sb.append("    ratePlans: ").append(toIndentedString(ratePlans)).append("\n");
    sb.append("    fields: ").append(toIndentedString(fields)).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("subscriptionNumber");
    openapiFields.add("accountNumber");
    openapiFields.add("invoiceOwnerAccountNumber");
    openapiFields.add("currency");
    openapiFields.add("orderNumber");
    openapiFields.add("version");
    openapiFields.add("changedTime");
    openapiFields.add("type");
    openapiFields.add("externalSubscriptionId");
    openapiFields.add("subscriptionStartDate");
    openapiFields.add("subscriptionEndDate");
    openapiFields.add("termStartDate");
    openapiFields.add("termEndDate");
    openapiFields.add("ratePlans");
    openapiFields.add("fields");

    // 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 SubscriptionChangeLog
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!SubscriptionChangeLog.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in SubscriptionChangeLog is not found in the empty JSON string", SubscriptionChangeLog.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      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("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("invoiceOwnerAccountNumber") != null && !jsonObj.get("invoiceOwnerAccountNumber").isJsonNull()) && !jsonObj.get("invoiceOwnerAccountNumber").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `invoiceOwnerAccountNumber` to be a primitive type in the JSON string but got `%s`", jsonObj.get("invoiceOwnerAccountNumber").toString()));
      }
      if ((jsonObj.get("currency") != null && !jsonObj.get("currency").isJsonNull()) && !jsonObj.get("currency").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `currency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("currency").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("version") != null && !jsonObj.get("version").isJsonNull()) && !jsonObj.get("version").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString()));
      }
      if ((jsonObj.get("changedTime") != null && !jsonObj.get("changedTime").isJsonNull()) && !jsonObj.get("changedTime").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `changedTime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("changedTime").toString()));
      }
      if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString()));
      }
      if ((jsonObj.get("externalSubscriptionId") != null && !jsonObj.get("externalSubscriptionId").isJsonNull()) && !jsonObj.get("externalSubscriptionId").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `externalSubscriptionId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("externalSubscriptionId").toString()));
      }
      if ((jsonObj.get("subscriptionStartDate") != null && !jsonObj.get("subscriptionStartDate").isJsonNull()) && !jsonObj.get("subscriptionStartDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `subscriptionStartDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subscriptionStartDate").toString()));
      }
      if ((jsonObj.get("subscriptionEndDate") != null && !jsonObj.get("subscriptionEndDate").isJsonNull()) && !jsonObj.get("subscriptionEndDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `subscriptionEndDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("subscriptionEndDate").toString()));
      }
      if ((jsonObj.get("termStartDate") != null && !jsonObj.get("termStartDate").isJsonNull()) && !jsonObj.get("termStartDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `termStartDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("termStartDate").toString()));
      }
      if ((jsonObj.get("termEndDate") != null && !jsonObj.get("termEndDate").isJsonNull()) && !jsonObj.get("termEndDate").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `termEndDate` to be a primitive type in the JSON string but got `%s`", jsonObj.get("termEndDate").toString()));
      }
      if (jsonObj.get("ratePlans") != null && !jsonObj.get("ratePlans").isJsonNull()) {
        JsonArray jsonArrayratePlans = jsonObj.getAsJsonArray("ratePlans");
        if (jsonArrayratePlans != null) {
          // ensure the json data is an array
          if (!jsonObj.get("ratePlans").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `ratePlans` to be an array in the JSON string but got `%s`", jsonObj.get("ratePlans").toString()));
          }

          // validate the optional field `ratePlans` (array)
          for (int i = 0; i < jsonArrayratePlans.size(); i++) {
            RatePlanChangeLog.validateJsonElement(jsonArrayratePlans.get(i));
          };
        }
      }
      if (jsonObj.get("fields") != null && !jsonObj.get("fields").isJsonNull()) {
        JsonArray jsonArrayfields = jsonObj.getAsJsonArray("fields");
        if (jsonArrayfields != null) {
          // ensure the json data is an array
          if (!jsonObj.get("fields").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `fields` to be an array in the JSON string but got `%s`", jsonObj.get("fields").toString()));
          }

          // validate the optional field `fields` (array)
          for (int i = 0; i < jsonArrayfields.size(); i++) {
            ChangeLogField.validateJsonElement(jsonArrayfields.get(i));
          };
        }
      }
  }

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

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

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy