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

com.finbourne.horizon.model.LusidPropertyToVendorFieldMapping 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.LusidPropertyDefinition;
import com.finbourne.horizon.model.Optionality;
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;

/**
 * The mapping of a LUSID Property from the Vendor Field that would populate it
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class LusidPropertyToVendorFieldMapping {
  public static final String SERIALIZED_NAME_PROPERTY = "property";
  @SerializedName(SERIALIZED_NAME_PROPERTY)
  private LusidPropertyDefinition property;

  public static final String SERIALIZED_NAME_VENDOR_FIELD = "vendorField";
  @SerializedName(SERIALIZED_NAME_VENDOR_FIELD)
  private String vendorField;

  public static final String SERIALIZED_NAME_VENDOR_PACKAGE = "vendorPackage";
  @SerializedName(SERIALIZED_NAME_VENDOR_PACKAGE)
  private String vendorPackage;

  public static final String SERIALIZED_NAME_VENDOR_NAMESPACE = "vendorNamespace";
  @SerializedName(SERIALIZED_NAME_VENDOR_NAMESPACE)
  private String vendorNamespace;

  public static final String SERIALIZED_NAME_OPTIONALITY = "optionality";
  @SerializedName(SERIALIZED_NAME_OPTIONALITY)
  private Optionality optionality;

  public LusidPropertyToVendorFieldMapping() {
  }

  public LusidPropertyToVendorFieldMapping property(LusidPropertyDefinition property) {
    
    this.property = property;
    return this;
  }

   /**
   * Get property
   * @return property
  **/
  @jakarta.annotation.Nonnull
  public LusidPropertyDefinition getProperty() {
    return property;
  }


  public void setProperty(LusidPropertyDefinition property) {
    this.property = property;
  }


  public LusidPropertyToVendorFieldMapping vendorField(String vendorField) {
    
    this.vendorField = vendorField;
    return this;
  }

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


  public void setVendorField(String vendorField) {
    this.vendorField = vendorField;
  }


  public LusidPropertyToVendorFieldMapping vendorPackage(String vendorPackage) {
    
    this.vendorPackage = vendorPackage;
    return this;
  }

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


  public void setVendorPackage(String vendorPackage) {
    this.vendorPackage = vendorPackage;
  }


  public LusidPropertyToVendorFieldMapping vendorNamespace(String vendorNamespace) {
    
    this.vendorNamespace = vendorNamespace;
    return this;
  }

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


  public void setVendorNamespace(String vendorNamespace) {
    this.vendorNamespace = vendorNamespace;
  }


  public LusidPropertyToVendorFieldMapping optionality(Optionality optionality) {
    
    this.optionality = optionality;
    return this;
  }

   /**
   * Get optionality
   * @return optionality
  **/
  @jakarta.annotation.Nonnull
  public Optionality getOptionality() {
    return optionality;
  }


  public void setOptionality(Optionality optionality) {
    this.optionality = optionality;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    LusidPropertyToVendorFieldMapping lusidPropertyToVendorFieldMapping = (LusidPropertyToVendorFieldMapping) o;
    return Objects.equals(this.property, lusidPropertyToVendorFieldMapping.property) &&
        Objects.equals(this.vendorField, lusidPropertyToVendorFieldMapping.vendorField) &&
        Objects.equals(this.vendorPackage, lusidPropertyToVendorFieldMapping.vendorPackage) &&
        Objects.equals(this.vendorNamespace, lusidPropertyToVendorFieldMapping.vendorNamespace) &&
        Objects.equals(this.optionality, lusidPropertyToVendorFieldMapping.optionality);
  }

  @Override
  public int hashCode() {
    return Objects.hash(property, vendorField, vendorPackage, vendorNamespace, optionality);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class LusidPropertyToVendorFieldMapping {\n");
    sb.append("    property: ").append(toIndentedString(property)).append("\n");
    sb.append("    vendorField: ").append(toIndentedString(vendorField)).append("\n");
    sb.append("    vendorPackage: ").append(toIndentedString(vendorPackage)).append("\n");
    sb.append("    vendorNamespace: ").append(toIndentedString(vendorNamespace)).append("\n");
    sb.append("    optionality: ").append(toIndentedString(optionality)).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("property");
    openapiFields.add("vendorField");
    openapiFields.add("vendorPackage");
    openapiFields.add("vendorNamespace");
    openapiFields.add("optionality");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
    openapiRequiredFields.add("property");
    openapiRequiredFields.add("vendorField");
    openapiRequiredFields.add("vendorPackage");
    openapiRequiredFields.add("vendorNamespace");
    openapiRequiredFields.add("optionality");
  }

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

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : LusidPropertyToVendorFieldMapping.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();
      // validate the required field `property`
      LusidPropertyDefinition.validateJsonElement(jsonObj.get("property"));
      if (!jsonObj.get("vendorField").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `vendorField` to be a primitive type in the JSON string but got `%s`", jsonObj.get("vendorField").toString()));
      }
      if (!jsonObj.get("vendorPackage").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `vendorPackage` to be a primitive type in the JSON string but got `%s`", jsonObj.get("vendorPackage").toString()));
      }
      if (!jsonObj.get("vendorNamespace").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `vendorNamespace` to be a primitive type in the JSON string but got `%s`", jsonObj.get("vendorNamespace").toString()));
      }
  }

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

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

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

       }.nullSafe();
    }
  }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy