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

com.finbourne.luminesce.model.BackgroundQueryProgressResponse Maven / Gradle / Ivy

There is a newer version: 2.0.285
Show newest version
/*
 * FINBOURNE Luminesce Web API
 *
 * 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.finbourne.luminesce.model;

import java.util.Objects;
import com.finbourne.luminesce.model.BackgroundQueryState;
import com.finbourne.luminesce.model.Column;
import com.finbourne.luminesce.model.FeedbackEventArgs;
import com.finbourne.luminesce.model.TaskStatus;
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.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.openapitools.jackson.nullable.JsonNullable;

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.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.finbourne.luminesce.JSON;

/**
 * BackgroundQueryProgressResponse
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class BackgroundQueryProgressResponse {
  public static final String SERIALIZED_NAME_HAS_DATA = "hasData";
  @SerializedName(SERIALIZED_NAME_HAS_DATA)
  private Boolean hasData;

  public static final String SERIALIZED_NAME_ROW_COUNT = "rowCount";
  @SerializedName(SERIALIZED_NAME_ROW_COUNT)
  private Integer rowCount;

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

  public static final String SERIALIZED_NAME_STATE = "state";
  @SerializedName(SERIALIZED_NAME_STATE)
  private BackgroundQueryState state;

  public static final String SERIALIZED_NAME_PROGRESS = "progress";
  @SerializedName(SERIALIZED_NAME_PROGRESS)
  private String progress;

  public static final String SERIALIZED_NAME_FEEDBACK = "feedback";
  @SerializedName(SERIALIZED_NAME_FEEDBACK)
  private List feedback;

  public static final String SERIALIZED_NAME_QUERY = "query";
  @SerializedName(SERIALIZED_NAME_QUERY)
  private String query;

  public static final String SERIALIZED_NAME_QUERY_NAME = "queryName";
  @SerializedName(SERIALIZED_NAME_QUERY_NAME)
  private String queryName;

  public static final String SERIALIZED_NAME_COLUMNS_AVAILABLE = "columnsAvailable";
  @SerializedName(SERIALIZED_NAME_COLUMNS_AVAILABLE)
  private List columnsAvailable;

  public BackgroundQueryProgressResponse() {
  }

  public BackgroundQueryProgressResponse hasData(Boolean hasData) {
    
    this.hasData = hasData;
    return this;
  }

   /**
   * Is there currently data for this Query?
   * @return hasData
  **/
  @jakarta.annotation.Nullable
  public Boolean getHasData() {
    return hasData;
  }


  public void setHasData(Boolean hasData) {
    this.hasData = hasData;
  }


  public BackgroundQueryProgressResponse rowCount(Integer rowCount) {
    
    this.rowCount = rowCount;
    return this;
  }

   /**
   * Number of rows of data held. -1 if none as yet.
   * @return rowCount
  **/
  @jakarta.annotation.Nullable
  public Integer getRowCount() {
    return rowCount;
  }


  public void setRowCount(Integer rowCount) {
    this.rowCount = rowCount;
  }


  public BackgroundQueryProgressResponse status(TaskStatus status) {
    
    this.status = status;
    return this;
  }

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


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


  public BackgroundQueryProgressResponse state(BackgroundQueryState state) {
    
    this.state = state;
    return this;
  }

   /**
   * Get state
   * @return state
  **/
  @jakarta.annotation.Nullable
  public BackgroundQueryState getState() {
    return state;
  }


  public void setState(BackgroundQueryState state) {
    this.state = state;
  }


  public BackgroundQueryProgressResponse progress(String progress) {
    
    this.progress = progress;
    return this;
  }

   /**
   * The full progress log (up to this point at least)
   * @return progress
  **/
  @jakarta.annotation.Nullable
  public String getProgress() {
    return progress;
  }


  public void setProgress(String progress) {
    this.progress = progress;
  }


  public BackgroundQueryProgressResponse feedback(List feedback) {
    
    this.feedback = feedback;
    return this;
  }

  public BackgroundQueryProgressResponse addFeedbackItem(FeedbackEventArgs feedbackItem) {
    if (this.feedback == null) {
      this.feedback = new ArrayList<>();
    }
    this.feedback.add(feedbackItem);
    return this;
  }

   /**
   * Individual Feedback Messages (to replace Progress). A given message will be returned from only one call.
   * @return feedback
  **/
  @jakarta.annotation.Nullable
  public List getFeedback() {
    return feedback;
  }


  public void setFeedback(List feedback) {
    this.feedback = feedback;
  }


  public BackgroundQueryProgressResponse query(String query) {
    
    this.query = query;
    return this;
  }

   /**
   * The LuminesceSql of the original request
   * @return query
  **/
  @jakarta.annotation.Nullable
  public String getQuery() {
    return query;
  }


  public void setQuery(String query) {
    this.query = query;
  }


  public BackgroundQueryProgressResponse queryName(String queryName) {
    
    this.queryName = queryName;
    return this;
  }

   /**
   * The QueryName given in the original request
   * @return queryName
  **/
  @jakarta.annotation.Nullable
  public String getQueryName() {
    return queryName;
  }


  public void setQueryName(String queryName) {
    this.queryName = queryName;
  }


  public BackgroundQueryProgressResponse columnsAvailable(List columnsAvailable) {
    
    this.columnsAvailable = columnsAvailable;
    return this;
  }

  public BackgroundQueryProgressResponse addColumnsAvailableItem(Column columnsAvailableItem) {
    if (this.columnsAvailable == null) {
      this.columnsAvailable = new ArrayList<>();
    }
    this.columnsAvailable.add(columnsAvailableItem);
    return this;
  }

   /**
   * When HasData is true this is the schema of columns that will be returned if the data is requested
   * @return columnsAvailable
  **/
  @jakarta.annotation.Nullable
  public List getColumnsAvailable() {
    return columnsAvailable;
  }


  public void setColumnsAvailable(List columnsAvailable) {
    this.columnsAvailable = columnsAvailable;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    BackgroundQueryProgressResponse backgroundQueryProgressResponse = (BackgroundQueryProgressResponse) o;
    return Objects.equals(this.hasData, backgroundQueryProgressResponse.hasData) &&
        Objects.equals(this.rowCount, backgroundQueryProgressResponse.rowCount) &&
        Objects.equals(this.status, backgroundQueryProgressResponse.status) &&
        Objects.equals(this.state, backgroundQueryProgressResponse.state) &&
        Objects.equals(this.progress, backgroundQueryProgressResponse.progress) &&
        Objects.equals(this.feedback, backgroundQueryProgressResponse.feedback) &&
        Objects.equals(this.query, backgroundQueryProgressResponse.query) &&
        Objects.equals(this.queryName, backgroundQueryProgressResponse.queryName) &&
        Objects.equals(this.columnsAvailable, backgroundQueryProgressResponse.columnsAvailable);
  }

  private static  boolean equalsNullable(JsonNullable a, JsonNullable b) {
    return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
  }

  @Override
  public int hashCode() {
    return Objects.hash(hasData, rowCount, status, state, progress, feedback, query, queryName, columnsAvailable);
  }

  private static  int hashCodeNullable(JsonNullable a) {
    if (a == null) {
      return 1;
    }
    return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class BackgroundQueryProgressResponse {\n");
    sb.append("    hasData: ").append(toIndentedString(hasData)).append("\n");
    sb.append("    rowCount: ").append(toIndentedString(rowCount)).append("\n");
    sb.append("    status: ").append(toIndentedString(status)).append("\n");
    sb.append("    state: ").append(toIndentedString(state)).append("\n");
    sb.append("    progress: ").append(toIndentedString(progress)).append("\n");
    sb.append("    feedback: ").append(toIndentedString(feedback)).append("\n");
    sb.append("    query: ").append(toIndentedString(query)).append("\n");
    sb.append("    queryName: ").append(toIndentedString(queryName)).append("\n");
    sb.append("    columnsAvailable: ").append(toIndentedString(columnsAvailable)).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("hasData");
    openapiFields.add("rowCount");
    openapiFields.add("status");
    openapiFields.add("state");
    openapiFields.add("progress");
    openapiFields.add("feedback");
    openapiFields.add("query");
    openapiFields.add("queryName");
    openapiFields.add("columnsAvailable");

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

          // validate the optional field `feedback` (array)
          for (int i = 0; i < jsonArrayfeedback.size(); i++) {
            FeedbackEventArgs.validateJsonElement(jsonArrayfeedback.get(i));
          };
        }
      }
      if ((jsonObj.get("query") != null && !jsonObj.get("query").isJsonNull()) && !jsonObj.get("query").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `query` to be a primitive type in the JSON string but got `%s`", jsonObj.get("query").toString()));
      }
      if ((jsonObj.get("queryName") != null && !jsonObj.get("queryName").isJsonNull()) && !jsonObj.get("queryName").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `queryName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("queryName").toString()));
      }
      if (jsonObj.get("columnsAvailable") != null && !jsonObj.get("columnsAvailable").isJsonNull()) {
        JsonArray jsonArraycolumnsAvailable = jsonObj.getAsJsonArray("columnsAvailable");
        if (jsonArraycolumnsAvailable != null) {
          // ensure the json data is an array
          if (!jsonObj.get("columnsAvailable").isJsonArray()) {
            throw new IllegalArgumentException(String.format("Expected the field `columnsAvailable` to be an array in the JSON string but got `%s`", jsonObj.get("columnsAvailable").toString()));
          }

          // validate the optional field `columnsAvailable` (array)
          for (int i = 0; i < jsonArraycolumnsAvailable.size(); i++) {
            Column.validateJsonElement(jsonArraycolumnsAvailable.get(i));
          };
        }
      }
  }

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

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, BackgroundQueryProgressResponse value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             elementAdapter.write(out, obj);
           }

           @Override
           public BackgroundQueryProgressResponse read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             return thisAdapter.fromJsonTree(jsonElement);
           }

       }.nullSafe();
    }
  }

 /**
  * Create an instance of BackgroundQueryProgressResponse given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of BackgroundQueryProgressResponse
  * @throws IOException if the JSON string is invalid with respect to BackgroundQueryProgressResponse
  */
  public static BackgroundQueryProgressResponse fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, BackgroundQueryProgressResponse.class);
  }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy