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

com.finbourne.luminesce.model.OptionsCsv 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.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;

/**
 * Additional options applicable to the given SourceType
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class OptionsCsv {
  public static final String SERIALIZED_NAME_COLUMN_NAMES = "columnNames";
  @SerializedName(SERIALIZED_NAME_COLUMN_NAMES)
  private String columnNames;

  public static final String SERIALIZED_NAME_COLUMN_NAMES_WANTED = "columnNamesWanted";
  @SerializedName(SERIALIZED_NAME_COLUMN_NAMES_WANTED)
  private String columnNamesWanted;

  public static final String SERIALIZED_NAME_COLUMN_TYPES = "columnTypes";
  @SerializedName(SERIALIZED_NAME_COLUMN_TYPES)
  private String columnTypes;

  public static final String SERIALIZED_NAME_INFER_TYPE_ROW_COUNT = "inferTypeRowCount";
  @SerializedName(SERIALIZED_NAME_INFER_TYPE_ROW_COUNT)
  private Integer inferTypeRowCount;

  public static final String SERIALIZED_NAME_NO_HEADER = "noHeader";
  @SerializedName(SERIALIZED_NAME_NO_HEADER)
  private Boolean noHeader;

  public static final String SERIALIZED_NAME_DELIMITER = "delimiter";
  @SerializedName(SERIALIZED_NAME_DELIMITER)
  private String delimiter;

  public static final String SERIALIZED_NAME_ESCAPE = "escape";
  @SerializedName(SERIALIZED_NAME_ESCAPE)
  private String escape;

  public static final String SERIALIZED_NAME_QUOTE = "quote";
  @SerializedName(SERIALIZED_NAME_QUOTE)
  private String quote;

  public static final String SERIALIZED_NAME_VALUES_TO_MAKE_NULL = "valuesToMakeNull";
  @SerializedName(SERIALIZED_NAME_VALUES_TO_MAKE_NULL)
  private String valuesToMakeNull;

  public static final String SERIALIZED_NAME_SKIP_PRE_HEADER = "skipPreHeader";
  @SerializedName(SERIALIZED_NAME_SKIP_PRE_HEADER)
  private Integer skipPreHeader;

  public static final String SERIALIZED_NAME_SKIP_POST_HEADER = "skipPostHeader";
  @SerializedName(SERIALIZED_NAME_SKIP_POST_HEADER)
  private Integer skipPostHeader;

  public static final String SERIALIZED_NAME_SKIP_INVALID_ROWS = "skipInvalidRows";
  @SerializedName(SERIALIZED_NAME_SKIP_INVALID_ROWS)
  private Boolean skipInvalidRows;

  public OptionsCsv() {
  }

  public OptionsCsv columnNames(String columnNames) {
    
    this.columnNames = columnNames;
    return this;
  }

   /**
   * Column Names either overrides the header row or steps in when there is no header row (comma delimited list)
   * @return columnNames
  **/
  @jakarta.annotation.Nullable
  public String getColumnNames() {
    return columnNames;
  }


  public void setColumnNames(String columnNames) {
    this.columnNames = columnNames;
  }


  public OptionsCsv columnNamesWanted(String columnNamesWanted) {
    
    this.columnNamesWanted = columnNamesWanted;
    return this;
  }

   /**
   * Column (by Name) that should be returned (comma delimited list)
   * @return columnNamesWanted
  **/
  @jakarta.annotation.Nullable
  public String getColumnNamesWanted() {
    return columnNamesWanted;
  }


  public void setColumnNamesWanted(String columnNamesWanted) {
    this.columnNamesWanted = columnNamesWanted;
  }


  public OptionsCsv columnTypes(String columnTypes) {
    
    this.columnTypes = columnTypes;
    return this;
  }

   /**
   * Column types (comma delimited list of: '{types}', some columns may be left blank while others are specified)
   * @return columnTypes
  **/
  @jakarta.annotation.Nullable
  public String getColumnTypes() {
    return columnTypes;
  }


  public void setColumnTypes(String columnTypes) {
    this.columnTypes = columnTypes;
  }


  public OptionsCsv inferTypeRowCount(Integer inferTypeRowCount) {
    
    this.inferTypeRowCount = inferTypeRowCount;
    return this;
  }

   /**
   * If non-zero and 'types' is not specified (or not specified for some columns) this will look through N rows to attempt to work out the column types for columns not pre-specified
   * @return inferTypeRowCount
  **/
  @jakarta.annotation.Nullable
  public Integer getInferTypeRowCount() {
    return inferTypeRowCount;
  }


  public void setInferTypeRowCount(Integer inferTypeRowCount) {
    this.inferTypeRowCount = inferTypeRowCount;
  }


  public OptionsCsv noHeader(Boolean noHeader) {
    
    this.noHeader = noHeader;
    return this;
  }

   /**
   * Set this if there is no header row
   * @return noHeader
  **/
  @jakarta.annotation.Nullable
  public Boolean getNoHeader() {
    return noHeader;
  }


  public void setNoHeader(Boolean noHeader) {
    this.noHeader = noHeader;
  }


  public OptionsCsv delimiter(String delimiter) {
    
    this.delimiter = delimiter;
    return this;
  }

   /**
   * The delimiter between values (\\t for tab)
   * @return delimiter
  **/
  @jakarta.annotation.Nullable
  public String getDelimiter() {
    return delimiter;
  }


  public void setDelimiter(String delimiter) {
    this.delimiter = delimiter;
  }


  public OptionsCsv escape(String escape) {
    
    this.escape = escape;
    return this;
  }

   /**
   * Character used to escape the 'Quote' character when within a value
   * @return escape
  **/
  @jakarta.annotation.Nullable
  public String getEscape() {
    return escape;
  }


  public void setEscape(String escape) {
    this.escape = escape;
  }


  public OptionsCsv quote(String quote) {
    
    this.quote = quote;
    return this;
  }

   /**
   * Character used around any field containing the 'delimiter' or a line break.
   * @return quote
  **/
  @jakarta.annotation.Nullable
  public String getQuote() {
    return quote;
  }


  public void setQuote(String quote) {
    this.quote = quote;
  }


  public OptionsCsv valuesToMakeNull(String valuesToMakeNull) {
    
    this.valuesToMakeNull = valuesToMakeNull;
    return this;
  }

   /**
   * Regex of values to map to 'null' in the returned data.
   * @return valuesToMakeNull
  **/
  @jakarta.annotation.Nullable
  public String getValuesToMakeNull() {
    return valuesToMakeNull;
  }


  public void setValuesToMakeNull(String valuesToMakeNull) {
    this.valuesToMakeNull = valuesToMakeNull;
  }


  public OptionsCsv skipPreHeader(Integer skipPreHeader) {
    
    this.skipPreHeader = skipPreHeader;
    return this;
  }

   /**
   * Number of rows to ignore before the header row
   * @return skipPreHeader
  **/
  @jakarta.annotation.Nullable
  public Integer getSkipPreHeader() {
    return skipPreHeader;
  }


  public void setSkipPreHeader(Integer skipPreHeader) {
    this.skipPreHeader = skipPreHeader;
  }


  public OptionsCsv skipPostHeader(Integer skipPostHeader) {
    
    this.skipPostHeader = skipPostHeader;
    return this;
  }

   /**
   * Number of rows to ignore after the header row
   * @return skipPostHeader
  **/
  @jakarta.annotation.Nullable
  public Integer getSkipPostHeader() {
    return skipPostHeader;
  }


  public void setSkipPostHeader(Integer skipPostHeader) {
    this.skipPostHeader = skipPostHeader;
  }


  public OptionsCsv skipInvalidRows(Boolean skipInvalidRows) {
    
    this.skipInvalidRows = skipInvalidRows;
    return this;
  }

   /**
   * Skip invalid data rows (totally invalid ones),   This also allows for potentially wrong data if it can be handled somewhat e.g. embedded quotes misused (and still returns such rows).  In either case a warning will show in the progress feedback.
   * @return skipInvalidRows
  **/
  @jakarta.annotation.Nullable
  public Boolean getSkipInvalidRows() {
    return skipInvalidRows;
  }


  public void setSkipInvalidRows(Boolean skipInvalidRows) {
    this.skipInvalidRows = skipInvalidRows;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    OptionsCsv optionsCsv = (OptionsCsv) o;
    return Objects.equals(this.columnNames, optionsCsv.columnNames) &&
        Objects.equals(this.columnNamesWanted, optionsCsv.columnNamesWanted) &&
        Objects.equals(this.columnTypes, optionsCsv.columnTypes) &&
        Objects.equals(this.inferTypeRowCount, optionsCsv.inferTypeRowCount) &&
        Objects.equals(this.noHeader, optionsCsv.noHeader) &&
        Objects.equals(this.delimiter, optionsCsv.delimiter) &&
        Objects.equals(this.escape, optionsCsv.escape) &&
        Objects.equals(this.quote, optionsCsv.quote) &&
        Objects.equals(this.valuesToMakeNull, optionsCsv.valuesToMakeNull) &&
        Objects.equals(this.skipPreHeader, optionsCsv.skipPreHeader) &&
        Objects.equals(this.skipPostHeader, optionsCsv.skipPostHeader) &&
        Objects.equals(this.skipInvalidRows, optionsCsv.skipInvalidRows);
  }

  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(columnNames, columnNamesWanted, columnTypes, inferTypeRowCount, noHeader, delimiter, escape, quote, valuesToMakeNull, skipPreHeader, skipPostHeader, skipInvalidRows);
  }

  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 OptionsCsv {\n");
    sb.append("    columnNames: ").append(toIndentedString(columnNames)).append("\n");
    sb.append("    columnNamesWanted: ").append(toIndentedString(columnNamesWanted)).append("\n");
    sb.append("    columnTypes: ").append(toIndentedString(columnTypes)).append("\n");
    sb.append("    inferTypeRowCount: ").append(toIndentedString(inferTypeRowCount)).append("\n");
    sb.append("    noHeader: ").append(toIndentedString(noHeader)).append("\n");
    sb.append("    delimiter: ").append(toIndentedString(delimiter)).append("\n");
    sb.append("    escape: ").append(toIndentedString(escape)).append("\n");
    sb.append("    quote: ").append(toIndentedString(quote)).append("\n");
    sb.append("    valuesToMakeNull: ").append(toIndentedString(valuesToMakeNull)).append("\n");
    sb.append("    skipPreHeader: ").append(toIndentedString(skipPreHeader)).append("\n");
    sb.append("    skipPostHeader: ").append(toIndentedString(skipPostHeader)).append("\n");
    sb.append("    skipInvalidRows: ").append(toIndentedString(skipInvalidRows)).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("columnNames");
    openapiFields.add("columnNamesWanted");
    openapiFields.add("columnTypes");
    openapiFields.add("inferTypeRowCount");
    openapiFields.add("noHeader");
    openapiFields.add("delimiter");
    openapiFields.add("escape");
    openapiFields.add("quote");
    openapiFields.add("valuesToMakeNull");
    openapiFields.add("skipPreHeader");
    openapiFields.add("skipPostHeader");
    openapiFields.add("skipInvalidRows");

    // 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 OptionsCsv
  */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!OptionsCsv.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in OptionsCsv is not found in the empty JSON string", OptionsCsv.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("columnNames") != null && !jsonObj.get("columnNames").isJsonNull()) && !jsonObj.get("columnNames").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `columnNames` to be a primitive type in the JSON string but got `%s`", jsonObj.get("columnNames").toString()));
      }
      if ((jsonObj.get("columnNamesWanted") != null && !jsonObj.get("columnNamesWanted").isJsonNull()) && !jsonObj.get("columnNamesWanted").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `columnNamesWanted` to be a primitive type in the JSON string but got `%s`", jsonObj.get("columnNamesWanted").toString()));
      }
      if ((jsonObj.get("columnTypes") != null && !jsonObj.get("columnTypes").isJsonNull()) && !jsonObj.get("columnTypes").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `columnTypes` to be a primitive type in the JSON string but got `%s`", jsonObj.get("columnTypes").toString()));
      }
      if ((jsonObj.get("delimiter") != null && !jsonObj.get("delimiter").isJsonNull()) && !jsonObj.get("delimiter").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `delimiter` to be a primitive type in the JSON string but got `%s`", jsonObj.get("delimiter").toString()));
      }
      if ((jsonObj.get("escape") != null && !jsonObj.get("escape").isJsonNull()) && !jsonObj.get("escape").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `escape` to be a primitive type in the JSON string but got `%s`", jsonObj.get("escape").toString()));
      }
      if ((jsonObj.get("quote") != null && !jsonObj.get("quote").isJsonNull()) && !jsonObj.get("quote").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `quote` to be a primitive type in the JSON string but got `%s`", jsonObj.get("quote").toString()));
      }
      if ((jsonObj.get("valuesToMakeNull") != null && !jsonObj.get("valuesToMakeNull").isJsonNull()) && !jsonObj.get("valuesToMakeNull").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `valuesToMakeNull` to be a primitive type in the JSON string but got `%s`", jsonObj.get("valuesToMakeNull").toString()));
      }
  }

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

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

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

       }.nullSafe();
    }
  }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy