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

com.zuora.model.GetBatchQueryJobResponse 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.BatchQueryEncrypted;
import com.zuora.model.BatchQueryFormat;
import com.zuora.model.BatchQueryStatus;
import com.zuora.model.GetBatchQueryResponse;
import java.io.IOException;
import java.math.BigDecimal;
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;

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

  public static final String SERIALIZED_NAME_ENCRYPTED = "encrypted";
  @SerializedName(SERIALIZED_NAME_ENCRYPTED)
  private BatchQueryEncrypted encrypted;

  public static final String SERIALIZED_NAME_FORMAT = "format";
  @SerializedName(SERIALIZED_NAME_FORMAT)
  private BatchQueryFormat format;

  public static final String SERIALIZED_NAME_ID = "id";
  @SerializedName(SERIALIZED_NAME_ID)
  private String id;

  public static final String SERIALIZED_NAME_NAME = "name";
  @SerializedName(SERIALIZED_NAME_NAME)
  private String name;

  public static final String SERIALIZED_NAME_PARTNER = "partner";
  @SerializedName(SERIALIZED_NAME_PARTNER)
  private String partner;

  public static final String SERIALIZED_NAME_PROJECT = "project";
  @SerializedName(SERIALIZED_NAME_PROJECT)
  private String project;

  public static final String SERIALIZED_NAME_OFFSET = "offset";
  @SerializedName(SERIALIZED_NAME_OFFSET)
  private BigDecimal offset;

  public static final String SERIALIZED_NAME_USE_LAST_COMPLETED_JOB_QUERIES = "useLastCompletedJobQueries";
  @SerializedName(SERIALIZED_NAME_USE_LAST_COMPLETED_JOB_QUERIES)
  private Boolean useLastCompletedJobQueries;

  public static final String SERIALIZED_NAME_START_TIME = "startTime";
  @SerializedName(SERIALIZED_NAME_START_TIME)
  private String startTime;

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

  public static final String SERIALIZED_NAME_LOCALIZED_STATUS = "localizedStatus";
  @SerializedName(SERIALIZED_NAME_LOCALIZED_STATUS)
  private BatchQueryStatus localizedStatus;

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

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

  public static final String SERIALIZED_NAME_MESSAGE = "message";
  @SerializedName(SERIALIZED_NAME_MESSAGE)
  private String message;

  public GetBatchQueryJobResponse() {
  }

  public GetBatchQueryJobResponse batches(List batches) {
    this.batches = batches;
    return this;
  }

  public GetBatchQueryJobResponse addBatchesItem(GetBatchQueryResponse batchesItem) {
    if (this.batches == null) {
      this.batches = new ArrayList<>();
    }
    this.batches.add(batchesItem);
    return this;
  }

  /**
   * A JSON array object that contains a list of batch objects. 
   * @return batches
   */
  @javax.annotation.Nullable
  public List getBatches() {
    return batches;
  }

  public void setBatches(List batches) {
    this.batches = batches;
  }


  public GetBatchQueryJobResponse encrypted(BatchQueryEncrypted encrypted) {
    this.encrypted = encrypted;
    return this;
  }

  /**
   * Get encrypted
   * @return encrypted
   */
  @javax.annotation.Nullable
  public BatchQueryEncrypted getEncrypted() {
    return encrypted;
  }

  public void setEncrypted(BatchQueryEncrypted encrypted) {
    this.encrypted = encrypted;
  }


  public GetBatchQueryJobResponse format(BatchQueryFormat format) {
    this.format = format;
    return this;
  }

  /**
   * Get format
   * @return format
   */
  @javax.annotation.Nullable
  public BatchQueryFormat getFormat() {
    return format;
  }

  public void setFormat(BatchQueryFormat format) {
    this.format = format;
  }


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

  /**
   * The job ID created for the AQuA API request. The job ID can be used for querying for the query status.   The ID exists only if the JSON request can be parsed and validated successfully. Otherwise, the job ID is null. 
   * @return id
   */
  @javax.annotation.Nullable
  public String getId() {
    return id;
  }

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


  public GetBatchQueryJobResponse name(String name) {
    this.name = name;
    return this;
  }

  /**
   * The name of the job. 32 character limit. 
   * @return name
   */
  @javax.annotation.Nullable
  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }


  public GetBatchQueryJobResponse partner(String partner) {
    this.partner = partner;
    return this;
  }

  /**
   * The partner field indicates the unique ID of a data integration partner. The dropdown list of this field displays partner IDs for the past thirty days.  It must be used together with \"project\" field to uniquely identify a data integration target.  For example, if a continuous AQuA session is to retrieve data incrementally for a Salesforce.com Org 00170000011K3Ub, you can use partner as \"Salesforce\", and \"project\" as \"00170000011K3Ub.\"   This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null.  **Note**: Zuora highly recommends you use the stateless mode instead of the stateful mode to extract bulk data. See <a href=\"https://knowledgecenter.zuora.com/Zuora_Central_Platform/API/AB_Aggregate_Query_API/Bulk_data__extraction_from_Zuora_using_AQuA\" target=\"_blank\">Bulk data extraction from Zuora using AQuA</a> for best practices.  **Note**: Submit a request at <a href=\"http://support.zuora.com\" target=\"_blank\">Zuora Global Support</a> to obtain a partner ID. 
   * @return partner
   */
  @javax.annotation.Nullable
  public String getPartner() {
    return partner;
  }

  public void setPartner(String partner) {
    this.partner = partner;
  }


  public GetBatchQueryJobResponse project(String project) {
    this.project = project;
    return this;
  }

  /**
   * The project field contains the unique ID of a data integration project for a particular partner. The dropdown list of this field displays project IDs for the past thirty days.  This field must be used together with partner field to uniquely identify a data integration target.   This field is required only if you are using AQuA in stateful mode. Otherwise, if you are using AQuA in stateless mode, partner field can be null. 
   * @return project
   */
  @javax.annotation.Nullable
  public String getProject() {
    return project;
  }

  public void setProject(String project) {
    this.project = project;
  }


  public GetBatchQueryJobResponse offset(BigDecimal offset) {
    this.offset = offset;
    return this;
  }

  /**
   * This field specifies the time offset for AQuA queries in stateful mode. It is an integer in the range 0 to 3,600 seconds.  For example, if you set this field to 600 seconds and you post a query in stateful mode at 2:00 AM, it will query against data created or updated between the completion time of the previous query and 1:50 AM.  The value of this field will override the value you configured in **Settings** > **Administration** > **AQuA API Stateful Mode Time Offset**.     
   * @return offset
   */
  @javax.annotation.Nullable
  public BigDecimal getOffset() {
    return offset;
  }

  public void setOffset(BigDecimal offset) {
    this.offset = offset;
  }


  public GetBatchQueryJobResponse useLastCompletedJobQueries(Boolean useLastCompletedJobQueries) {
    this.useLastCompletedJobQueries = useLastCompletedJobQueries;
    return this;
  }

  /**
   * If this flag is set to `true`, then all the previous queries are merged with existing queries.  If the flag is set to `false`, then the previous queries are ignored, and only the new query is executed. 
   * @return useLastCompletedJobQueries
   */
  @javax.annotation.Nullable
  public Boolean getUseLastCompletedJobQueries() {
    return useLastCompletedJobQueries;
  }

  public void setUseLastCompletedJobQueries(Boolean useLastCompletedJobQueries) {
    this.useLastCompletedJobQueries = useLastCompletedJobQueries;
  }


  public GetBatchQueryJobResponse startTime(String startTime) {
    this.startTime = startTime;
    return this;
  }

  /**
   * The start time of the query.  
   * @return startTime
   */
  @javax.annotation.Nullable
  public String getStartTime() {
    return startTime;
  }

  public void setStartTime(String startTime) {
    this.startTime = startTime;
  }


  public GetBatchQueryJobResponse status(BatchQueryStatus status) {
    this.status = status;
    return this;
  }

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

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


  public GetBatchQueryJobResponse localizedStatus(BatchQueryStatus localizedStatus) {
    this.localizedStatus = localizedStatus;
    return this;
  }

  /**
   * Get localizedStatus
   * @return localizedStatus
   */
  @javax.annotation.Nullable
  public BatchQueryStatus getLocalizedStatus() {
    return localizedStatus;
  }

  public void setLocalizedStatus(BatchQueryStatus localizedStatus) {
    this.localizedStatus = localizedStatus;
  }


  public GetBatchQueryJobResponse version(Float version) {
    this.version = version;
    return this;
  }

  /**
   * The API version you want to use.   The supported versions are as follows:   - `1.1`. It supports both modes   - `1.0`. Default. It supports stateless modes only.  See <a href=\"https://knowledgecenter.zuora.com/Zuora_Central_Platform/API/AB_Aggregate_Query_API/BA_Stateless_and_Stateful_Modes\" target=\"_blank\">Stateless and stateful modes</a> for more information. 
   * @return version
   */
  @javax.annotation.Nullable
  public Float getVersion() {
    return version;
  }

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


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

  /**
   * The error code used to identify the failure reason.
   * @return errorCode
   */
  @javax.annotation.Nullable
  public String getErrorCode() {
    return errorCode;
  }

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


  public GetBatchQueryJobResponse message(String message) {
    this.message = message;
    return this;
  }

  /**
   * The error message used to describe the failure reason detail.
   * @return message
   */
  @javax.annotation.Nullable
  public String getMessage() {
    return message;
  }

  public void setMessage(String message) {
    this.message = message;
  }

  /**
   * 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 GetBatchQueryJobResponse instance itself
   */
  public GetBatchQueryJobResponse 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;
    }
    GetBatchQueryJobResponse getBatchQueryJobResponse = (GetBatchQueryJobResponse) o;
    return Objects.equals(this.batches, getBatchQueryJobResponse.batches) &&
        Objects.equals(this.encrypted, getBatchQueryJobResponse.encrypted) &&
        Objects.equals(this.format, getBatchQueryJobResponse.format) &&
        Objects.equals(this.id, getBatchQueryJobResponse.id) &&
        Objects.equals(this.name, getBatchQueryJobResponse.name) &&
        Objects.equals(this.partner, getBatchQueryJobResponse.partner) &&
        Objects.equals(this.project, getBatchQueryJobResponse.project) &&
        Objects.equals(this.offset, getBatchQueryJobResponse.offset) &&
        Objects.equals(this.useLastCompletedJobQueries, getBatchQueryJobResponse.useLastCompletedJobQueries) &&
        Objects.equals(this.startTime, getBatchQueryJobResponse.startTime) &&
        Objects.equals(this.status, getBatchQueryJobResponse.status) &&
        Objects.equals(this.localizedStatus, getBatchQueryJobResponse.localizedStatus) &&
        Objects.equals(this.version, getBatchQueryJobResponse.version) &&
        Objects.equals(this.errorCode, getBatchQueryJobResponse.errorCode) &&
        Objects.equals(this.message, getBatchQueryJobResponse.message)&&
        Objects.equals(this.additionalProperties, getBatchQueryJobResponse.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(batches, encrypted, format, id, name, partner, project, offset, useLastCompletedJobQueries, startTime, status, localizedStatus, version, errorCode, message, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class GetBatchQueryJobResponse {\n");
    sb.append("    batches: ").append(toIndentedString(batches)).append("\n");
    sb.append("    encrypted: ").append(toIndentedString(encrypted)).append("\n");
    sb.append("    format: ").append(toIndentedString(format)).append("\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    name: ").append(toIndentedString(name)).append("\n");
    sb.append("    partner: ").append(toIndentedString(partner)).append("\n");
    sb.append("    project: ").append(toIndentedString(project)).append("\n");
    sb.append("    offset: ").append(toIndentedString(offset)).append("\n");
    sb.append("    useLastCompletedJobQueries: ").append(toIndentedString(useLastCompletedJobQueries)).append("\n");
    sb.append("    startTime: ").append(toIndentedString(startTime)).append("\n");
    sb.append("    status: ").append(toIndentedString(status)).append("\n");
    sb.append("    localizedStatus: ").append(toIndentedString(localizedStatus)).append("\n");
    sb.append("    version: ").append(toIndentedString(version)).append("\n");
    sb.append("    errorCode: ").append(toIndentedString(errorCode)).append("\n");
    sb.append("    message: ").append(toIndentedString(message)).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("batches");
    openapiFields.add("encrypted");
    openapiFields.add("format");
    openapiFields.add("id");
    openapiFields.add("name");
    openapiFields.add("partner");
    openapiFields.add("project");
    openapiFields.add("offset");
    openapiFields.add("useLastCompletedJobQueries");
    openapiFields.add("startTime");
    openapiFields.add("status");
    openapiFields.add("localizedStatus");
    openapiFields.add("version");
    openapiFields.add("errorCode");
    openapiFields.add("message");

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

          // validate the optional field `batches` (array)
          for (int i = 0; i < jsonArraybatches.size(); i++) {
            GetBatchQueryResponse.validateJsonElement(jsonArraybatches.get(i));
          };
        }
      }
      if ((jsonObj.get("encrypted") != null && !jsonObj.get("encrypted").isJsonNull()) && !jsonObj.get("encrypted").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `encrypted` to be a primitive type in the JSON string but got `%s`", jsonObj.get("encrypted").toString()));
      }
      // validate the optional field `encrypted`
      if (jsonObj.get("encrypted") != null && !jsonObj.get("encrypted").isJsonNull()) {
        BatchQueryEncrypted.validateJsonElement(jsonObj.get("encrypted"));
      }
      if ((jsonObj.get("format") != null && !jsonObj.get("format").isJsonNull()) && !jsonObj.get("format").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `format` to be a primitive type in the JSON string but got `%s`", jsonObj.get("format").toString()));
      }
      // validate the optional field `format`
      if (jsonObj.get("format") != null && !jsonObj.get("format").isJsonNull()) {
        BatchQueryFormat.validateJsonElement(jsonObj.get("format"));
      }
      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("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
      }
      if ((jsonObj.get("partner") != null && !jsonObj.get("partner").isJsonNull()) && !jsonObj.get("partner").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `partner` to be a primitive type in the JSON string but got `%s`", jsonObj.get("partner").toString()));
      }
      if ((jsonObj.get("project") != null && !jsonObj.get("project").isJsonNull()) && !jsonObj.get("project").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `project` to be a primitive type in the JSON string but got `%s`", jsonObj.get("project").toString()));
      }
      if ((jsonObj.get("startTime") != null && !jsonObj.get("startTime").isJsonNull()) && !jsonObj.get("startTime").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `startTime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("startTime").toString()));
      }
      if ((jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) && !jsonObj.get("status").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
      }
      // validate the optional field `status`
      if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) {
        BatchQueryStatus.validateJsonElement(jsonObj.get("status"));
      }
      if ((jsonObj.get("localizedStatus") != null && !jsonObj.get("localizedStatus").isJsonNull()) && !jsonObj.get("localizedStatus").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `localizedStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("localizedStatus").toString()));
      }
      // validate the optional field `localizedStatus`
      if (jsonObj.get("localizedStatus") != null && !jsonObj.get("localizedStatus").isJsonNull()) {
        BatchQueryStatus.validateJsonElement(jsonObj.get("localizedStatus"));
      }
      if ((jsonObj.get("errorCode") != null && !jsonObj.get("errorCode").isJsonNull()) && !jsonObj.get("errorCode").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `errorCode` to be a primitive type in the JSON string but got `%s`", jsonObj.get("errorCode").toString()));
      }
      if ((jsonObj.get("message") != null && !jsonObj.get("message").isJsonNull()) && !jsonObj.get("message").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString()));
      }
  }

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

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

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy