com.finbourne.luminesce.model.BackgroundMultiQueryProgressResponse Maven / Gradle / Ivy
/*
* 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.BackgroundQueryProgressResponse;
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;
/**
* BackgroundMultiQueryProgressResponse
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class BackgroundMultiQueryProgressResponse {
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_STATUS = "status";
@SerializedName(SERIALIZED_NAME_STATUS)
private TaskStatus status;
public static final String SERIALIZED_NAME_QUERIES = "queries";
@SerializedName(SERIALIZED_NAME_QUERIES)
private List queries;
public BackgroundMultiQueryProgressResponse() {
}
public BackgroundMultiQueryProgressResponse 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 BackgroundMultiQueryProgressResponse feedback(List feedback) {
this.feedback = feedback;
return this;
}
public BackgroundMultiQueryProgressResponse 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 BackgroundMultiQueryProgressResponse 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 BackgroundMultiQueryProgressResponse queries(List queries) {
this.queries = queries;
return this;
}
public BackgroundMultiQueryProgressResponse addQueriesItem(BackgroundQueryProgressResponse queriesItem) {
if (this.queries == null) {
this.queries = new ArrayList<>();
}
this.queries.add(queriesItem);
return this;
}
/**
* Get queries
* @return queries
**/
@jakarta.annotation.Nullable
public List getQueries() {
return queries;
}
public void setQueries(List queries) {
this.queries = queries;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
BackgroundMultiQueryProgressResponse backgroundMultiQueryProgressResponse = (BackgroundMultiQueryProgressResponse) o;
return Objects.equals(this.progress, backgroundMultiQueryProgressResponse.progress) &&
Objects.equals(this.feedback, backgroundMultiQueryProgressResponse.feedback) &&
Objects.equals(this.status, backgroundMultiQueryProgressResponse.status) &&
Objects.equals(this.queries, backgroundMultiQueryProgressResponse.queries);
}
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(progress, feedback, status, queries);
}
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 BackgroundMultiQueryProgressResponse {\n");
sb.append(" progress: ").append(toIndentedString(progress)).append("\n");
sb.append(" feedback: ").append(toIndentedString(feedback)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" queries: ").append(toIndentedString(queries)).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("progress");
openapiFields.add("feedback");
openapiFields.add("status");
openapiFields.add("queries");
// 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 BackgroundMultiQueryProgressResponse
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!BackgroundMultiQueryProgressResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in BackgroundMultiQueryProgressResponse is not found in the empty JSON string", BackgroundMultiQueryProgressResponse.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("queries") != null && !jsonObj.get("queries").isJsonNull()) {
JsonArray jsonArrayqueries = jsonObj.getAsJsonArray("queries");
if (jsonArrayqueries != null) {
// ensure the json data is an array
if (!jsonObj.get("queries").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `queries` to be an array in the JSON string but got `%s`", jsonObj.get("queries").toString()));
}
// validate the optional field `queries` (array)
for (int i = 0; i < jsonArrayqueries.size(); i++) {
BackgroundQueryProgressResponse.validateJsonElement(jsonArrayqueries.get(i));
};
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!BackgroundMultiQueryProgressResponse.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'BackgroundMultiQueryProgressResponse' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(BackgroundMultiQueryProgressResponse.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, BackgroundMultiQueryProgressResponse value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public BackgroundMultiQueryProgressResponse read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of BackgroundMultiQueryProgressResponse given an JSON string
*
* @param jsonString JSON string
* @return An instance of BackgroundMultiQueryProgressResponse
* @throws IOException if the JSON string is invalid with respect to BackgroundMultiQueryProgressResponse
*/
public static BackgroundMultiQueryProgressResponse fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, BackgroundMultiQueryProgressResponse.class);
}
/**
* Convert an instance of BackgroundMultiQueryProgressResponse to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}