Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.VendorField;
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;
/**
* Mapping from a set of Vendor Fields to a LUSID core entity field
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class FieldMapping {
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 static final String SERIALIZED_NAME_ENTITY_TYPE = "entityType";
@SerializedName(SERIALIZED_NAME_ENTITY_TYPE)
private String entityType;
public static final String SERIALIZED_NAME_ENTITY_SUB_TYPE = "entitySubType";
@SerializedName(SERIALIZED_NAME_ENTITY_SUB_TYPE)
private String entitySubType;
public static final String SERIALIZED_NAME_VERSIONS = "versions";
@SerializedName(SERIALIZED_NAME_VERSIONS)
private List versions = new ArrayList<>();
public FieldMapping() {
}
public FieldMapping fieldName(String fieldName) {
this.fieldName = fieldName;
return this;
}
/**
* The LUSID core entity field
* @return fieldName
**/
@jakarta.annotation.Nonnull
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
public FieldMapping defaultValue(String defaultValue) {
this.defaultValue = defaultValue;
return this;
}
/**
* Default value if needed
* @return defaultValue
**/
@jakarta.annotation.Nullable
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public FieldMapping vendorFields(List vendorFields) {
this.vendorFields = vendorFields;
return this;
}
public FieldMapping addVendorFieldsItem(VendorField vendorFieldsItem) {
if (this.vendorFields == null) {
this.vendorFields = new ArrayList<>();
}
this.vendorFields.add(vendorFieldsItem);
return this;
}
/**
* Fields that will be used to map to this field
* @return vendorFields
**/
@jakarta.annotation.Nonnull
public List getVendorFields() {
return vendorFields;
}
public void setVendorFields(List vendorFields) {
this.vendorFields = vendorFields;
}
public FieldMapping transformationDescription(String transformationDescription) {
this.transformationDescription = transformationDescription;
return this;
}
/**
* The transformation, if required, to map from VendorFields to the LUSID Property
* @return transformationDescription
**/
@jakarta.annotation.Nullable
public String getTransformationDescription() {
return transformationDescription;
}
public void setTransformationDescription(String transformationDescription) {
this.transformationDescription = transformationDescription;
}
public FieldMapping entityType(String entityType) {
this.entityType = entityType;
return this;
}
/**
* The LUSID Entity this is valid for
* @return entityType
**/
@jakarta.annotation.Nonnull
public String getEntityType() {
return entityType;
}
public void setEntityType(String entityType) {
this.entityType = entityType;
}
public FieldMapping entitySubType(String entitySubType) {
this.entitySubType = entitySubType;
return this;
}
/**
* The LUSID Entity sub type this is valid for
* @return entitySubType
**/
@jakarta.annotation.Nullable
public String getEntitySubType() {
return entitySubType;
}
public void setEntitySubType(String entitySubType) {
this.entitySubType = entitySubType;
}
public FieldMapping versions(List versions) {
this.versions = versions;
return this;
}
public FieldMapping addVersionsItem(String versionsItem) {
if (this.versions == null) {
this.versions = new ArrayList<>();
}
this.versions.add(versionsItem);
return this;
}
/**
* The versions of the Vendor integration this mapping is valid for
* @return versions
**/
@jakarta.annotation.Nonnull
public List getVersions() {
return versions;
}
public void setVersions(List versions) {
this.versions = versions;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
FieldMapping fieldMapping = (FieldMapping) o;
return Objects.equals(this.fieldName, fieldMapping.fieldName) &&
Objects.equals(this.defaultValue, fieldMapping.defaultValue) &&
Objects.equals(this.vendorFields, fieldMapping.vendorFields) &&
Objects.equals(this.transformationDescription, fieldMapping.transformationDescription) &&
Objects.equals(this.entityType, fieldMapping.entityType) &&
Objects.equals(this.entitySubType, fieldMapping.entitySubType) &&
Objects.equals(this.versions, fieldMapping.versions);
}
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, entityType, entitySubType, versions);
}
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 FieldMapping {\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(" entityType: ").append(toIndentedString(entityType)).append("\n");
sb.append(" entitySubType: ").append(toIndentedString(entitySubType)).append("\n");
sb.append(" versions: ").append(toIndentedString(versions)).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");
openapiFields.add("entityType");
openapiFields.add("entitySubType");
openapiFields.add("versions");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("fieldName");
openapiRequiredFields.add("vendorFields");
openapiRequiredFields.add("entityType");
openapiRequiredFields.add("versions");
}
/**
* 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 FieldMapping
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!FieldMapping.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in FieldMapping is not found in the empty JSON string", FieldMapping.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : FieldMapping.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 json data is an array
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()));
}
JsonArray jsonArrayvendorFields = jsonObj.getAsJsonArray("vendorFields");
// validate the required field `vendorFields` (array)
for (int i = 0; i < jsonArrayvendorFields.size(); i++) {
VendorField.validateJsonElement(jsonArrayvendorFields.get(i));
};
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()));
}
if (!jsonObj.get("entityType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `entityType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("entityType").toString()));
}
if ((jsonObj.get("entitySubType") != null && !jsonObj.get("entitySubType").isJsonNull()) && !jsonObj.get("entitySubType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `entitySubType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("entitySubType").toString()));
}
// ensure the required json array is present
if (jsonObj.get("versions") == null) {
throw new IllegalArgumentException("Expected the field `linkedContent` to be an array in the JSON string but got `null`");
} else if (!jsonObj.get("versions").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `versions` to be an array in the JSON string but got `%s`", jsonObj.get("versions").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!FieldMapping.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'FieldMapping' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(FieldMapping.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, FieldMapping value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public FieldMapping read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of FieldMapping given an JSON string
*
* @param jsonString JSON string
* @return An instance of FieldMapping
* @throws IOException if the JSON string is invalid with respect to FieldMapping
*/
public static FieldMapping fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, FieldMapping.class);
}
/**
* Convert an instance of FieldMapping to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}