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.DataType;
import com.finbourne.luminesce.model.ExpressionWithAlias;
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.Arrays;
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 about a field that can be designed on (regardless if it currently is) Kind of a \"mini-available catalog entry\"
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class MappableField {
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_TYPE = "type";
@SerializedName(SERIALIZED_NAME_TYPE)
private DataType type;
public static final String SERIALIZED_NAME_DESCRIPTION = "description";
@SerializedName(SERIALIZED_NAME_DESCRIPTION)
private String description;
public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName";
@SerializedName(SERIALIZED_NAME_DISPLAY_NAME)
private String displayName;
public static final String SERIALIZED_NAME_SAMPLE_VALUES = "sampleValues";
@SerializedName(SERIALIZED_NAME_SAMPLE_VALUES)
private String sampleValues;
public static final String SERIALIZED_NAME_ALLOWED_VALUES = "allowedValues";
@SerializedName(SERIALIZED_NAME_ALLOWED_VALUES)
private String allowedValues;
public static final String SERIALIZED_NAME_MANDATORY_FOR_ACTIONS = "mandatoryForActions";
@SerializedName(SERIALIZED_NAME_MANDATORY_FOR_ACTIONS)
private String mandatoryForActions;
public static final String SERIALIZED_NAME_MAPPING = "mapping";
@SerializedName(SERIALIZED_NAME_MAPPING)
private ExpressionWithAlias mapping;
public MappableField() {
}
public MappableField name(String name) {
this.name = name;
return this;
}
/**
* Name of the field in need of mapping (The field name from within the Table Parameter itself)
* @return name
**/
@jakarta.annotation.Nullable
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public MappableField type(DataType type) {
this.type = type;
return this;
}
/**
* Get type
* @return type
**/
@jakarta.annotation.Nullable
public DataType getType() {
return type;
}
public void setType(DataType type) {
this.type = type;
}
public MappableField description(String description) {
this.description = description;
return this;
}
/**
* Description of the field (just for rendering to the user)
* @return description
**/
@jakarta.annotation.Nullable
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public MappableField displayName(String displayName) {
this.displayName = displayName;
return this;
}
/**
* Display Name of the field (just for rendering to the user)
* @return displayName
**/
@jakarta.annotation.Nullable
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public MappableField sampleValues(String sampleValues) {
this.sampleValues = sampleValues;
return this;
}
/**
* Example values for the field (just for rendering to the user)
* @return sampleValues
**/
@jakarta.annotation.Nullable
public String getSampleValues() {
return sampleValues;
}
public void setSampleValues(String sampleValues) {
this.sampleValues = sampleValues;
}
public MappableField allowedValues(String allowedValues) {
this.allowedValues = allowedValues;
return this;
}
/**
* Any set of exactly allowed values for the field (perhaps just for rendering to the user, if nothing else)
* @return allowedValues
**/
@jakarta.annotation.Nullable
public String getAllowedValues() {
return allowedValues;
}
public void setAllowedValues(String allowedValues) {
this.allowedValues = allowedValues;
}
public MappableField mandatoryForActions(String mandatoryForActions) {
this.mandatoryForActions = mandatoryForActions;
return this;
}
/**
* Which `Actions` is this mandatory for? If any (and potentially when), perhaps just for rendering to the user, if nothing else
* @return mandatoryForActions
**/
@jakarta.annotation.Nullable
public String getMandatoryForActions() {
return mandatoryForActions;
}
public void setMandatoryForActions(String mandatoryForActions) {
this.mandatoryForActions = mandatoryForActions;
}
public MappableField mapping(ExpressionWithAlias mapping) {
this.mapping = mapping;
return this;
}
/**
* Get mapping
* @return mapping
**/
@jakarta.annotation.Nullable
public ExpressionWithAlias getMapping() {
return mapping;
}
public void setMapping(ExpressionWithAlias mapping) {
this.mapping = mapping;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
MappableField mappableField = (MappableField) o;
return Objects.equals(this.name, mappableField.name) &&
Objects.equals(this.type, mappableField.type) &&
Objects.equals(this.description, mappableField.description) &&
Objects.equals(this.displayName, mappableField.displayName) &&
Objects.equals(this.sampleValues, mappableField.sampleValues) &&
Objects.equals(this.allowedValues, mappableField.allowedValues) &&
Objects.equals(this.mandatoryForActions, mappableField.mandatoryForActions) &&
Objects.equals(this.mapping, mappableField.mapping);
}
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(name, type, description, displayName, sampleValues, allowedValues, mandatoryForActions, mapping);
}
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 MappableField {\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n");
sb.append(" sampleValues: ").append(toIndentedString(sampleValues)).append("\n");
sb.append(" allowedValues: ").append(toIndentedString(allowedValues)).append("\n");
sb.append(" mandatoryForActions: ").append(toIndentedString(mandatoryForActions)).append("\n");
sb.append(" mapping: ").append(toIndentedString(mapping)).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("name");
openapiFields.add("type");
openapiFields.add("description");
openapiFields.add("displayName");
openapiFields.add("sampleValues");
openapiFields.add("allowedValues");
openapiFields.add("mandatoryForActions");
openapiFields.add("mapping");
// 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 MappableField
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!MappableField.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in MappableField is not found in the empty JSON string", MappableField.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
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("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("displayName") != null && !jsonObj.get("displayName").isJsonNull()) && !jsonObj.get("displayName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("displayName").toString()));
}
if ((jsonObj.get("sampleValues") != null && !jsonObj.get("sampleValues").isJsonNull()) && !jsonObj.get("sampleValues").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `sampleValues` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sampleValues").toString()));
}
if ((jsonObj.get("allowedValues") != null && !jsonObj.get("allowedValues").isJsonNull()) && !jsonObj.get("allowedValues").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `allowedValues` to be a primitive type in the JSON string but got `%s`", jsonObj.get("allowedValues").toString()));
}
if ((jsonObj.get("mandatoryForActions") != null && !jsonObj.get("mandatoryForActions").isJsonNull()) && !jsonObj.get("mandatoryForActions").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `mandatoryForActions` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mandatoryForActions").toString()));
}
// validate the optional field `mapping`
if (jsonObj.get("mapping") != null && !jsonObj.get("mapping").isJsonNull()) {
ExpressionWithAlias.validateJsonElement(jsonObj.get("mapping"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!MappableField.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'MappableField' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(MappableField.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, MappableField value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public MappableField read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of MappableField given an JSON string
*
* @param jsonString JSON string
* @return An instance of MappableField
* @throws IOException if the JSON string is invalid with respect to MappableField
*/
public static MappableField fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, MappableField.class);
}
/**
* Convert an instance of MappableField to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}