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

com.finbourne.horizon.model.LusidPropertyDefinition Maven / Gradle / Ivy

The newest version!
/*
 * FINBOURNE Horizon 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.horizon.model;

import java.util.Objects;
import com.finbourne.horizon.model.ResourceId;
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 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.horizon.JSON;

/**
 * Defines the information in a LUSID Property Definition
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class LusidPropertyDefinition {
  public static final String SERIALIZED_NAME_KEY = "key";
  @SerializedName(SERIALIZED_NAME_KEY)
  private String key;

  public static final String SERIALIZED_NAME_PRODUCT_ENTITY_ITEM_KEY = "productEntityItemKey";
  @SerializedName(SERIALIZED_NAME_PRODUCT_ENTITY_ITEM_KEY)
  private String productEntityItemKey;

  public static final String SERIALIZED_NAME_DOMAIN = "domain";
  @SerializedName(SERIALIZED_NAME_DOMAIN)
  private String domain;

  public static final String SERIALIZED_NAME_SCOPE = "scope";
  @SerializedName(SERIALIZED_NAME_SCOPE)
  private String scope;

  public static final String SERIALIZED_NAME_CODE = "code";
  @SerializedName(SERIALIZED_NAME_CODE)
  private String code;

  public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName";
  @SerializedName(SERIALIZED_NAME_DISPLAY_NAME)
  private String displayName;

  public static final String SERIALIZED_NAME_DATA_TYPE_ID = "dataTypeId";
  @SerializedName(SERIALIZED_NAME_DATA_TYPE_ID)
  private ResourceId dataTypeId;

  public static final String SERIALIZED_NAME_DESCRIPTION = "description";
  @SerializedName(SERIALIZED_NAME_DESCRIPTION)
  private String description;

  public static final String SERIALIZED_NAME_LIFETIME = "lifetime";
  @SerializedName(SERIALIZED_NAME_LIFETIME)
  private String lifetime;

  public static final String SERIALIZED_NAME_CONSTRAINT_STYLE = "constraintStyle";
  @SerializedName(SERIALIZED_NAME_CONSTRAINT_STYLE)
  private String constraintStyle;

  public LusidPropertyDefinition() {
  }

  
  public LusidPropertyDefinition(
     String key
  ) {
    this();
    this.key = key;
  }

   /**
   * Get key
   * @return key
  **/
  @jakarta.annotation.Nonnull
  public String getKey() {
    return key;
  }




  public LusidPropertyDefinition productEntityItemKey(String productEntityItemKey) {
    
    this.productEntityItemKey = productEntityItemKey;
    return this;
  }

   /**
   * Property key associated with the mapping
   * @return productEntityItemKey
  **/
  @jakarta.annotation.Nonnull
  public String getProductEntityItemKey() {
    return productEntityItemKey;
  }


  public void setProductEntityItemKey(String productEntityItemKey) {
    this.productEntityItemKey = productEntityItemKey;
  }


  public LusidPropertyDefinition domain(String domain) {
    
    this.domain = domain;
    return this;
  }

   /**
   * The domain of this definition.
   * @return domain
  **/
  @jakarta.annotation.Nonnull
  public String getDomain() {
    return domain;
  }


  public void setDomain(String domain) {
    this.domain = domain;
  }


  public LusidPropertyDefinition scope(String scope) {
    
    this.scope = scope;
    return this;
  }

   /**
   * The scope of this definition.
   * @return scope
  **/
  @jakarta.annotation.Nonnull
  public String getScope() {
    return scope;
  }


  public void setScope(String scope) {
    this.scope = scope;
  }


  public LusidPropertyDefinition code(String code) {
    
    this.code = code;
    return this;
  }

   /**
   * The code of this definition.
   * @return code
  **/
  @jakarta.annotation.Nonnull
  public String getCode() {
    return code;
  }


  public void setCode(String code) {
    this.code = code;
  }


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

   /**
   * The name used when this definition is displayed.
   * @return displayName
  **/
  @jakarta.annotation.Nonnull
  public String getDisplayName() {
    return displayName;
  }


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


  public LusidPropertyDefinition dataTypeId(ResourceId dataTypeId) {
    
    this.dataTypeId = dataTypeId;
    return this;
  }

   /**
   * Get dataTypeId
   * @return dataTypeId
  **/
  @jakarta.annotation.Nonnull
  public ResourceId getDataTypeId() {
    return dataTypeId;
  }


  public void setDataTypeId(ResourceId dataTypeId) {
    this.dataTypeId = dataTypeId;
  }


  public LusidPropertyDefinition description(String description) {
    
    this.description = description;
    return this;
  }

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


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


  public LusidPropertyDefinition lifetime(String lifetime) {
    
    this.lifetime = lifetime;
    return this;
  }

   /**
   * 
   * @return lifetime
  **/
  @jakarta.annotation.Nonnull
  public String getLifetime() {
    return lifetime;
  }


  public void setLifetime(String lifetime) {
    this.lifetime = lifetime;
  }


  public LusidPropertyDefinition constraintStyle(String constraintStyle) {
    
    this.constraintStyle = constraintStyle;
    return this;
  }

   /**
   * 
   * @return constraintStyle
  **/
  @jakarta.annotation.Nonnull
  public String getConstraintStyle() {
    return constraintStyle;
  }


  public void setConstraintStyle(String constraintStyle) {
    this.constraintStyle = constraintStyle;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    LusidPropertyDefinition lusidPropertyDefinition = (LusidPropertyDefinition) o;
    return Objects.equals(this.key, lusidPropertyDefinition.key) &&
        Objects.equals(this.productEntityItemKey, lusidPropertyDefinition.productEntityItemKey) &&
        Objects.equals(this.domain, lusidPropertyDefinition.domain) &&
        Objects.equals(this.scope, lusidPropertyDefinition.scope) &&
        Objects.equals(this.code, lusidPropertyDefinition.code) &&
        Objects.equals(this.displayName, lusidPropertyDefinition.displayName) &&
        Objects.equals(this.dataTypeId, lusidPropertyDefinition.dataTypeId) &&
        Objects.equals(this.description, lusidPropertyDefinition.description) &&
        Objects.equals(this.lifetime, lusidPropertyDefinition.lifetime) &&
        Objects.equals(this.constraintStyle, lusidPropertyDefinition.constraintStyle);
  }

  @Override
  public int hashCode() {
    return Objects.hash(key, productEntityItemKey, domain, scope, code, displayName, dataTypeId, description, lifetime, constraintStyle);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class LusidPropertyDefinition {\n");
    sb.append("    key: ").append(toIndentedString(key)).append("\n");
    sb.append("    productEntityItemKey: ").append(toIndentedString(productEntityItemKey)).append("\n");
    sb.append("    domain: ").append(toIndentedString(domain)).append("\n");
    sb.append("    scope: ").append(toIndentedString(scope)).append("\n");
    sb.append("    code: ").append(toIndentedString(code)).append("\n");
    sb.append("    displayName: ").append(toIndentedString(displayName)).append("\n");
    sb.append("    dataTypeId: ").append(toIndentedString(dataTypeId)).append("\n");
    sb.append("    description: ").append(toIndentedString(description)).append("\n");
    sb.append("    lifetime: ").append(toIndentedString(lifetime)).append("\n");
    sb.append("    constraintStyle: ").append(toIndentedString(constraintStyle)).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("key");
    openapiFields.add("productEntityItemKey");
    openapiFields.add("domain");
    openapiFields.add("scope");
    openapiFields.add("code");
    openapiFields.add("displayName");
    openapiFields.add("dataTypeId");
    openapiFields.add("description");
    openapiFields.add("lifetime");
    openapiFields.add("constraintStyle");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
    openapiRequiredFields.add("key");
    openapiRequiredFields.add("productEntityItemKey");
    openapiRequiredFields.add("domain");
    openapiRequiredFields.add("scope");
    openapiRequiredFields.add("code");
    openapiRequiredFields.add("displayName");
    openapiRequiredFields.add("dataTypeId");
    openapiRequiredFields.add("description");
    openapiRequiredFields.add("lifetime");
    openapiRequiredFields.add("constraintStyle");
  }

 /**
  * 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 LusidPropertyDefinition
  */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!LusidPropertyDefinition.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in LusidPropertyDefinition is not found in the empty JSON string", LusidPropertyDefinition.openapiRequiredFields.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : LusidPropertyDefinition.openapiRequiredFields) {
        if (jsonElement.getAsJsonObject().get(requiredField) == null) {
          throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if (!jsonObj.get("key").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString()));
      }
      if (!jsonObj.get("productEntityItemKey").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `productEntityItemKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("productEntityItemKey").toString()));
      }
      if (!jsonObj.get("domain").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `domain` to be a primitive type in the JSON string but got `%s`", jsonObj.get("domain").toString()));
      }
      if (!jsonObj.get("scope").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `scope` to be a primitive type in the JSON string but got `%s`", jsonObj.get("scope").toString()));
      }
      if (!jsonObj.get("code").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString()));
      }
      if (!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()));
      }
      // validate the required field `dataTypeId`
      ResourceId.validateJsonElement(jsonObj.get("dataTypeId"));
      if (!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("lifetime").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `lifetime` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lifetime").toString()));
      }
      if (!jsonObj.get("constraintStyle").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `constraintStyle` to be a primitive type in the JSON string but got `%s`", jsonObj.get("constraintStyle").toString()));
      }
  }

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

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

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

       }.nullSafe();
    }
  }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy