
com.finbourne.horizon.model.LusidField Maven / Gradle / Ivy
/*
* 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.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.ArrayList;
import java.util.Arrays;
import java.util.List;
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.horizon.JSON;
/**
* A field on a LUSID entity
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class LusidField {
public static final String SERIALIZED_NAME_FIELD_NAME = "fieldName";
@SerializedName(SERIALIZED_NAME_FIELD_NAME)
private String fieldName;
public static final String SERIALIZED_NAME_DEFAULT_VALUE = "defaultValue";
@SerializedName(SERIALIZED_NAME_DEFAULT_VALUE)
private String defaultValue;
public static final String SERIALIZED_NAME_VENDOR_FIELDS = "vendorFields";
@SerializedName(SERIALIZED_NAME_VENDOR_FIELDS)
private List vendorFields = new ArrayList<>();
public static final String SERIALIZED_NAME_TRANSFORMATION_DESCRIPTION = "transformationDescription";
@SerializedName(SERIALIZED_NAME_TRANSFORMATION_DESCRIPTION)
private String transformationDescription;
public LusidField() {
}
public LusidField fieldName(String fieldName) {
this.fieldName = fieldName;
return this;
}
/**
* The name of the LUSID field.
* @return fieldName
**/
@jakarta.annotation.Nonnull
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public LusidField defaultValue(String defaultValue) {
this.defaultValue = defaultValue;
return this;
}
/**
* The default value for the field.
* @return defaultValue
**/
@jakarta.annotation.Nullable
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public LusidField vendorFields(List vendorFields) {
this.vendorFields = vendorFields;
return this;
}
public LusidField addVendorFieldsItem(String vendorFieldsItem) {
if (this.vendorFields == null) {
this.vendorFields = new ArrayList<>();
}
this.vendorFields.add(vendorFieldsItem);
return this;
}
/**
* The underlying fields on the vendor package that contribute to this LUSID field
* @return vendorFields
**/
@jakarta.annotation.Nonnull
public List getVendorFields() {
return vendorFields;
}
public void setVendorFields(List vendorFields) {
this.vendorFields = vendorFields;
}
public LusidField transformationDescription(String transformationDescription) {
this.transformationDescription = transformationDescription;
return this;
}
/**
* A description of how the vendor package's field(s) get mapped to the LUSID field
* @return transformationDescription
**/
@jakarta.annotation.Nullable
public String getTransformationDescription() {
return transformationDescription;
}
public void setTransformationDescription(String transformationDescription) {
this.transformationDescription = transformationDescription;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
LusidField lusidField = (LusidField) o;
return Objects.equals(this.fieldName, lusidField.fieldName) &&
Objects.equals(this.defaultValue, lusidField.defaultValue) &&
Objects.equals(this.vendorFields, lusidField.vendorFields) &&
Objects.equals(this.transformationDescription, lusidField.transformationDescription);
}
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(fieldName, defaultValue, vendorFields, transformationDescription);
}
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 LusidField {\n");
sb.append(" fieldName: ").append(toIndentedString(fieldName)).append("\n");
sb.append(" defaultValue: ").append(toIndentedString(defaultValue)).append("\n");
sb.append(" vendorFields: ").append(toIndentedString(vendorFields)).append("\n");
sb.append(" transformationDescription: ").append(toIndentedString(transformationDescription)).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("fieldName");
openapiFields.add("defaultValue");
openapiFields.add("vendorFields");
openapiFields.add("transformationDescription");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("fieldName");
openapiRequiredFields.add("vendorFields");
}
/**
* 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 LusidField
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!LusidField.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in LusidField is not found in the empty JSON string", LusidField.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : LusidField.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("fieldName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `fieldName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("fieldName").toString()));
}
if ((jsonObj.get("defaultValue") != null && !jsonObj.get("defaultValue").isJsonNull()) && !jsonObj.get("defaultValue").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `defaultValue` to be a primitive type in the JSON string but got `%s`", jsonObj.get("defaultValue").toString()));
}
// ensure the required json array is present
if (jsonObj.get("vendorFields") == null) {
throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`");
} else if (!jsonObj.get("vendorFields").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `vendorFields` to be an array in the JSON string but got `%s`", jsonObj.get("vendorFields").toString()));
}
if ((jsonObj.get("transformationDescription") != null && !jsonObj.get("transformationDescription").isJsonNull()) && !jsonObj.get("transformationDescription").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `transformationDescription` to be a primitive type in the JSON string but got `%s`", jsonObj.get("transformationDescription").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!LusidField.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'LusidField' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(LusidField.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, LusidField value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public LusidField read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of LusidField given an JSON string
*
* @param jsonString JSON string
* @return An instance of LusidField
* @throws IOException if the JSON string is invalid with respect to LusidField
*/
public static LusidField fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, LusidField.class);
}
/**
* Convert an instance of LusidField to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy