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

com.finbourne.luminesce.model.OptionsXml 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.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 OptionsXml {
  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_VALUES_TO_MAKE_NULL = "valuesToMakeNull";
  @SerializedName(SERIALIZED_NAME_VALUES_TO_MAKE_NULL)
  private String valuesToMakeNull;

  public static final String SERIALIZED_NAME_COLUMN_NAMES = "columnNames";
  @SerializedName(SERIALIZED_NAME_COLUMN_NAMES)
  private String columnNames;

  public static final String SERIALIZED_NAME_NODE_PATH = "nodePath";
  @SerializedName(SERIALIZED_NAME_NODE_PATH)
  private String nodePath;

  public static final String SERIALIZED_NAME_NAMESPACES = "namespaces";
  @SerializedName(SERIALIZED_NAME_NAMESPACES)
  private String namespaces;

  public OptionsXml() {
  }

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

   /**
   * XPath query that selects the nodes to map to rows
   * @return nodePath
  **/
  @jakarta.annotation.Nullable
  public String getNodePath() {
    return nodePath;
  }


  public void setNodePath(String nodePath) {
    this.nodePath = nodePath;
  }


  public OptionsXml namespaces(String namespaces) {
    
    this.namespaces = namespaces;
    return this;
  }

   /**
   * Selected prefix(es) and namespace(s):prefix1=namespace1-uri1,prefix2=namespace2-uri2,...prefixN=namespaceN-uriN
   * @return namespaces
  **/
  @jakarta.annotation.Nullable
  public String getNamespaces() {
    return namespaces;
  }


  public void setNamespaces(String namespaces) {
    this.namespaces = namespaces;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    OptionsXml optionsXml = (OptionsXml) o;
    return Objects.equals(this.columnTypes, optionsXml.columnTypes) &&
        Objects.equals(this.inferTypeRowCount, optionsXml.inferTypeRowCount) &&
        Objects.equals(this.valuesToMakeNull, optionsXml.valuesToMakeNull) &&
        Objects.equals(this.columnNames, optionsXml.columnNames) &&
        Objects.equals(this.nodePath, optionsXml.nodePath) &&
        Objects.equals(this.namespaces, optionsXml.namespaces);
  }

  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(columnTypes, inferTypeRowCount, valuesToMakeNull, columnNames, nodePath, namespaces);
  }

  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 OptionsXml {\n");
    sb.append("    columnTypes: ").append(toIndentedString(columnTypes)).append("\n");
    sb.append("    inferTypeRowCount: ").append(toIndentedString(inferTypeRowCount)).append("\n");
    sb.append("    valuesToMakeNull: ").append(toIndentedString(valuesToMakeNull)).append("\n");
    sb.append("    columnNames: ").append(toIndentedString(columnNames)).append("\n");
    sb.append("    nodePath: ").append(toIndentedString(nodePath)).append("\n");
    sb.append("    namespaces: ").append(toIndentedString(namespaces)).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("columnTypes");
    openapiFields.add("inferTypeRowCount");
    openapiFields.add("valuesToMakeNull");
    openapiFields.add("columnNames");
    openapiFields.add("nodePath");
    openapiFields.add("namespaces");

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

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

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

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

       }.nullSafe();
    }
  }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy