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

com.zuora.model.GetJournalEntryDetailResponse 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.GetJournalEntryItemResponse;
import com.zuora.model.GetJournalEntrySegmentResponse;
import com.zuora.model.JournalEntryStatus;
import com.zuora.model.TransferredToAccountingStatus;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonArray;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParseException;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.TypeAdapter;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.zuora.JSON;

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

  public static final String SERIALIZED_NAME_AGGREGATE_CURRENCY = "aggregateCurrency";
  @SerializedName(SERIALIZED_NAME_AGGREGATE_CURRENCY)
  private Boolean aggregateCurrency;

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

  public static final String SERIALIZED_NAME_HOME_CURRENCY = "homeCurrency";
  @SerializedName(SERIALIZED_NAME_HOME_CURRENCY)
  private String homeCurrency;

  public static final String SERIALIZED_NAME_JOURNAL_ENTRY_DATE = "journalEntryDate";
  @SerializedName(SERIALIZED_NAME_JOURNAL_ENTRY_DATE)
  private LocalDate journalEntryDate;

  public static final String SERIALIZED_NAME_JOURNAL_ENTRY_ITEMS = "journalEntryItems";
  @SerializedName(SERIALIZED_NAME_JOURNAL_ENTRY_ITEMS)
  private List journalEntryItems;

  public static final String SERIALIZED_NAME_NOTES = "notes";
  @SerializedName(SERIALIZED_NAME_NOTES)
  private String notes;

  public static final String SERIALIZED_NAME_NUMBER = "number";
  @SerializedName(SERIALIZED_NAME_NUMBER)
  private String number;

  public static final String SERIALIZED_NAME_ORGANIZATION_LABEL = "organizationLabel";
  @SerializedName(SERIALIZED_NAME_ORGANIZATION_LABEL)
  private String organizationLabel;

  public static final String SERIALIZED_NAME_SEGMENTS = "segments";
  @SerializedName(SERIALIZED_NAME_SEGMENTS)
  private List segments;

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

  public static final String SERIALIZED_NAME_SUCCESS = "success";
  @SerializedName(SERIALIZED_NAME_SUCCESS)
  private Boolean success;

  public static final String SERIALIZED_NAME_TIME_PERIOD_END = "timePeriodEnd";
  @SerializedName(SERIALIZED_NAME_TIME_PERIOD_END)
  private LocalDate timePeriodEnd;

  public static final String SERIALIZED_NAME_TIME_PERIOD_START = "timePeriodStart";
  @SerializedName(SERIALIZED_NAME_TIME_PERIOD_START)
  private LocalDate timePeriodStart;

  public static final String SERIALIZED_NAME_TRANSACTION_TYPE = "transactionType";
  @SerializedName(SERIALIZED_NAME_TRANSACTION_TYPE)
  private String transactionType;

  public static final String SERIALIZED_NAME_TRANSFER_DATE_TIME = "transferDateTime";
  @SerializedName(SERIALIZED_NAME_TRANSFER_DATE_TIME)
  private String transferDateTime;

  public static final String SERIALIZED_NAME_TRANSFERRED_BY = "transferredBy";
  @SerializedName(SERIALIZED_NAME_TRANSFERRED_BY)
  private String transferredBy;

  public static final String SERIALIZED_NAME_TRANSFERRED_TO_ACCOUNTING = "transferredToAccounting";
  @SerializedName(SERIALIZED_NAME_TRANSFERRED_TO_ACCOUNTING)
  private TransferredToAccountingStatus transferredToAccounting;

  public GetJournalEntryDetailResponse() {
  }

  public GetJournalEntryDetailResponse accountingPeriodName(String accountingPeriodName) {
    this.accountingPeriodName = accountingPeriodName;
    return this;
  }

  /**
   * Name of the accounting period that the journal entry belongs to. 
   * @return accountingPeriodName
   */
  @javax.annotation.Nullable
  public String getAccountingPeriodName() {
    return accountingPeriodName;
  }

  public void setAccountingPeriodName(String accountingPeriodName) {
    this.accountingPeriodName = accountingPeriodName;
  }


  public GetJournalEntryDetailResponse aggregateCurrency(Boolean aggregateCurrency) {
    this.aggregateCurrency = aggregateCurrency;
    return this;
  }

  /**
   * Returns true if the journal entry is aggregating currencies. That is, if the journal entry was created when the `Aggregate transactions with different currencies during a Journal Run` setting was configured to `Yes`. Otherwise, returns `false`. 
   * @return aggregateCurrency
   */
  @javax.annotation.Nullable
  public Boolean getAggregateCurrency() {
    return aggregateCurrency;
  }

  public void setAggregateCurrency(Boolean aggregateCurrency) {
    this.aggregateCurrency = aggregateCurrency;
  }


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

  /**
   * Currency used. 
   * @return currency
   */
  @javax.annotation.Nullable
  public String getCurrency() {
    return currency;
  }

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


  public GetJournalEntryDetailResponse homeCurrency(String homeCurrency) {
    this.homeCurrency = homeCurrency;
    return this;
  }

  /**
   * Home currency used. 
   * @return homeCurrency
   */
  @javax.annotation.Nullable
  public String getHomeCurrency() {
    return homeCurrency;
  }

  public void setHomeCurrency(String homeCurrency) {
    this.homeCurrency = homeCurrency;
  }


  public GetJournalEntryDetailResponse journalEntryDate(LocalDate journalEntryDate) {
    this.journalEntryDate = journalEntryDate;
    return this;
  }

  /**
   * Date of the journal entry. 
   * @return journalEntryDate
   */
  @javax.annotation.Nullable
  public LocalDate getJournalEntryDate() {
    return journalEntryDate;
  }

  public void setJournalEntryDate(LocalDate journalEntryDate) {
    this.journalEntryDate = journalEntryDate;
  }


  public GetJournalEntryDetailResponse journalEntryItems(List journalEntryItems) {
    this.journalEntryItems = journalEntryItems;
    return this;
  }

  public GetJournalEntryDetailResponse addJournalEntryItemsItem(GetJournalEntryItemResponse journalEntryItemsItem) {
    if (this.journalEntryItems == null) {
      this.journalEntryItems = new ArrayList<>();
    }
    this.journalEntryItems.add(journalEntryItemsItem);
    return this;
  }

  /**
   * Key name that represents the list of journal entry items. 
   * @return journalEntryItems
   */
  @javax.annotation.Nullable
  public List getJournalEntryItems() {
    return journalEntryItems;
  }

  public void setJournalEntryItems(List journalEntryItems) {
    this.journalEntryItems = journalEntryItems;
  }


  public GetJournalEntryDetailResponse notes(String notes) {
    this.notes = notes;
    return this;
  }

  /**
   *  Additional information about this record. Character limit: 2,000 
   * @return notes
   */
  @javax.annotation.Nullable
  public String getNotes() {
    return notes;
  }

  public void setNotes(String notes) {
    this.notes = notes;
  }


  public GetJournalEntryDetailResponse number(String number) {
    this.number = number;
    return this;
  }

  /**
   * Journal entry number in the format JE-00000001. 
   * @return number
   */
  @javax.annotation.Nullable
  public String getNumber() {
    return number;
  }

  public void setNumber(String number) {
    this.number = number;
  }


  public GetJournalEntryDetailResponse organizationLabel(String organizationLabel) {
    this.organizationLabel = organizationLabel;
    return this;
  }

  /**
   * Organization label. 
   * @return organizationLabel
   */
  @javax.annotation.Nullable
  public String getOrganizationLabel() {
    return organizationLabel;
  }

  public void setOrganizationLabel(String organizationLabel) {
    this.organizationLabel = organizationLabel;
  }


  public GetJournalEntryDetailResponse segments(List segments) {
    this.segments = segments;
    return this;
  }

  public GetJournalEntryDetailResponse addSegmentsItem(GetJournalEntrySegmentResponse segmentsItem) {
    if (this.segments == null) {
      this.segments = new ArrayList<>();
    }
    this.segments.add(segmentsItem);
    return this;
  }

  /**
   * List of segments that apply to the summary journal entry. 
   * @return segments
   */
  @javax.annotation.Nullable
  public List getSegments() {
    return segments;
  }

  public void setSegments(List segments) {
    this.segments = segments;
  }


  public GetJournalEntryDetailResponse status(JournalEntryStatus status) {
    this.status = status;
    return this;
  }

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

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


  public GetJournalEntryDetailResponse success(Boolean success) {
    this.success = success;
    return this;
  }

  /**
   * Returns `true` if the request was processed successfully. 
   * @return success
   */
  @javax.annotation.Nullable
  public Boolean getSuccess() {
    return success;
  }

  public void setSuccess(Boolean success) {
    this.success = success;
  }


  public GetJournalEntryDetailResponse timePeriodEnd(LocalDate timePeriodEnd) {
    this.timePeriodEnd = timePeriodEnd;
    return this;
  }

  /**
   * End date of time period included in the journal entry. 
   * @return timePeriodEnd
   */
  @javax.annotation.Nullable
  public LocalDate getTimePeriodEnd() {
    return timePeriodEnd;
  }

  public void setTimePeriodEnd(LocalDate timePeriodEnd) {
    this.timePeriodEnd = timePeriodEnd;
  }


  public GetJournalEntryDetailResponse timePeriodStart(LocalDate timePeriodStart) {
    this.timePeriodStart = timePeriodStart;
    return this;
  }

  /**
   * Start date of time period included in the journal entry. 
   * @return timePeriodStart
   */
  @javax.annotation.Nullable
  public LocalDate getTimePeriodStart() {
    return timePeriodStart;
  }

  public void setTimePeriodStart(LocalDate timePeriodStart) {
    this.timePeriodStart = timePeriodStart;
  }


  public GetJournalEntryDetailResponse transactionType(String transactionType) {
    this.transactionType = transactionType;
    return this;
  }

  /**
   * Transaction type of the transactions included in the summary journal entry. 
   * @return transactionType
   */
  @javax.annotation.Nullable
  public String getTransactionType() {
    return transactionType;
  }

  public void setTransactionType(String transactionType) {
    this.transactionType = transactionType;
  }


  public GetJournalEntryDetailResponse transferDateTime(String transferDateTime) {
    this.transferDateTime = transferDateTime;
    return this;
  }

  /**
   * Date and time that transferredToAccounting was changed to `Yes`. This field is returned only when transferredToAccounting is `Yes`. Otherwise, this field is `null`. 
   * @return transferDateTime
   */
  @javax.annotation.Nullable
  public String getTransferDateTime() {
    return transferDateTime;
  }

  public void setTransferDateTime(String transferDateTime) {
    this.transferDateTime = transferDateTime;
  }


  public GetJournalEntryDetailResponse transferredBy(String transferredBy) {
    this.transferredBy = transferredBy;
    return this;
  }

  /**
   * User ID of the person who changed transferredToAccounting to `Yes`. This field is returned only when transferredToAccounting is `Yes`. Otherwise, this field is `null`. 
   * @return transferredBy
   */
  @javax.annotation.Nullable
  public String getTransferredBy() {
    return transferredBy;
  }

  public void setTransferredBy(String transferredBy) {
    this.transferredBy = transferredBy;
  }


  public GetJournalEntryDetailResponse transferredToAccounting(TransferredToAccountingStatus transferredToAccounting) {
    this.transferredToAccounting = transferredToAccounting;
    return this;
  }

  /**
   * Get transferredToAccounting
   * @return transferredToAccounting
   */
  @javax.annotation.Nullable
  public TransferredToAccountingStatus getTransferredToAccounting() {
    return transferredToAccounting;
  }

  public void setTransferredToAccounting(TransferredToAccountingStatus transferredToAccounting) {
    this.transferredToAccounting = transferredToAccounting;
  }

  /**
   * 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 GetJournalEntryDetailResponse instance itself
   */
  public GetJournalEntryDetailResponse 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;
    }
    GetJournalEntryDetailResponse getJournalEntryDetailResponse = (GetJournalEntryDetailResponse) o;
    return Objects.equals(this.accountingPeriodName, getJournalEntryDetailResponse.accountingPeriodName) &&
        Objects.equals(this.aggregateCurrency, getJournalEntryDetailResponse.aggregateCurrency) &&
        Objects.equals(this.currency, getJournalEntryDetailResponse.currency) &&
        Objects.equals(this.homeCurrency, getJournalEntryDetailResponse.homeCurrency) &&
        Objects.equals(this.journalEntryDate, getJournalEntryDetailResponse.journalEntryDate) &&
        Objects.equals(this.journalEntryItems, getJournalEntryDetailResponse.journalEntryItems) &&
        Objects.equals(this.notes, getJournalEntryDetailResponse.notes) &&
        Objects.equals(this.number, getJournalEntryDetailResponse.number) &&
        Objects.equals(this.organizationLabel, getJournalEntryDetailResponse.organizationLabel) &&
        Objects.equals(this.segments, getJournalEntryDetailResponse.segments) &&
        Objects.equals(this.status, getJournalEntryDetailResponse.status) &&
        Objects.equals(this.success, getJournalEntryDetailResponse.success) &&
        Objects.equals(this.timePeriodEnd, getJournalEntryDetailResponse.timePeriodEnd) &&
        Objects.equals(this.timePeriodStart, getJournalEntryDetailResponse.timePeriodStart) &&
        Objects.equals(this.transactionType, getJournalEntryDetailResponse.transactionType) &&
        Objects.equals(this.transferDateTime, getJournalEntryDetailResponse.transferDateTime) &&
        Objects.equals(this.transferredBy, getJournalEntryDetailResponse.transferredBy) &&
        Objects.equals(this.transferredToAccounting, getJournalEntryDetailResponse.transferredToAccounting)&&
        Objects.equals(this.additionalProperties, getJournalEntryDetailResponse.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(accountingPeriodName, aggregateCurrency, currency, homeCurrency, journalEntryDate, journalEntryItems, notes, number, organizationLabel, segments, status, success, timePeriodEnd, timePeriodStart, transactionType, transferDateTime, transferredBy, transferredToAccounting, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class GetJournalEntryDetailResponse {\n");
    sb.append("    accountingPeriodName: ").append(toIndentedString(accountingPeriodName)).append("\n");
    sb.append("    aggregateCurrency: ").append(toIndentedString(aggregateCurrency)).append("\n");
    sb.append("    currency: ").append(toIndentedString(currency)).append("\n");
    sb.append("    homeCurrency: ").append(toIndentedString(homeCurrency)).append("\n");
    sb.append("    journalEntryDate: ").append(toIndentedString(journalEntryDate)).append("\n");
    sb.append("    journalEntryItems: ").append(toIndentedString(journalEntryItems)).append("\n");
    sb.append("    notes: ").append(toIndentedString(notes)).append("\n");
    sb.append("    number: ").append(toIndentedString(number)).append("\n");
    sb.append("    organizationLabel: ").append(toIndentedString(organizationLabel)).append("\n");
    sb.append("    segments: ").append(toIndentedString(segments)).append("\n");
    sb.append("    status: ").append(toIndentedString(status)).append("\n");
    sb.append("    success: ").append(toIndentedString(success)).append("\n");
    sb.append("    timePeriodEnd: ").append(toIndentedString(timePeriodEnd)).append("\n");
    sb.append("    timePeriodStart: ").append(toIndentedString(timePeriodStart)).append("\n");
    sb.append("    transactionType: ").append(toIndentedString(transactionType)).append("\n");
    sb.append("    transferDateTime: ").append(toIndentedString(transferDateTime)).append("\n");
    sb.append("    transferredBy: ").append(toIndentedString(transferredBy)).append("\n");
    sb.append("    transferredToAccounting: ").append(toIndentedString(transferredToAccounting)).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("accountingPeriodName");
    openapiFields.add("aggregateCurrency");
    openapiFields.add("currency");
    openapiFields.add("homeCurrency");
    openapiFields.add("journalEntryDate");
    openapiFields.add("journalEntryItems");
    openapiFields.add("notes");
    openapiFields.add("number");
    openapiFields.add("organizationLabel");
    openapiFields.add("segments");
    openapiFields.add("status");
    openapiFields.add("success");
    openapiFields.add("timePeriodEnd");
    openapiFields.add("timePeriodStart");
    openapiFields.add("transactionType");
    openapiFields.add("transferDateTime");
    openapiFields.add("transferredBy");
    openapiFields.add("transferredToAccounting");

    // 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 GetJournalEntryDetailResponse
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!GetJournalEntryDetailResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in GetJournalEntryDetailResponse is not found in the empty JSON string", GetJournalEntryDetailResponse.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("accountingPeriodName") != null && !jsonObj.get("accountingPeriodName").isJsonNull()) && !jsonObj.get("accountingPeriodName").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `accountingPeriodName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountingPeriodName").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("homeCurrency") != null && !jsonObj.get("homeCurrency").isJsonNull()) && !jsonObj.get("homeCurrency").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `homeCurrency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("homeCurrency").toString()));
      }
      // ensure the optional json data is an array if present
      if (jsonObj.get("journalEntryItems") != null && !jsonObj.get("journalEntryItems").isJsonNull() && !jsonObj.get("journalEntryItems").isJsonArray()) {
        throw new IllegalArgumentException(String.format("Expected the field `journalEntryItems` to be an array in the JSON string but got `%s`", jsonObj.get("journalEntryItems").toString()));
      }
      if ((jsonObj.get("notes") != null && !jsonObj.get("notes").isJsonNull()) && !jsonObj.get("notes").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `notes` to be a primitive type in the JSON string but got `%s`", jsonObj.get("notes").toString()));
      }
      if ((jsonObj.get("number") != null && !jsonObj.get("number").isJsonNull()) && !jsonObj.get("number").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("number").toString()));
      }
      if ((jsonObj.get("organizationLabel") != null && !jsonObj.get("organizationLabel").isJsonNull()) && !jsonObj.get("organizationLabel").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `organizationLabel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("organizationLabel").toString()));
      }
      if (jsonObj.get("segments") != null && !jsonObj.get("segments").isJsonNull()) {
        JsonArray jsonArraysegments = jsonObj.getAsJsonArray("segments");
        if (jsonArraysegments != null) {
          // ensure the json data is an array
          if (!jsonObj.get("segments").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `segments` to be an array in the JSON string but got `%s`", jsonObj.get("segments").toString()));
          }

          // validate the optional field `segments` (array)
          for (int i = 0; i < jsonArraysegments.size(); i++) {
            GetJournalEntrySegmentResponse.validateJsonElement(jsonArraysegments.get(i));
          };
        }
      }
      // validate the optional field `status`
      if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) {
        JournalEntryStatus.validateJsonElement(jsonObj.get("status"));
      }
      if ((jsonObj.get("transactionType") != null && !jsonObj.get("transactionType").isJsonNull()) && !jsonObj.get("transactionType").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `transactionType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transactionType").toString()));
      }
      if ((jsonObj.get("transferDateTime") != null && !jsonObj.get("transferDateTime").isJsonNull()) && !jsonObj.get("transferDateTime").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `transferDateTime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transferDateTime").toString()));
      }
      if ((jsonObj.get("transferredBy") != null && !jsonObj.get("transferredBy").isJsonNull()) && !jsonObj.get("transferredBy").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `transferredBy` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transferredBy").toString()));
      }
      // validate the optional field `transferredToAccounting`
      if (jsonObj.get("transferredToAccounting") != null && !jsonObj.get("transferredToAccounting").isJsonNull()) {
        TransferredToAccountingStatus.validateJsonElement(jsonObj.get("transferredToAccounting"));
      }
  }

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

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

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy