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

com.finbourne.luminesce.model.Column 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.ConditionAttributes;
import com.finbourne.luminesce.model.DataType;
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;

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

  public static final String SERIALIZED_NAME_IS_MAIN = "isMain";
  @SerializedName(SERIALIZED_NAME_IS_MAIN)
  private Boolean isMain;

  public static final String SERIALIZED_NAME_IS_REQUIRED_BY_PROVIDER = "isRequiredByProvider";
  @SerializedName(SERIALIZED_NAME_IS_REQUIRED_BY_PROVIDER)
  private Boolean isRequiredByProvider;

  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_CLIENT_IDS = "clientIds";
  @SerializedName(SERIALIZED_NAME_CLIENT_IDS)
  private List clientIds;

  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_CONDITION_USAGE = "conditionUsage";
  @SerializedName(SERIALIZED_NAME_CONDITION_USAGE)
  private ConditionAttributes conditionUsage;

  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 Column() {
  }

  
  public Column(
     String name
  ) {
    this();
    this.name = name;
  }

  public Column isPrimaryKey(Boolean isPrimaryKey) {
    
    this.isPrimaryKey = isPrimaryKey;
    return this;
  }

   /**
   * Get isPrimaryKey
   * @return isPrimaryKey
  **/
  @jakarta.annotation.Nullable
  public Boolean getIsPrimaryKey() {
    return isPrimaryKey;
  }


  public void setIsPrimaryKey(Boolean isPrimaryKey) {
    this.isPrimaryKey = isPrimaryKey;
  }


  public Column isMain(Boolean isMain) {
    
    this.isMain = isMain;
    return this;
  }

   /**
   * Get isMain
   * @return isMain
  **/
  @jakarta.annotation.Nullable
  public Boolean getIsMain() {
    return isMain;
  }


  public void setIsMain(Boolean isMain) {
    this.isMain = isMain;
  }


  public Column isRequiredByProvider(Boolean isRequiredByProvider) {
    
    this.isRequiredByProvider = isRequiredByProvider;
    return this;
  }

   /**
   * Get isRequiredByProvider
   * @return isRequiredByProvider
  **/
  @jakarta.annotation.Nullable
  public Boolean getIsRequiredByProvider() {
    return isRequiredByProvider;
  }


  public void setIsRequiredByProvider(Boolean isRequiredByProvider) {
    this.isRequiredByProvider = isRequiredByProvider;
  }


  public Column mandatoryForActions(String mandatoryForActions) {
    
    this.mandatoryForActions = mandatoryForActions;
    return this;
  }

   /**
   * Get mandatoryForActions
   * @return mandatoryForActions
  **/
  @jakarta.annotation.Nullable
  public String getMandatoryForActions() {
    return mandatoryForActions;
  }


  public void setMandatoryForActions(String mandatoryForActions) {
    this.mandatoryForActions = mandatoryForActions;
  }


  public Column clientIds(List clientIds) {
    
    this.clientIds = clientIds;
    return this;
  }

  public Column addClientIdsItem(String clientIdsItem) {
    if (this.clientIds == null) {
      this.clientIds = new ArrayList<>();
    }
    this.clientIds.add(clientIdsItem);
    return this;
  }

   /**
   * Get clientIds
   * @return clientIds
  **/
  @jakarta.annotation.Nullable
  public List getClientIds() {
    return clientIds;
  }


  public void setClientIds(List clientIds) {
    this.clientIds = clientIds;
  }


   /**
   * Get name
   * @return name
  **/
  @jakarta.annotation.Nullable
  public String getName() {
    return name;
  }




  public Column 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 Column description(String description) {
    
    this.description = description;
    return this;
  }

   /**
   * Get description
   * @return description
  **/
  @jakarta.annotation.Nullable
  public String getDescription() {
    return description;
  }


  public void setDescription(String description) {
    this.description = description;
  }


  public Column displayName(String displayName) {
    
    this.displayName = displayName;
    return this;
  }

   /**
   * Get displayName
   * @return displayName
  **/
  @jakarta.annotation.Nullable
  public String getDisplayName() {
    return displayName;
  }


  public void setDisplayName(String displayName) {
    this.displayName = displayName;
  }


  public Column conditionUsage(ConditionAttributes conditionUsage) {
    
    this.conditionUsage = conditionUsage;
    return this;
  }

   /**
   * Get conditionUsage
   * @return conditionUsage
  **/
  @jakarta.annotation.Nullable
  public ConditionAttributes getConditionUsage() {
    return conditionUsage;
  }


  public void setConditionUsage(ConditionAttributes conditionUsage) {
    this.conditionUsage = conditionUsage;
  }


  public Column sampleValues(String sampleValues) {
    
    this.sampleValues = sampleValues;
    return this;
  }

   /**
   * Get sampleValues
   * @return sampleValues
  **/
  @jakarta.annotation.Nullable
  public String getSampleValues() {
    return sampleValues;
  }


  public void setSampleValues(String sampleValues) {
    this.sampleValues = sampleValues;
  }


  public Column allowedValues(String allowedValues) {
    
    this.allowedValues = allowedValues;
    return this;
  }

   /**
   * Get allowedValues
   * @return allowedValues
  **/
  @jakarta.annotation.Nullable
  public String getAllowedValues() {
    return allowedValues;
  }


  public void setAllowedValues(String allowedValues) {
    this.allowedValues = allowedValues;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    Column column = (Column) o;
    return Objects.equals(this.isPrimaryKey, column.isPrimaryKey) &&
        Objects.equals(this.isMain, column.isMain) &&
        Objects.equals(this.isRequiredByProvider, column.isRequiredByProvider) &&
        Objects.equals(this.mandatoryForActions, column.mandatoryForActions) &&
        Objects.equals(this.clientIds, column.clientIds) &&
        Objects.equals(this.name, column.name) &&
        Objects.equals(this.type, column.type) &&
        Objects.equals(this.description, column.description) &&
        Objects.equals(this.displayName, column.displayName) &&
        Objects.equals(this.conditionUsage, column.conditionUsage) &&
        Objects.equals(this.sampleValues, column.sampleValues) &&
        Objects.equals(this.allowedValues, column.allowedValues);
  }

  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(isPrimaryKey, isMain, isRequiredByProvider, mandatoryForActions, clientIds, name, type, description, displayName, conditionUsage, sampleValues, allowedValues);
  }

  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 Column {\n");
    sb.append("    isPrimaryKey: ").append(toIndentedString(isPrimaryKey)).append("\n");
    sb.append("    isMain: ").append(toIndentedString(isMain)).append("\n");
    sb.append("    isRequiredByProvider: ").append(toIndentedString(isRequiredByProvider)).append("\n");
    sb.append("    mandatoryForActions: ").append(toIndentedString(mandatoryForActions)).append("\n");
    sb.append("    clientIds: ").append(toIndentedString(clientIds)).append("\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("    conditionUsage: ").append(toIndentedString(conditionUsage)).append("\n");
    sb.append("    sampleValues: ").append(toIndentedString(sampleValues)).append("\n");
    sb.append("    allowedValues: ").append(toIndentedString(allowedValues)).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("isPrimaryKey");
    openapiFields.add("isMain");
    openapiFields.add("isRequiredByProvider");
    openapiFields.add("mandatoryForActions");
    openapiFields.add("clientIds");
    openapiFields.add("name");
    openapiFields.add("type");
    openapiFields.add("description");
    openapiFields.add("displayName");
    openapiFields.add("conditionUsage");
    openapiFields.add("sampleValues");
    openapiFields.add("allowedValues");

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

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

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

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

       }.nullSafe();
    }
  }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy