com.finbourne.luminesce.model.FileReaderBuilderResponse 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.ColumnInfo;
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;
/**
* Information on how to construct a file-read sql query
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class FileReaderBuilderResponse {
public static final String SERIALIZED_NAME_QUERY = "query";
@SerializedName(SERIALIZED_NAME_QUERY)
private String query;
public static final String SERIALIZED_NAME_ERROR = "error";
@SerializedName(SERIALIZED_NAME_ERROR)
private String error;
public static final String SERIALIZED_NAME_COLUMNS = "columns";
@SerializedName(SERIALIZED_NAME_COLUMNS)
private List columns;
public static final String SERIALIZED_NAME_DATA = "data";
@SerializedName(SERIALIZED_NAME_DATA)
private Object data = null;
public FileReaderBuilderResponse() {
}
public FileReaderBuilderResponse query(String query) {
this.query = query;
return this;
}
/**
* The generated SQL
* @return query
**/
@jakarta.annotation.Nullable
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
public FileReaderBuilderResponse error(String error) {
this.error = error;
return this;
}
/**
* The error from running generated SQL Query, if any
* @return error
**/
@jakarta.annotation.Nullable
public String getError() {
return error;
}
public void setError(String error) {
this.error = error;
}
public FileReaderBuilderResponse columns(List columns) {
this.columns = columns;
return this;
}
public FileReaderBuilderResponse addColumnsItem(ColumnInfo columnsItem) {
if (this.columns == null) {
this.columns = new ArrayList<>();
}
this.columns.add(columnsItem);
return this;
}
/**
* Column information for the results
* @return columns
**/
@jakarta.annotation.Nullable
public List getColumns() {
return columns;
}
public void setColumns(List columns) {
this.columns = columns;
}
public FileReaderBuilderResponse data(Object data) {
this.data = data;
return this;
}
/**
* The resulting data from running the Query
* @return data
**/
@jakarta.annotation.Nullable
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
FileReaderBuilderResponse fileReaderBuilderResponse = (FileReaderBuilderResponse) o;
return Objects.equals(this.query, fileReaderBuilderResponse.query) &&
Objects.equals(this.error, fileReaderBuilderResponse.error) &&
Objects.equals(this.columns, fileReaderBuilderResponse.columns) &&
Objects.equals(this.data, fileReaderBuilderResponse.data);
}
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(query, error, columns, data);
}
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 FileReaderBuilderResponse {\n");
sb.append(" query: ").append(toIndentedString(query)).append("\n");
sb.append(" error: ").append(toIndentedString(error)).append("\n");
sb.append(" columns: ").append(toIndentedString(columns)).append("\n");
sb.append(" data: ").append(toIndentedString(data)).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("query");
openapiFields.add("error");
openapiFields.add("columns");
openapiFields.add("data");
// 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 FileReaderBuilderResponse
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!FileReaderBuilderResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in FileReaderBuilderResponse is not found in the empty JSON string", FileReaderBuilderResponse.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
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("error") != null && !jsonObj.get("error").isJsonNull()) && !jsonObj.get("error").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `error` to be a primitive type in the JSON string but got `%s`", jsonObj.get("error").toString()));
}
if (jsonObj.get("columns") != null && !jsonObj.get("columns").isJsonNull()) {
JsonArray jsonArraycolumns = jsonObj.getAsJsonArray("columns");
if (jsonArraycolumns != null) {
// ensure the json data is an array
if (!jsonObj.get("columns").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `columns` to be an array in the JSON string but got `%s`", jsonObj.get("columns").toString()));
}
// validate the optional field `columns` (array)
for (int i = 0; i < jsonArraycolumns.size(); i++) {
ColumnInfo.validateJsonElement(jsonArraycolumns.get(i));
};
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!FileReaderBuilderResponse.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'FileReaderBuilderResponse' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(FileReaderBuilderResponse.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, FileReaderBuilderResponse value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public FileReaderBuilderResponse read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of FileReaderBuilderResponse given an JSON string
*
* @param jsonString JSON string
* @return An instance of FileReaderBuilderResponse
* @throws IOException if the JSON string is invalid with respect to FileReaderBuilderResponse
*/
public static FileReaderBuilderResponse fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, FileReaderBuilderResponse.class);
}
/**
* Convert an instance of FileReaderBuilderResponse to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}