Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.ViewParameter;
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.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
* Representation of view data where will template the data into a 'create view' sql
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ConvertToViewData {
public static final String SERIALIZED_NAME_QUERY = "query";
@SerializedName(SERIALIZED_NAME_QUERY)
private String query;
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_DESCRIPTION = "description";
@SerializedName(SERIALIZED_NAME_DESCRIPTION)
private String description;
public static final String SERIALIZED_NAME_DOCUMENTATION_LINK = "documentationLink";
@SerializedName(SERIALIZED_NAME_DOCUMENTATION_LINK)
private String documentationLink;
public static final String SERIALIZED_NAME_VIEW_PARAMETERS = "viewParameters";
@SerializedName(SERIALIZED_NAME_VIEW_PARAMETERS)
private List viewParameters;
public static final String SERIALIZED_NAME_OTHER_PARAMETERS = "otherParameters";
@SerializedName(SERIALIZED_NAME_OTHER_PARAMETERS)
private Map otherParameters;
public static final String SERIALIZED_NAME_STARTING_VARIABLE_NAME = "startingVariableName";
@SerializedName(SERIALIZED_NAME_STARTING_VARIABLE_NAME)
private String startingVariableName;
public ConvertToViewData() {
}
public ConvertToViewData query(String query) {
this.query = query;
return this;
}
/**
* view query
* @return query
**/
@jakarta.annotation.Nonnull
public String getQuery() {
return query;
}
public void setQuery(String query) {
this.query = query;
}
public ConvertToViewData name(String name) {
this.name = name;
return this;
}
/**
* Name of view
* @return name
**/
@jakarta.annotation.Nonnull
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public ConvertToViewData description(String description) {
this.description = description;
return this;
}
/**
* Description of view
* @return description
**/
@jakarta.annotation.Nullable
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public ConvertToViewData documentationLink(String documentationLink) {
this.documentationLink = documentationLink;
return this;
}
/**
* Documentation link
* @return documentationLink
**/
@jakarta.annotation.Nullable
public String getDocumentationLink() {
return documentationLink;
}
public void setDocumentationLink(String documentationLink) {
this.documentationLink = documentationLink;
}
public ConvertToViewData viewParameters(List viewParameters) {
this.viewParameters = viewParameters;
return this;
}
public ConvertToViewData addViewParametersItem(ViewParameter viewParametersItem) {
if (this.viewParameters == null) {
this.viewParameters = new ArrayList<>();
}
this.viewParameters.add(viewParametersItem);
return this;
}
/**
* View parameters
* @return viewParameters
**/
@jakarta.annotation.Nullable
public List getViewParameters() {
return viewParameters;
}
public void setViewParameters(List viewParameters) {
this.viewParameters = viewParameters;
}
public ConvertToViewData otherParameters(Map otherParameters) {
this.otherParameters = otherParameters;
return this;
}
public ConvertToViewData putOtherParametersItem(String key, String otherParametersItem) {
if (this.otherParameters == null) {
this.otherParameters = new HashMap<>();
}
this.otherParameters.put(key, otherParametersItem);
return this;
}
/**
* Other parameters not explicitly handled by the ConvertToView generation. These will be populated by the \"From SQL\" and should simply be returned by the web GUI should the user edit / update / regenerate
* @return otherParameters
**/
@jakarta.annotation.Nullable
public Map getOtherParameters() {
return otherParameters;
}
public void setOtherParameters(Map otherParameters) {
this.otherParameters = otherParameters;
}
public ConvertToViewData startingVariableName(String startingVariableName) {
this.startingVariableName = startingVariableName;
return this;
}
/**
* Which variable the this start with, null if not started from a full Create View Sql Statement.
* @return startingVariableName
**/
@jakarta.annotation.Nullable
public String getStartingVariableName() {
return startingVariableName;
}
public void setStartingVariableName(String startingVariableName) {
this.startingVariableName = startingVariableName;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ConvertToViewData convertToViewData = (ConvertToViewData) o;
return Objects.equals(this.query, convertToViewData.query) &&
Objects.equals(this.name, convertToViewData.name) &&
Objects.equals(this.description, convertToViewData.description) &&
Objects.equals(this.documentationLink, convertToViewData.documentationLink) &&
Objects.equals(this.viewParameters, convertToViewData.viewParameters) &&
Objects.equals(this.otherParameters, convertToViewData.otherParameters) &&
Objects.equals(this.startingVariableName, convertToViewData.startingVariableName);
}
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, name, description, documentationLink, viewParameters, otherParameters, startingVariableName);
}
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 ConvertToViewData {\n");
sb.append(" query: ").append(toIndentedString(query)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" documentationLink: ").append(toIndentedString(documentationLink)).append("\n");
sb.append(" viewParameters: ").append(toIndentedString(viewParameters)).append("\n");
sb.append(" otherParameters: ").append(toIndentedString(otherParameters)).append("\n");
sb.append(" startingVariableName: ").append(toIndentedString(startingVariableName)).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("name");
openapiFields.add("description");
openapiFields.add("documentationLink");
openapiFields.add("viewParameters");
openapiFields.add("otherParameters");
openapiFields.add("startingVariableName");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("query");
openapiRequiredFields.add("name");
}
/**
* 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 ConvertToViewData
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!ConvertToViewData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ConvertToViewData is not found in the empty JSON string", ConvertToViewData.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : ConvertToViewData.openapiRequiredFields) {
if (jsonElement.getAsJsonObject().get(requiredField) == null) {
throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if (!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("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("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString()));
}
if ((jsonObj.get("documentationLink") != null && !jsonObj.get("documentationLink").isJsonNull()) && !jsonObj.get("documentationLink").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `documentationLink` to be a primitive type in the JSON string but got `%s`", jsonObj.get("documentationLink").toString()));
}
if (jsonObj.get("viewParameters") != null && !jsonObj.get("viewParameters").isJsonNull()) {
JsonArray jsonArrayviewParameters = jsonObj.getAsJsonArray("viewParameters");
if (jsonArrayviewParameters != null) {
// ensure the json data is an array
if (!jsonObj.get("viewParameters").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `viewParameters` to be an array in the JSON string but got `%s`", jsonObj.get("viewParameters").toString()));
}
// validate the optional field `viewParameters` (array)
for (int i = 0; i < jsonArrayviewParameters.size(); i++) {
ViewParameter.validateJsonElement(jsonArrayviewParameters.get(i));
};
}
}
if ((jsonObj.get("startingVariableName") != null && !jsonObj.get("startingVariableName").isJsonNull()) && !jsonObj.get("startingVariableName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `startingVariableName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("startingVariableName").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!ConvertToViewData.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'ConvertToViewData' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(ConvertToViewData.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, ConvertToViewData value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public ConvertToViewData read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of ConvertToViewData given an JSON string
*
* @param jsonString JSON string
* @return An instance of ConvertToViewData
* @throws IOException if the JSON string is invalid with respect to ConvertToViewData
*/
public static ConvertToViewData fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, ConvertToViewData.class);
}
/**
* Convert an instance of ConvertToViewData to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}