sdks/java/src/main/java/com/konfigthis/client/model/OptionsSymbol.java
/*
 * SnapTrade
 * Connect brokerage accounts to your app for live positions and trading
 *
 * The version of the OpenAPI document: 1.0.0
 * Contact: anpch@example.com
 *
 * NOTE: This class is auto generated by Konfig (https://konfigthis.com).
 * Do not edit the class manually.
 */


package com.konfigthis.client.model;

import java.util.Objects;
import java.util.Arrays;
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 com.konfigthis.client.model.UnderlyingSymbol;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;
import java.util.UUID;
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 org.apache.commons.lang3.StringUtils;

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.konfigthis.client.JSON;

/**
 * Options Symbol
 */
@ApiModel(description = "Options Symbol")
@javax.annotation.Generated(value = "Generated by https://konfigthis.com")
public class OptionsSymbol {
  public static final String SERIALIZED_NAME_ID = "id";
  @SerializedName(SERIALIZED_NAME_ID)
  private UUID id;

  public static final String SERIALIZED_NAME_TICKER = "ticker";
  @SerializedName(SERIALIZED_NAME_TICKER)
  private String ticker;

  public static final String SERIALIZED_NAME_STRIKE_PRICE = "strike_price";
  @SerializedName(SERIALIZED_NAME_STRIKE_PRICE)
  private Double strikePrice;

  public static final String SERIALIZED_NAME_EXPIRATION_DATE = "expiration_date";
  @SerializedName(SERIALIZED_NAME_EXPIRATION_DATE)
  private String expirationDate;

  public static final String SERIALIZED_NAME_IS_MINI_OPTION = "is_mini_option";
  @SerializedName(SERIALIZED_NAME_IS_MINI_OPTION)
  private Boolean isMiniOption;

  public static final String SERIALIZED_NAME_UNDERLYING_SYMBOL = "underlying_symbol";
  @SerializedName(SERIALIZED_NAME_UNDERLYING_SYMBOL)
  private UnderlyingSymbol underlyingSymbol;

  public static final String SERIALIZED_NAME_LOCAL_ID = "local_id";
  @SerializedName(SERIALIZED_NAME_LOCAL_ID)
  private String localId;

  public static final String SERIALIZED_NAME_SECURITY_TYPE = "security_type";
  @SerializedName(SERIALIZED_NAME_SECURITY_TYPE)
  private Object securityType = null;

  public static final String SERIALIZED_NAME_LISTING_EXCHANGE = "listing_exchange";
  @SerializedName(SERIALIZED_NAME_LISTING_EXCHANGE)
  private Object listingExchange = null;

  public static final String SERIALIZED_NAME_IS_QUOTABLE = "is_quotable";
  @SerializedName(SERIALIZED_NAME_IS_QUOTABLE)
  private Boolean isQuotable;

  public static final String SERIALIZED_NAME_IS_TRADABLE = "is_tradable";
  @SerializedName(SERIALIZED_NAME_IS_TRADABLE)
  private Boolean isTradable;

  public OptionsSymbol() {
  }

  public OptionsSymbol id(UUID id) {

    
    
    
    
    this.id = id;
    return this;
  }

   /**
   * Get id
   * @return id
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "2bcd7cc3-e922-4976-bce1-9858296801c3", value = "")

  public UUID getId() {
    return id;
  }


  public void setId(UUID id) {

    
    
    
    this.id = id;
  }


  public OptionsSymbol ticker(String ticker) {

    
    
    
    
    this.ticker = ticker;
    return this;
  }

   /**
   * Get ticker
   * @return ticker
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "SPY 220819P00200000", value = "")

  public String getTicker() {
    return ticker;
  }


  public void setTicker(String ticker) {

    
    
    
    this.ticker = ticker;
  }


  public OptionsSymbol strikePrice(Double strikePrice) {

    
    
    
    
    this.strikePrice = strikePrice;
    return this;
  }

  public OptionsSymbol strikePrice(Integer strikePrice) {

    
    
    
    
    this.strikePrice = strikePrice.doubleValue();
    return this;
  }

   /**
   * Get strikePrice
   * @return strikePrice
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "200", value = "")

  public Double getStrikePrice() {
    return strikePrice;
  }


  public void setStrikePrice(Double strikePrice) {

    
    
    
    this.strikePrice = strikePrice;
  }


  public OptionsSymbol expirationDate(String expirationDate) {

    
    
    
    
    this.expirationDate = expirationDate;
    return this;
  }

   /**
   * Get expirationDate
   * @return expirationDate
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "2022-08-19T00:00:00.000Z", value = "")

  public String getExpirationDate() {
    return expirationDate;
  }


  public void setExpirationDate(String expirationDate) {

    
    
    
    this.expirationDate = expirationDate;
  }


  public OptionsSymbol isMiniOption(Boolean isMiniOption) {

    
    
    
    
    this.isMiniOption = isMiniOption;
    return this;
  }

   /**
   * Get isMiniOption
   * @return isMiniOption
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "false", value = "")

  public Boolean getIsMiniOption() {
    return isMiniOption;
  }


  public void setIsMiniOption(Boolean isMiniOption) {

    
    
    
    this.isMiniOption = isMiniOption;
  }


  public OptionsSymbol underlyingSymbol(UnderlyingSymbol underlyingSymbol) {

    
    
    
    
    this.underlyingSymbol = underlyingSymbol;
    return this;
  }

   /**
   * Get underlyingSymbol
   * @return underlyingSymbol
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(value = "")

  public UnderlyingSymbol getUnderlyingSymbol() {
    return underlyingSymbol;
  }


  public void setUnderlyingSymbol(UnderlyingSymbol underlyingSymbol) {

    
    
    
    this.underlyingSymbol = underlyingSymbol;
  }


  public OptionsSymbol localId(String localId) {

    
    
    
    
    this.localId = localId;
    return this;
  }

   /**
   * Get localId
   * @return localId
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "40817960", value = "")

  public String getLocalId() {
    return localId;
  }


  public void setLocalId(String localId) {

    
    
    
    this.localId = localId;
  }


  public OptionsSymbol securityType(Object securityType) {

    
    
    
    
    this.securityType = securityType;
    return this;
  }

   /**
   * Get securityType
   * @return securityType
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "{}", value = "")

  public Object getSecurityType() {
    return securityType;
  }


  public void setSecurityType(Object securityType) {

    
    
    
    this.securityType = securityType;
  }


  public OptionsSymbol listingExchange(Object listingExchange) {

    
    
    
    
    this.listingExchange = listingExchange;
    return this;
  }

   /**
   * Get listingExchange
   * @return listingExchange
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "{}", value = "")

  public Object getListingExchange() {
    return listingExchange;
  }


  public void setListingExchange(Object listingExchange) {

    
    
    
    this.listingExchange = listingExchange;
  }


  public OptionsSymbol isQuotable(Boolean isQuotable) {

    
    
    
    
    this.isQuotable = isQuotable;
    return this;
  }

   /**
   * Get isQuotable
   * @return isQuotable
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "true", value = "")

  public Boolean getIsQuotable() {
    return isQuotable;
  }


  public void setIsQuotable(Boolean isQuotable) {

    
    
    
    this.isQuotable = isQuotable;
  }


  public OptionsSymbol isTradable(Boolean isTradable) {

    
    
    
    
    this.isTradable = isTradable;
    return this;
  }

   /**
   * Get isTradable
   * @return isTradable
  **/
  @javax.annotation.Nullable
  @ApiModelProperty(example = "true", value = "")

  public Boolean getIsTradable() {
    return isTradable;
  }


  public void setIsTradable(Boolean isTradable) {

    
    
    
    this.isTradable = isTradable;
  }

  /**
   * A container for additional, undeclared properties.
   * This is a holder for any undeclared properties as specified with
   * the 'additionalProperties' keyword in the OAS document.
   */
  private Map<String, Object> additionalProperties;

  /**
   * Set the additional (undeclared) property with the specified name and value.
   * If the property does not already exist, create it otherwise replace it.
   *
   * @param key name of the property
   * @param value value of the property
   * @return the OptionsSymbol instance itself
   */
  public OptionsSymbol putAdditionalProperty(String key, Object value) {
    if (this.additionalProperties == null) {
        this.additionalProperties = new HashMap<String, Object>();
    }
    this.additionalProperties.put(key, value);
    return this;
  }

  /**
   * Return the additional (undeclared) property.
   *
   * @return a map of objects
   */
  public Map<String, Object> getAdditionalProperties() {
    return additionalProperties;
  }

  /**
   * Return the additional (undeclared) property with the specified name.
   *
   * @param key name of the property
   * @return an object
   */
  public Object getAdditionalProperty(String key) {
    if (this.additionalProperties == null) {
        return null;
    }
    return this.additionalProperties.get(key);
  }


  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    OptionsSymbol optionsSymbol = (OptionsSymbol) o;
    return Objects.equals(this.id, optionsSymbol.id) &&
        Objects.equals(this.ticker, optionsSymbol.ticker) &&
        Objects.equals(this.strikePrice, optionsSymbol.strikePrice) &&
        Objects.equals(this.expirationDate, optionsSymbol.expirationDate) &&
        Objects.equals(this.isMiniOption, optionsSymbol.isMiniOption) &&
        Objects.equals(this.underlyingSymbol, optionsSymbol.underlyingSymbol) &&
        Objects.equals(this.localId, optionsSymbol.localId) &&
        Objects.equals(this.securityType, optionsSymbol.securityType) &&
        Objects.equals(this.listingExchange, optionsSymbol.listingExchange) &&
        Objects.equals(this.isQuotable, optionsSymbol.isQuotable) &&
        Objects.equals(this.isTradable, optionsSymbol.isTradable)&&
        Objects.equals(this.additionalProperties, optionsSymbol.additionalProperties);
  }

  private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> 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(id, ticker, strikePrice, expirationDate, isMiniOption, underlyingSymbol, localId, securityType, listingExchange, isQuotable, isTradable, additionalProperties);
  }

  private static <T> int hashCodeNullable(JsonNullable<T> 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 OptionsSymbol {\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    ticker: ").append(toIndentedString(ticker)).append("\n");
    sb.append("    strikePrice: ").append(toIndentedString(strikePrice)).append("\n");
    sb.append("    expirationDate: ").append(toIndentedString(expirationDate)).append("\n");
    sb.append("    isMiniOption: ").append(toIndentedString(isMiniOption)).append("\n");
    sb.append("    underlyingSymbol: ").append(toIndentedString(underlyingSymbol)).append("\n");
    sb.append("    localId: ").append(toIndentedString(localId)).append("\n");
    sb.append("    securityType: ").append(toIndentedString(securityType)).append("\n");
    sb.append("    listingExchange: ").append(toIndentedString(listingExchange)).append("\n");
    sb.append("    isQuotable: ").append(toIndentedString(isQuotable)).append("\n");
    sb.append("    isTradable: ").append(toIndentedString(isTradable)).append("\n");
    sb.append("    additionalProperties: ").append(toIndentedString(additionalProperties)).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<String> openapiFields;
  public static HashSet<String> openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet<String>();
    openapiFields.add("id");
    openapiFields.add("ticker");
    openapiFields.add("strike_price");
    openapiFields.add("expiration_date");
    openapiFields.add("is_mini_option");
    openapiFields.add("underlying_symbol");
    openapiFields.add("local_id");
    openapiFields.add("security_type");
    openapiFields.add("listing_exchange");
    openapiFields.add("is_quotable");
    openapiFields.add("is_tradable");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet<String>();
  }

 /**
  * Validates the JSON Object and throws an exception if issues found
  *
  * @param jsonObj JSON Object
  * @throws IOException if the JSON Object is invalid with respect to OptionsSymbol
  */
  public static void validateJsonObject(JsonObject jsonObj) throws IOException {
      if (jsonObj == null) {
        if (!OptionsSymbol.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in OptionsSymbol is not found in the empty JSON string", OptionsSymbol.openapiRequiredFields.toString()));
        }
      }
      if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString()));
      }
      if ((jsonObj.get("ticker") != null && !jsonObj.get("ticker").isJsonNull()) && !jsonObj.get("ticker").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `ticker` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ticker").toString()));
      }
      if ((jsonObj.get("expiration_date") != null && !jsonObj.get("expiration_date").isJsonNull()) && !jsonObj.get("expiration_date").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `expiration_date` to be a primitive type in the JSON string but got `%s`", jsonObj.get("expiration_date").toString()));
      }
      if ((jsonObj.get("local_id") != null && !jsonObj.get("local_id").isJsonNull()) && !jsonObj.get("local_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `local_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("local_id").toString()));
      }
  }

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

       return (TypeAdapter<T>) new TypeAdapter<OptionsSymbol>() {
           @Override
           public void write(JsonWriter out, OptionsSymbol value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             obj.remove("additionalProperties");
             // serialize additonal properties
             if (value.getAdditionalProperties() != null) {
               for (Map.Entry<String, Object> entry : value.getAdditionalProperties().entrySet()) {
                 if (entry.getValue() instanceof String)
                   obj.addProperty(entry.getKey(), (String) entry.getValue());
                 else if (entry.getValue() instanceof Number)
                   obj.addProperty(entry.getKey(), (Number) entry.getValue());
                 else if (entry.getValue() instanceof Boolean)
                   obj.addProperty(entry.getKey(), (Boolean) entry.getValue());
                 else if (entry.getValue() instanceof Character)
                   obj.addProperty(entry.getKey(), (Character) entry.getValue());
                 else {
                   obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
                 }
               }
             }
             elementAdapter.write(out, obj);
           }

           @Override
           public OptionsSymbol read(JsonReader in) throws IOException {
             JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
             validateJsonObject(jsonObj);
             // store additional fields in the deserialized instance
             OptionsSymbol instance = thisAdapter.fromJsonTree(jsonObj);
             for (Map.Entry<String, JsonElement> entry : jsonObj.entrySet()) {
               if (!openapiFields.contains(entry.getKey())) {
                 if (entry.getValue().isJsonPrimitive()) { // primitive type
                   if (entry.getValue().getAsJsonPrimitive().isString())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString());
                   else if (entry.getValue().getAsJsonPrimitive().isNumber())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber());
                   else if (entry.getValue().getAsJsonPrimitive().isBoolean())
                     instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean());
                   else
                     throw new IllegalArgumentException(String.format("The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString()));
                 } else if (entry.getValue().isJsonArray()) {
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class));
                 } else { // JSON object
                     instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class));
                 }
               }
             }
             return instance;
           }

       }.nullSafe();
    }
  }

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

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

