diff --git a/.release.json b/.release.json index e5b52f1..9de5738 100644 --- a/.release.json +++ b/.release.json @@ -1,9 +1,9 @@ { "source": { "repo_url": "https://github.com/onfido/onfido-openapi-spec", - "short_sha": "a33e3b2", - "long_sha": "a33e3b25defea6110ec610051560df2c20bd1f65", - "version": "v3.4.0" + "short_sha": "08508b9", + "long_sha": "08508b9517238b3becb4265130633a418a8ee319", + "version": "v3.5.0" }, - "release": "v4.2.0" + "release": "v4.3.0" } diff --git a/README.md b/README.md index dbf01e8..b03976a 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Add this dependency to your project's POM: com.onfido onfido-api-java - 4.2.0 + 4.3.0 compile ``` @@ -59,7 +59,7 @@ Add this dependency to your project's build file: } dependencies { - implementation "com.onfido:onfido-api-java:4.2.0" + implementation "com.onfido:onfido-api-java:4.3.0" } ``` @@ -73,10 +73,10 @@ mvn clean package Then manually install the following JARs: -- `target/onfido-api-java-4.2.0.jar` +- `target/onfido-api-java-4.3.0.jar` - `target/lib/*.jar` -The latest version can be found at: https://search.maven.org/artifact/com.onfido/4.2.0 +The latest version can be found at: https://search.maven.org/artifact/com.onfido/4.3.0 ## Getting Started diff --git a/build.gradle b/build.gradle index ae5c847..223e05e 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ apply plugin: 'java' apply plugin: 'com.diffplug.spotless' group = 'com.onfido' -version = '4.2.0' +version = '4.3.0' buildscript { repositories { diff --git a/build.sbt b/build.sbt index 830d5db..db922de 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val root = (project in file(".")). settings( organization := "com.onfido", name := "onfido-api-java", - version := "4.2.0", + version := "4.3.0", scalaVersion := "2.11.4", scalacOptions ++= Seq("-feature"), javacOptions in compile ++= Seq("-Xlint:deprecation"), diff --git a/pom.xml b/pom.xml index 9017583..9362bc5 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ onfido-api-java jar onfido-api-java - 4.2.0 + 4.3.0 https://documentation.onfido.com Official Java API client library for the Onfido API diff --git a/src/main/java/com/onfido/ApiClient.java b/src/main/java/com/onfido/ApiClient.java index a2d309f..6886450 100644 --- a/src/main/java/com/onfido/ApiClient.java +++ b/src/main/java/com/onfido/ApiClient.java @@ -160,7 +160,7 @@ private void init() { json = new JSON(); // Set default User-Agent. - setUserAgent("onfido-java/4.2.0"); + setUserAgent("onfido-java/4.3.0"); authentications = new HashMap(); } diff --git a/src/main/java/com/onfido/Configuration.java b/src/main/java/com/onfido/Configuration.java index 5db1244..d5be14d 100644 --- a/src/main/java/com/onfido/Configuration.java +++ b/src/main/java/com/onfido/Configuration.java @@ -15,7 +15,7 @@ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") public class Configuration { - public static final String VERSION = "4.2.0"; + public static final String VERSION = "4.3.0"; private static ApiClient defaultApiClient = new ApiClient(); diff --git a/src/main/java/com/onfido/JSON.java b/src/main/java/com/onfido/JSON.java index 9544a47..dbd902d 100644 --- a/src/main/java/com/onfido/JSON.java +++ b/src/main/java/com/onfido/JSON.java @@ -385,6 +385,14 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistAmlReport.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedBreakdown.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedProperties.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedPropertiesRecordsInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerAddressInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerAliasInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerAssociateInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerAttributeInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerEventInner.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerSourceInner.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistEnhancedReport.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistMonitor.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.onfido.model.WatchlistMonitorBuilder.CustomTypeAdapterFactory()); diff --git a/src/main/java/com/onfido/model/WatchlistEnhancedProperties.java b/src/main/java/com/onfido/model/WatchlistEnhancedProperties.java index 9c16d3e..4776070 100644 --- a/src/main/java/com/onfido/model/WatchlistEnhancedProperties.java +++ b/src/main/java/com/onfido/model/WatchlistEnhancedProperties.java @@ -19,6 +19,7 @@ import com.google.gson.annotations.SerializedName; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; +import com.onfido.model.WatchlistEnhancedPropertiesRecordsInner; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; @@ -55,17 +56,17 @@ public class WatchlistEnhancedProperties { public static final String SERIALIZED_NAME_RECORDS = "records"; @SerializedName(SERIALIZED_NAME_RECORDS) - private List records = new ArrayList<>(); + private List records = new ArrayList<>(); public WatchlistEnhancedProperties() { } - public WatchlistEnhancedProperties records(List records) { + public WatchlistEnhancedProperties records(List records) { this.records = records; return this; } - public WatchlistEnhancedProperties addRecordsItem(String recordsItem) { + public WatchlistEnhancedProperties addRecordsItem(WatchlistEnhancedPropertiesRecordsInner recordsItem) { if (this.records == null) { this.records = new ArrayList<>(); } @@ -78,11 +79,11 @@ public WatchlistEnhancedProperties addRecordsItem(String recordsItem) { * @return records **/ @javax.annotation.Nullable - public List getRecords() { + public List getRecords() { return records; } - public void setRecords(List records) { + public void setRecords(List records) { this.records = records; } @@ -197,9 +198,19 @@ public static void validateJsonElement(JsonElement jsonElement) throws IOExcepti } } JsonObject jsonObj = jsonElement.getAsJsonObject(); - // ensure the optional json data is an array if present - if (jsonObj.get("records") != null && !jsonObj.get("records").isJsonNull() && !jsonObj.get("records").isJsonArray()) { - throw new IllegalArgumentException(String.format("Expected the field `records` to be an array in the JSON string but got `%s`", jsonObj.get("records").toString())); + if (jsonObj.get("records") != null && !jsonObj.get("records").isJsonNull()) { + JsonArray jsonArrayrecords = jsonObj.getAsJsonArray("records"); + if (jsonArrayrecords != null) { + // ensure the json data is an array + if (!jsonObj.get("records").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `records` to be an array in the JSON string but got `%s`", jsonObj.get("records").toString())); + } + + // validate the optional field `records` (array) + for (int i = 0; i < jsonArrayrecords.size(); i++) { + WatchlistEnhancedPropertiesRecordsInner.validateJsonElement(jsonArrayrecords.get(i)); + }; + } } } diff --git a/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInner.java b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInner.java new file mode 100644 index 0000000..4f9bdd5 --- /dev/null +++ b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInner.java @@ -0,0 +1,659 @@ +/* + * Onfido API v3.6 + * The Onfido API (v3.6) + * + * The version of the OpenAPI document: v3.6 + * + * + * 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.onfido.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 com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerAddressInner; +import com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerAliasInner; +import com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerAssociateInner; +import com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerAttributeInner; +import com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerEventInner; +import com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerSourceInner; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +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.Set; + +import com.onfido.JSON; + +/** + * WatchlistEnhancedPropertiesRecordsInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class WatchlistEnhancedPropertiesRecordsInner { + public static final String SERIALIZED_NAME_ADDRESS = "address"; + @SerializedName(SERIALIZED_NAME_ADDRESS) + private List address = new ArrayList<>(); + + public static final String SERIALIZED_NAME_ALIAS = "alias"; + @SerializedName(SERIALIZED_NAME_ALIAS) + private List alias = new ArrayList<>(); + + public static final String SERIALIZED_NAME_ASSOCIATE = "associate"; + @SerializedName(SERIALIZED_NAME_ASSOCIATE) + private List associate = new ArrayList<>(); + + public static final String SERIALIZED_NAME_ATTRIBUTE = "attribute"; + @SerializedName(SERIALIZED_NAME_ATTRIBUTE) + private List attribute = new ArrayList<>(); + + public static final String SERIALIZED_NAME_DATE_OF_BIRTH = "date_of_birth"; + @SerializedName(SERIALIZED_NAME_DATE_OF_BIRTH) + private List dateOfBirth = new ArrayList<>(); + + public static final String SERIALIZED_NAME_EVENT = "event"; + @SerializedName(SERIALIZED_NAME_EVENT) + private List event = new ArrayList<>(); + + public static final String SERIALIZED_NAME_FULL_NAME = "full_name"; + @SerializedName(SERIALIZED_NAME_FULL_NAME) + private String fullName; + + public static final String SERIALIZED_NAME_POSITION = "position"; + @SerializedName(SERIALIZED_NAME_POSITION) + private List position = new ArrayList<>(); + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + private List source = new ArrayList<>(); + + public WatchlistEnhancedPropertiesRecordsInner() { + } + + public WatchlistEnhancedPropertiesRecordsInner address(List address) { + this.address = address; + return this; + } + + public WatchlistEnhancedPropertiesRecordsInner addAddressItem(WatchlistEnhancedPropertiesRecordsInnerAddressInner addressItem) { + if (this.address == null) { + this.address = new ArrayList<>(); + } + this.address.add(addressItem); + return this; + } + + /** + * All addresses on file. + * @return address + **/ + @javax.annotation.Nullable + public List getAddress() { + return address; + } + + public void setAddress(List address) { + this.address = address; + } + + + public WatchlistEnhancedPropertiesRecordsInner alias(List alias) { + this.alias = alias; + return this; + } + + public WatchlistEnhancedPropertiesRecordsInner addAliasItem(WatchlistEnhancedPropertiesRecordsInnerAliasInner aliasItem) { + if (this.alias == null) { + this.alias = new ArrayList<>(); + } + this.alias.add(aliasItem); + return this; + } + + /** + * Any names that the person is also known as. + * @return alias + **/ + @javax.annotation.Nullable + public List getAlias() { + return alias; + } + + public void setAlias(List alias) { + this.alias = alias; + } + + + public WatchlistEnhancedPropertiesRecordsInner associate(List associate) { + this.associate = associate; + return this; + } + + public WatchlistEnhancedPropertiesRecordsInner addAssociateItem(WatchlistEnhancedPropertiesRecordsInnerAssociateInner associateItem) { + if (this.associate == null) { + this.associate = new ArrayList<>(); + } + this.associate.add(associateItem); + return this; + } + + /** + * Any linked persons, for example family relatives or business partners. + * @return associate + **/ + @javax.annotation.Nullable + public List getAssociate() { + return associate; + } + + public void setAssociate(List associate) { + this.associate = associate; + } + + + public WatchlistEnhancedPropertiesRecordsInner attribute(List attribute) { + this.attribute = attribute; + return this; + } + + public WatchlistEnhancedPropertiesRecordsInner addAttributeItem(WatchlistEnhancedPropertiesRecordsInnerAttributeInner attributeItem) { + if (this.attribute == null) { + this.attribute = new ArrayList<>(); + } + this.attribute.add(attributeItem); + return this; + } + + /** + * Information about the person, for example hair color or nationality. + * @return attribute + **/ + @javax.annotation.Nullable + public List getAttribute() { + return attribute; + } + + public void setAttribute(List attribute) { + this.attribute = attribute; + } + + + public WatchlistEnhancedPropertiesRecordsInner dateOfBirth(List dateOfBirth) { + this.dateOfBirth = dateOfBirth; + return this; + } + + public WatchlistEnhancedPropertiesRecordsInner addDateOfBirthItem(String dateOfBirthItem) { + if (this.dateOfBirth == null) { + this.dateOfBirth = new ArrayList<>(); + } + this.dateOfBirth.add(dateOfBirthItem); + return this; + } + + /** + * All the date of births on file. + * @return dateOfBirth + **/ + @javax.annotation.Nullable + public List getDateOfBirth() { + return dateOfBirth; + } + + public void setDateOfBirth(List dateOfBirth) { + this.dateOfBirth = dateOfBirth; + } + + + public WatchlistEnhancedPropertiesRecordsInner event(List event) { + this.event = event; + return this; + } + + public WatchlistEnhancedPropertiesRecordsInner addEventItem(WatchlistEnhancedPropertiesRecordsInnerEventInner eventItem) { + if (this.event == null) { + this.event = new ArrayList<>(); + } + this.event.add(eventItem); + return this; + } + + /** + * Information about events that have occurred to the person, for example deportation or arrest. + * @return event + **/ + @javax.annotation.Nullable + public List getEvent() { + return event; + } + + public void setEvent(List event) { + this.event = event; + } + + + public WatchlistEnhancedPropertiesRecordsInner fullName(String fullName) { + this.fullName = fullName; + return this; + } + + /** + * The name on file + * @return fullName + **/ + @javax.annotation.Nullable + public String getFullName() { + return fullName; + } + + public void setFullName(String fullName) { + this.fullName = fullName; + } + + + public WatchlistEnhancedPropertiesRecordsInner position(List position) { + this.position = position; + return this; + } + + public WatchlistEnhancedPropertiesRecordsInner addPositionItem(String positionItem) { + if (this.position == null) { + this.position = new ArrayList<>(); + } + this.position.add(positionItem); + return this; + } + + /** + * The role, country and date of each position. + * @return position + **/ + @javax.annotation.Nullable + public List getPosition() { + return position; + } + + public void setPosition(List position) { + this.position = position; + } + + + public WatchlistEnhancedPropertiesRecordsInner source(List source) { + this.source = source; + return this; + } + + public WatchlistEnhancedPropertiesRecordsInner addSourceItem(WatchlistEnhancedPropertiesRecordsInnerSourceInner sourceItem) { + if (this.source == null) { + this.source = new ArrayList<>(); + } + this.source.add(sourceItem); + return this; + } + + /** + * Details about where the information was obtained. + * @return source + **/ + @javax.annotation.Nullable + public List getSource() { + return source; + } + + public void setSource(List source) { + this.source = source; + } + + /** + * 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 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 WatchlistEnhancedPropertiesRecordsInner instance itself + */ + public WatchlistEnhancedPropertiesRecordsInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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; + } + WatchlistEnhancedPropertiesRecordsInner watchlistEnhancedPropertiesRecordsInner = (WatchlistEnhancedPropertiesRecordsInner) o; + return Objects.equals(this.address, watchlistEnhancedPropertiesRecordsInner.address) && + Objects.equals(this.alias, watchlistEnhancedPropertiesRecordsInner.alias) && + Objects.equals(this.associate, watchlistEnhancedPropertiesRecordsInner.associate) && + Objects.equals(this.attribute, watchlistEnhancedPropertiesRecordsInner.attribute) && + Objects.equals(this.dateOfBirth, watchlistEnhancedPropertiesRecordsInner.dateOfBirth) && + Objects.equals(this.event, watchlistEnhancedPropertiesRecordsInner.event) && + Objects.equals(this.fullName, watchlistEnhancedPropertiesRecordsInner.fullName) && + Objects.equals(this.position, watchlistEnhancedPropertiesRecordsInner.position) && + Objects.equals(this.source, watchlistEnhancedPropertiesRecordsInner.source)&& + Objects.equals(this.additionalProperties, watchlistEnhancedPropertiesRecordsInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(address, alias, associate, attribute, dateOfBirth, event, fullName, position, source, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WatchlistEnhancedPropertiesRecordsInner {\n"); + sb.append(" address: ").append(toIndentedString(address)).append("\n"); + sb.append(" alias: ").append(toIndentedString(alias)).append("\n"); + sb.append(" associate: ").append(toIndentedString(associate)).append("\n"); + sb.append(" attribute: ").append(toIndentedString(attribute)).append("\n"); + sb.append(" dateOfBirth: ").append(toIndentedString(dateOfBirth)).append("\n"); + sb.append(" event: ").append(toIndentedString(event)).append("\n"); + sb.append(" fullName: ").append(toIndentedString(fullName)).append("\n"); + sb.append(" position: ").append(toIndentedString(position)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).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 openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("address"); + openapiFields.add("alias"); + openapiFields.add("associate"); + openapiFields.add("attribute"); + openapiFields.add("date_of_birth"); + openapiFields.add("event"); + openapiFields.add("full_name"); + openapiFields.add("position"); + openapiFields.add("source"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 WatchlistEnhancedPropertiesRecordsInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WatchlistEnhancedPropertiesRecordsInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WatchlistEnhancedPropertiesRecordsInner is not found in the empty JSON string", WatchlistEnhancedPropertiesRecordsInner.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (jsonObj.get("address") != null && !jsonObj.get("address").isJsonNull()) { + JsonArray jsonArrayaddress = jsonObj.getAsJsonArray("address"); + if (jsonArrayaddress != null) { + // ensure the json data is an array + if (!jsonObj.get("address").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `address` to be an array in the JSON string but got `%s`", jsonObj.get("address").toString())); + } + + // validate the optional field `address` (array) + for (int i = 0; i < jsonArrayaddress.size(); i++) { + WatchlistEnhancedPropertiesRecordsInnerAddressInner.validateJsonElement(jsonArrayaddress.get(i)); + }; + } + } + if (jsonObj.get("alias") != null && !jsonObj.get("alias").isJsonNull()) { + JsonArray jsonArrayalias = jsonObj.getAsJsonArray("alias"); + if (jsonArrayalias != null) { + // ensure the json data is an array + if (!jsonObj.get("alias").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `alias` to be an array in the JSON string but got `%s`", jsonObj.get("alias").toString())); + } + + // validate the optional field `alias` (array) + for (int i = 0; i < jsonArrayalias.size(); i++) { + WatchlistEnhancedPropertiesRecordsInnerAliasInner.validateJsonElement(jsonArrayalias.get(i)); + }; + } + } + if (jsonObj.get("associate") != null && !jsonObj.get("associate").isJsonNull()) { + JsonArray jsonArrayassociate = jsonObj.getAsJsonArray("associate"); + if (jsonArrayassociate != null) { + // ensure the json data is an array + if (!jsonObj.get("associate").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `associate` to be an array in the JSON string but got `%s`", jsonObj.get("associate").toString())); + } + + // validate the optional field `associate` (array) + for (int i = 0; i < jsonArrayassociate.size(); i++) { + WatchlistEnhancedPropertiesRecordsInnerAssociateInner.validateJsonElement(jsonArrayassociate.get(i)); + }; + } + } + if (jsonObj.get("attribute") != null && !jsonObj.get("attribute").isJsonNull()) { + JsonArray jsonArrayattribute = jsonObj.getAsJsonArray("attribute"); + if (jsonArrayattribute != null) { + // ensure the json data is an array + if (!jsonObj.get("attribute").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `attribute` to be an array in the JSON string but got `%s`", jsonObj.get("attribute").toString())); + } + + // validate the optional field `attribute` (array) + for (int i = 0; i < jsonArrayattribute.size(); i++) { + WatchlistEnhancedPropertiesRecordsInnerAttributeInner.validateJsonElement(jsonArrayattribute.get(i)); + }; + } + } + // ensure the optional json data is an array if present + if (jsonObj.get("date_of_birth") != null && !jsonObj.get("date_of_birth").isJsonNull() && !jsonObj.get("date_of_birth").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `date_of_birth` to be an array in the JSON string but got `%s`", jsonObj.get("date_of_birth").toString())); + } + if (jsonObj.get("event") != null && !jsonObj.get("event").isJsonNull()) { + JsonArray jsonArrayevent = jsonObj.getAsJsonArray("event"); + if (jsonArrayevent != null) { + // ensure the json data is an array + if (!jsonObj.get("event").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `event` to be an array in the JSON string but got `%s`", jsonObj.get("event").toString())); + } + + // validate the optional field `event` (array) + for (int i = 0; i < jsonArrayevent.size(); i++) { + WatchlistEnhancedPropertiesRecordsInnerEventInner.validateJsonElement(jsonArrayevent.get(i)); + }; + } + } + if ((jsonObj.get("full_name") != null && !jsonObj.get("full_name").isJsonNull()) && !jsonObj.get("full_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `full_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("full_name").toString())); + } + // ensure the optional json data is an array if present + if (jsonObj.get("position") != null && !jsonObj.get("position").isJsonNull() && !jsonObj.get("position").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `position` to be an array in the JSON string but got `%s`", jsonObj.get("position").toString())); + } + if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { + JsonArray jsonArraysource = jsonObj.getAsJsonArray("source"); + if (jsonArraysource != null) { + // ensure the json data is an array + if (!jsonObj.get("source").isJsonArray()) { + throw new IllegalArgumentException(String.format("Expected the field `source` to be an array in the JSON string but got `%s`", jsonObj.get("source").toString())); + } + + // validate the optional field `source` (array) + for (int i = 0; i < jsonArraysource.size(); i++) { + WatchlistEnhancedPropertiesRecordsInnerSourceInner.validateJsonElement(jsonArraysource.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WatchlistEnhancedPropertiesRecordsInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WatchlistEnhancedPropertiesRecordsInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WatchlistEnhancedPropertiesRecordsInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WatchlistEnhancedPropertiesRecordsInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WatchlistEnhancedPropertiesRecordsInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WatchlistEnhancedPropertiesRecordsInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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 WatchlistEnhancedPropertiesRecordsInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of WatchlistEnhancedPropertiesRecordsInner + * @throws IOException if the JSON string is invalid with respect to WatchlistEnhancedPropertiesRecordsInner + */ + public static WatchlistEnhancedPropertiesRecordsInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WatchlistEnhancedPropertiesRecordsInner.class); + } + + /** + * Convert an instance of WatchlistEnhancedPropertiesRecordsInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAddressInner.java b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAddressInner.java new file mode 100644 index 0000000..0b69ba5 --- /dev/null +++ b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAddressInner.java @@ -0,0 +1,434 @@ +/* + * Onfido API v3.6 + * The Onfido API (v3.6) + * + * The version of the OpenAPI document: v3.6 + * + * + * 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.onfido.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 com.onfido.model.CountryCodes; +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.Set; + +import com.onfido.JSON; + +/** + * WatchlistEnhancedPropertiesRecordsInnerAddressInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class WatchlistEnhancedPropertiesRecordsInnerAddressInner { + public static final String SERIALIZED_NAME_ADDRESS_LINE1 = "address_line1"; + @SerializedName(SERIALIZED_NAME_ADDRESS_LINE1) + private String addressLine1; + + public static final String SERIALIZED_NAME_COUNTRY = "country"; + @SerializedName(SERIALIZED_NAME_COUNTRY) + private CountryCodes country; + + public static final String SERIALIZED_NAME_POSTAL_CODE = "postal_code"; + @SerializedName(SERIALIZED_NAME_POSTAL_CODE) + private String postalCode; + + public static final String SERIALIZED_NAME_STATE_PROVINCE = "state_province"; + @SerializedName(SERIALIZED_NAME_STATE_PROVINCE) + private String stateProvince; + + public static final String SERIALIZED_NAME_TOWN = "town"; + @SerializedName(SERIALIZED_NAME_TOWN) + private String town; + + public static final String SERIALIZED_NAME_LOCATOR_TYPE = "locator_type"; + @SerializedName(SERIALIZED_NAME_LOCATOR_TYPE) + private String locatorType; + + public WatchlistEnhancedPropertiesRecordsInnerAddressInner() { + } + + public WatchlistEnhancedPropertiesRecordsInnerAddressInner addressLine1(String addressLine1) { + this.addressLine1 = addressLine1; + return this; + } + + /** + * Get addressLine1 + * @return addressLine1 + **/ + @javax.annotation.Nullable + public String getAddressLine1() { + return addressLine1; + } + + public void setAddressLine1(String addressLine1) { + this.addressLine1 = addressLine1; + } + + + public WatchlistEnhancedPropertiesRecordsInnerAddressInner country(CountryCodes country) { + this.country = country; + return this; + } + + /** + * Get country + * @return country + **/ + @javax.annotation.Nullable + public CountryCodes getCountry() { + return country; + } + + public void setCountry(CountryCodes country) { + this.country = country; + } + + + public WatchlistEnhancedPropertiesRecordsInnerAddressInner postalCode(String postalCode) { + this.postalCode = postalCode; + return this; + } + + /** + * Get postalCode + * @return postalCode + **/ + @javax.annotation.Nullable + public String getPostalCode() { + return postalCode; + } + + public void setPostalCode(String postalCode) { + this.postalCode = postalCode; + } + + + public WatchlistEnhancedPropertiesRecordsInnerAddressInner stateProvince(String stateProvince) { + this.stateProvince = stateProvince; + return this; + } + + /** + * Get stateProvince + * @return stateProvince + **/ + @javax.annotation.Nullable + public String getStateProvince() { + return stateProvince; + } + + public void setStateProvince(String stateProvince) { + this.stateProvince = stateProvince; + } + + + public WatchlistEnhancedPropertiesRecordsInnerAddressInner town(String town) { + this.town = town; + return this; + } + + /** + * Get town + * @return town + **/ + @javax.annotation.Nullable + public String getTown() { + return town; + } + + public void setTown(String town) { + this.town = town; + } + + + public WatchlistEnhancedPropertiesRecordsInnerAddressInner locatorType(String locatorType) { + this.locatorType = locatorType; + return this; + } + + /** + * Get locatorType + * @return locatorType + **/ + @javax.annotation.Nullable + public String getLocatorType() { + return locatorType; + } + + public void setLocatorType(String locatorType) { + this.locatorType = locatorType; + } + + /** + * 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 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 WatchlistEnhancedPropertiesRecordsInnerAddressInner instance itself + */ + public WatchlistEnhancedPropertiesRecordsInnerAddressInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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; + } + WatchlistEnhancedPropertiesRecordsInnerAddressInner watchlistEnhancedPropertiesRecordsInnerAddressInner = (WatchlistEnhancedPropertiesRecordsInnerAddressInner) o; + return Objects.equals(this.addressLine1, watchlistEnhancedPropertiesRecordsInnerAddressInner.addressLine1) && + Objects.equals(this.country, watchlistEnhancedPropertiesRecordsInnerAddressInner.country) && + Objects.equals(this.postalCode, watchlistEnhancedPropertiesRecordsInnerAddressInner.postalCode) && + Objects.equals(this.stateProvince, watchlistEnhancedPropertiesRecordsInnerAddressInner.stateProvince) && + Objects.equals(this.town, watchlistEnhancedPropertiesRecordsInnerAddressInner.town) && + Objects.equals(this.locatorType, watchlistEnhancedPropertiesRecordsInnerAddressInner.locatorType)&& + Objects.equals(this.additionalProperties, watchlistEnhancedPropertiesRecordsInnerAddressInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(addressLine1, country, postalCode, stateProvince, town, locatorType, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WatchlistEnhancedPropertiesRecordsInnerAddressInner {\n"); + sb.append(" addressLine1: ").append(toIndentedString(addressLine1)).append("\n"); + sb.append(" country: ").append(toIndentedString(country)).append("\n"); + sb.append(" postalCode: ").append(toIndentedString(postalCode)).append("\n"); + sb.append(" stateProvince: ").append(toIndentedString(stateProvince)).append("\n"); + sb.append(" town: ").append(toIndentedString(town)).append("\n"); + sb.append(" locatorType: ").append(toIndentedString(locatorType)).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 openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("address_line1"); + openapiFields.add("country"); + openapiFields.add("postal_code"); + openapiFields.add("state_province"); + openapiFields.add("town"); + openapiFields.add("locator_type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 WatchlistEnhancedPropertiesRecordsInnerAddressInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WatchlistEnhancedPropertiesRecordsInnerAddressInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WatchlistEnhancedPropertiesRecordsInnerAddressInner is not found in the empty JSON string", WatchlistEnhancedPropertiesRecordsInnerAddressInner.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("address_line1") != null && !jsonObj.get("address_line1").isJsonNull()) && !jsonObj.get("address_line1").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `address_line1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_line1").toString())); + } + // validate the optional field `country` + if (jsonObj.get("country") != null && !jsonObj.get("country").isJsonNull()) { + CountryCodes.validateJsonElement(jsonObj.get("country")); + } + if ((jsonObj.get("postal_code") != null && !jsonObj.get("postal_code").isJsonNull()) && !jsonObj.get("postal_code").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `postal_code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("postal_code").toString())); + } + if ((jsonObj.get("state_province") != null && !jsonObj.get("state_province").isJsonNull()) && !jsonObj.get("state_province").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `state_province` to be a primitive type in the JSON string but got `%s`", jsonObj.get("state_province").toString())); + } + if ((jsonObj.get("town") != null && !jsonObj.get("town").isJsonNull()) && !jsonObj.get("town").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `town` to be a primitive type in the JSON string but got `%s`", jsonObj.get("town").toString())); + } + if ((jsonObj.get("locator_type") != null && !jsonObj.get("locator_type").isJsonNull()) && !jsonObj.get("locator_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `locator_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("locator_type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WatchlistEnhancedPropertiesRecordsInnerAddressInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WatchlistEnhancedPropertiesRecordsInnerAddressInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WatchlistEnhancedPropertiesRecordsInnerAddressInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WatchlistEnhancedPropertiesRecordsInnerAddressInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WatchlistEnhancedPropertiesRecordsInnerAddressInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WatchlistEnhancedPropertiesRecordsInnerAddressInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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 WatchlistEnhancedPropertiesRecordsInnerAddressInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of WatchlistEnhancedPropertiesRecordsInnerAddressInner + * @throws IOException if the JSON string is invalid with respect to WatchlistEnhancedPropertiesRecordsInnerAddressInner + */ + public static WatchlistEnhancedPropertiesRecordsInnerAddressInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WatchlistEnhancedPropertiesRecordsInnerAddressInner.class); + } + + /** + * Convert an instance of WatchlistEnhancedPropertiesRecordsInnerAddressInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAliasInner.java b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAliasInner.java new file mode 100644 index 0000000..3903f7f --- /dev/null +++ b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAliasInner.java @@ -0,0 +1,316 @@ +/* + * Onfido API v3.6 + * The Onfido API (v3.6) + * + * The version of the OpenAPI document: v3.6 + * + * + * 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.onfido.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.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.Set; + +import com.onfido.JSON; + +/** + * WatchlistEnhancedPropertiesRecordsInnerAliasInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class WatchlistEnhancedPropertiesRecordsInnerAliasInner { + public static final String SERIALIZED_NAME_ALIAS_NAME = "alias_name"; + @SerializedName(SERIALIZED_NAME_ALIAS_NAME) + private String aliasName; + + public static final String SERIALIZED_NAME_ALIAS_TYPE = "alias_type"; + @SerializedName(SERIALIZED_NAME_ALIAS_TYPE) + private String aliasType; + + public WatchlistEnhancedPropertiesRecordsInnerAliasInner() { + } + + public WatchlistEnhancedPropertiesRecordsInnerAliasInner aliasName(String aliasName) { + this.aliasName = aliasName; + return this; + } + + /** + * Get aliasName + * @return aliasName + **/ + @javax.annotation.Nullable + public String getAliasName() { + return aliasName; + } + + public void setAliasName(String aliasName) { + this.aliasName = aliasName; + } + + + public WatchlistEnhancedPropertiesRecordsInnerAliasInner aliasType(String aliasType) { + this.aliasType = aliasType; + return this; + } + + /** + * Get aliasType + * @return aliasType + **/ + @javax.annotation.Nullable + public String getAliasType() { + return aliasType; + } + + public void setAliasType(String aliasType) { + this.aliasType = aliasType; + } + + /** + * 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 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 WatchlistEnhancedPropertiesRecordsInnerAliasInner instance itself + */ + public WatchlistEnhancedPropertiesRecordsInnerAliasInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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; + } + WatchlistEnhancedPropertiesRecordsInnerAliasInner watchlistEnhancedPropertiesRecordsInnerAliasInner = (WatchlistEnhancedPropertiesRecordsInnerAliasInner) o; + return Objects.equals(this.aliasName, watchlistEnhancedPropertiesRecordsInnerAliasInner.aliasName) && + Objects.equals(this.aliasType, watchlistEnhancedPropertiesRecordsInnerAliasInner.aliasType)&& + Objects.equals(this.additionalProperties, watchlistEnhancedPropertiesRecordsInnerAliasInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(aliasName, aliasType, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WatchlistEnhancedPropertiesRecordsInnerAliasInner {\n"); + sb.append(" aliasName: ").append(toIndentedString(aliasName)).append("\n"); + sb.append(" aliasType: ").append(toIndentedString(aliasType)).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 openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("alias_name"); + openapiFields.add("alias_type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 WatchlistEnhancedPropertiesRecordsInnerAliasInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WatchlistEnhancedPropertiesRecordsInnerAliasInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WatchlistEnhancedPropertiesRecordsInnerAliasInner is not found in the empty JSON string", WatchlistEnhancedPropertiesRecordsInnerAliasInner.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("alias_name") != null && !jsonObj.get("alias_name").isJsonNull()) && !jsonObj.get("alias_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `alias_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("alias_name").toString())); + } + if ((jsonObj.get("alias_type") != null && !jsonObj.get("alias_type").isJsonNull()) && !jsonObj.get("alias_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `alias_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("alias_type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WatchlistEnhancedPropertiesRecordsInnerAliasInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WatchlistEnhancedPropertiesRecordsInnerAliasInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WatchlistEnhancedPropertiesRecordsInnerAliasInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WatchlistEnhancedPropertiesRecordsInnerAliasInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WatchlistEnhancedPropertiesRecordsInnerAliasInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WatchlistEnhancedPropertiesRecordsInnerAliasInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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 WatchlistEnhancedPropertiesRecordsInnerAliasInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of WatchlistEnhancedPropertiesRecordsInnerAliasInner + * @throws IOException if the JSON string is invalid with respect to WatchlistEnhancedPropertiesRecordsInnerAliasInner + */ + public static WatchlistEnhancedPropertiesRecordsInnerAliasInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WatchlistEnhancedPropertiesRecordsInnerAliasInner.class); + } + + /** + * Convert an instance of WatchlistEnhancedPropertiesRecordsInnerAliasInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAssociateInner.java b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAssociateInner.java new file mode 100644 index 0000000..d37019c --- /dev/null +++ b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAssociateInner.java @@ -0,0 +1,345 @@ +/* + * Onfido API v3.6 + * The Onfido API (v3.6) + * + * The version of the OpenAPI document: v3.6 + * + * + * 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.onfido.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.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.Set; + +import com.onfido.JSON; + +/** + * WatchlistEnhancedPropertiesRecordsInnerAssociateInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class WatchlistEnhancedPropertiesRecordsInnerAssociateInner { + public static final String SERIALIZED_NAME_ENTITY_NAME = "entity_name"; + @SerializedName(SERIALIZED_NAME_ENTITY_NAME) + private String entityName; + + public static final String SERIALIZED_NAME_RELATIONSHIP_DIRECTION = "relationship_direction"; + @SerializedName(SERIALIZED_NAME_RELATIONSHIP_DIRECTION) + private String relationshipDirection; + + public static final String SERIALIZED_NAME_RELATIONSHIP_TYPE = "relationship_type"; + @SerializedName(SERIALIZED_NAME_RELATIONSHIP_TYPE) + private String relationshipType; + + public WatchlistEnhancedPropertiesRecordsInnerAssociateInner() { + } + + public WatchlistEnhancedPropertiesRecordsInnerAssociateInner entityName(String entityName) { + this.entityName = entityName; + return this; + } + + /** + * Get entityName + * @return entityName + **/ + @javax.annotation.Nullable + public String getEntityName() { + return entityName; + } + + public void setEntityName(String entityName) { + this.entityName = entityName; + } + + + public WatchlistEnhancedPropertiesRecordsInnerAssociateInner relationshipDirection(String relationshipDirection) { + this.relationshipDirection = relationshipDirection; + return this; + } + + /** + * Get relationshipDirection + * @return relationshipDirection + **/ + @javax.annotation.Nullable + public String getRelationshipDirection() { + return relationshipDirection; + } + + public void setRelationshipDirection(String relationshipDirection) { + this.relationshipDirection = relationshipDirection; + } + + + public WatchlistEnhancedPropertiesRecordsInnerAssociateInner relationshipType(String relationshipType) { + this.relationshipType = relationshipType; + return this; + } + + /** + * Get relationshipType + * @return relationshipType + **/ + @javax.annotation.Nullable + public String getRelationshipType() { + return relationshipType; + } + + public void setRelationshipType(String relationshipType) { + this.relationshipType = relationshipType; + } + + /** + * 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 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 WatchlistEnhancedPropertiesRecordsInnerAssociateInner instance itself + */ + public WatchlistEnhancedPropertiesRecordsInnerAssociateInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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; + } + WatchlistEnhancedPropertiesRecordsInnerAssociateInner watchlistEnhancedPropertiesRecordsInnerAssociateInner = (WatchlistEnhancedPropertiesRecordsInnerAssociateInner) o; + return Objects.equals(this.entityName, watchlistEnhancedPropertiesRecordsInnerAssociateInner.entityName) && + Objects.equals(this.relationshipDirection, watchlistEnhancedPropertiesRecordsInnerAssociateInner.relationshipDirection) && + Objects.equals(this.relationshipType, watchlistEnhancedPropertiesRecordsInnerAssociateInner.relationshipType)&& + Objects.equals(this.additionalProperties, watchlistEnhancedPropertiesRecordsInnerAssociateInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(entityName, relationshipDirection, relationshipType, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WatchlistEnhancedPropertiesRecordsInnerAssociateInner {\n"); + sb.append(" entityName: ").append(toIndentedString(entityName)).append("\n"); + sb.append(" relationshipDirection: ").append(toIndentedString(relationshipDirection)).append("\n"); + sb.append(" relationshipType: ").append(toIndentedString(relationshipType)).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 openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("entity_name"); + openapiFields.add("relationship_direction"); + openapiFields.add("relationship_type"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 WatchlistEnhancedPropertiesRecordsInnerAssociateInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WatchlistEnhancedPropertiesRecordsInnerAssociateInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WatchlistEnhancedPropertiesRecordsInnerAssociateInner is not found in the empty JSON string", WatchlistEnhancedPropertiesRecordsInnerAssociateInner.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("entity_name") != null && !jsonObj.get("entity_name").isJsonNull()) && !jsonObj.get("entity_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `entity_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("entity_name").toString())); + } + if ((jsonObj.get("relationship_direction") != null && !jsonObj.get("relationship_direction").isJsonNull()) && !jsonObj.get("relationship_direction").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `relationship_direction` to be a primitive type in the JSON string but got `%s`", jsonObj.get("relationship_direction").toString())); + } + if ((jsonObj.get("relationship_type") != null && !jsonObj.get("relationship_type").isJsonNull()) && !jsonObj.get("relationship_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `relationship_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("relationship_type").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WatchlistEnhancedPropertiesRecordsInnerAssociateInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WatchlistEnhancedPropertiesRecordsInnerAssociateInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WatchlistEnhancedPropertiesRecordsInnerAssociateInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WatchlistEnhancedPropertiesRecordsInnerAssociateInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WatchlistEnhancedPropertiesRecordsInnerAssociateInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WatchlistEnhancedPropertiesRecordsInnerAssociateInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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 WatchlistEnhancedPropertiesRecordsInnerAssociateInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of WatchlistEnhancedPropertiesRecordsInnerAssociateInner + * @throws IOException if the JSON string is invalid with respect to WatchlistEnhancedPropertiesRecordsInnerAssociateInner + */ + public static WatchlistEnhancedPropertiesRecordsInnerAssociateInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WatchlistEnhancedPropertiesRecordsInnerAssociateInner.class); + } + + /** + * Convert an instance of WatchlistEnhancedPropertiesRecordsInnerAssociateInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAttributeInner.java b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAttributeInner.java new file mode 100644 index 0000000..9609d44 --- /dev/null +++ b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerAttributeInner.java @@ -0,0 +1,316 @@ +/* + * Onfido API v3.6 + * The Onfido API (v3.6) + * + * The version of the OpenAPI document: v3.6 + * + * + * 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.onfido.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.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.Set; + +import com.onfido.JSON; + +/** + * WatchlistEnhancedPropertiesRecordsInnerAttributeInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class WatchlistEnhancedPropertiesRecordsInnerAttributeInner { + public static final String SERIALIZED_NAME_ATTRIBUTE_TYPE = "attribute_type"; + @SerializedName(SERIALIZED_NAME_ATTRIBUTE_TYPE) + private String attributeType; + + public static final String SERIALIZED_NAME_ATTRIBUTE_VALUE = "attribute_value"; + @SerializedName(SERIALIZED_NAME_ATTRIBUTE_VALUE) + private String attributeValue; + + public WatchlistEnhancedPropertiesRecordsInnerAttributeInner() { + } + + public WatchlistEnhancedPropertiesRecordsInnerAttributeInner attributeType(String attributeType) { + this.attributeType = attributeType; + return this; + } + + /** + * Get attributeType + * @return attributeType + **/ + @javax.annotation.Nullable + public String getAttributeType() { + return attributeType; + } + + public void setAttributeType(String attributeType) { + this.attributeType = attributeType; + } + + + public WatchlistEnhancedPropertiesRecordsInnerAttributeInner attributeValue(String attributeValue) { + this.attributeValue = attributeValue; + return this; + } + + /** + * Get attributeValue + * @return attributeValue + **/ + @javax.annotation.Nullable + public String getAttributeValue() { + return attributeValue; + } + + public void setAttributeValue(String attributeValue) { + this.attributeValue = attributeValue; + } + + /** + * 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 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 WatchlistEnhancedPropertiesRecordsInnerAttributeInner instance itself + */ + public WatchlistEnhancedPropertiesRecordsInnerAttributeInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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; + } + WatchlistEnhancedPropertiesRecordsInnerAttributeInner watchlistEnhancedPropertiesRecordsInnerAttributeInner = (WatchlistEnhancedPropertiesRecordsInnerAttributeInner) o; + return Objects.equals(this.attributeType, watchlistEnhancedPropertiesRecordsInnerAttributeInner.attributeType) && + Objects.equals(this.attributeValue, watchlistEnhancedPropertiesRecordsInnerAttributeInner.attributeValue)&& + Objects.equals(this.additionalProperties, watchlistEnhancedPropertiesRecordsInnerAttributeInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(attributeType, attributeValue, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WatchlistEnhancedPropertiesRecordsInnerAttributeInner {\n"); + sb.append(" attributeType: ").append(toIndentedString(attributeType)).append("\n"); + sb.append(" attributeValue: ").append(toIndentedString(attributeValue)).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 openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("attribute_type"); + openapiFields.add("attribute_value"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 WatchlistEnhancedPropertiesRecordsInnerAttributeInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WatchlistEnhancedPropertiesRecordsInnerAttributeInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WatchlistEnhancedPropertiesRecordsInnerAttributeInner is not found in the empty JSON string", WatchlistEnhancedPropertiesRecordsInnerAttributeInner.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("attribute_type") != null && !jsonObj.get("attribute_type").isJsonNull()) && !jsonObj.get("attribute_type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `attribute_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("attribute_type").toString())); + } + if ((jsonObj.get("attribute_value") != null && !jsonObj.get("attribute_value").isJsonNull()) && !jsonObj.get("attribute_value").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `attribute_value` to be a primitive type in the JSON string but got `%s`", jsonObj.get("attribute_value").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WatchlistEnhancedPropertiesRecordsInnerAttributeInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WatchlistEnhancedPropertiesRecordsInnerAttributeInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WatchlistEnhancedPropertiesRecordsInnerAttributeInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WatchlistEnhancedPropertiesRecordsInnerAttributeInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WatchlistEnhancedPropertiesRecordsInnerAttributeInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WatchlistEnhancedPropertiesRecordsInnerAttributeInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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 WatchlistEnhancedPropertiesRecordsInnerAttributeInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of WatchlistEnhancedPropertiesRecordsInnerAttributeInner + * @throws IOException if the JSON string is invalid with respect to WatchlistEnhancedPropertiesRecordsInnerAttributeInner + */ + public static WatchlistEnhancedPropertiesRecordsInnerAttributeInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WatchlistEnhancedPropertiesRecordsInnerAttributeInner.class); + } + + /** + * Convert an instance of WatchlistEnhancedPropertiesRecordsInnerAttributeInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerEventInner.java b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerEventInner.java new file mode 100644 index 0000000..f0b3828 --- /dev/null +++ b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerEventInner.java @@ -0,0 +1,403 @@ +/* + * Onfido API v3.6 + * The Onfido API (v3.6) + * + * The version of the OpenAPI document: v3.6 + * + * + * 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.onfido.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 com.onfido.model.WatchlistEnhancedPropertiesRecordsInnerEventInnerSource; +import java.io.IOException; +import java.time.LocalDate; +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.Set; + +import com.onfido.JSON; + +/** + * WatchlistEnhancedPropertiesRecordsInnerEventInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class WatchlistEnhancedPropertiesRecordsInnerEventInner { + public static final String SERIALIZED_NAME_CATEGORY = "category"; + @SerializedName(SERIALIZED_NAME_CATEGORY) + private String category; + + public static final String SERIALIZED_NAME_EVENT_DATE = "event_date"; + @SerializedName(SERIALIZED_NAME_EVENT_DATE) + private LocalDate eventDate; + + public static final String SERIALIZED_NAME_EVENT_DESCRIPTION = "event_description"; + @SerializedName(SERIALIZED_NAME_EVENT_DESCRIPTION) + private String eventDescription; + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + private WatchlistEnhancedPropertiesRecordsInnerEventInnerSource source; + + public static final String SERIALIZED_NAME_SUB_CATEGORY = "sub_category"; + @SerializedName(SERIALIZED_NAME_SUB_CATEGORY) + private String subCategory; + + public WatchlistEnhancedPropertiesRecordsInnerEventInner() { + } + + public WatchlistEnhancedPropertiesRecordsInnerEventInner category(String category) { + this.category = category; + return this; + } + + /** + * Get category + * @return category + **/ + @javax.annotation.Nullable + public String getCategory() { + return category; + } + + public void setCategory(String category) { + this.category = category; + } + + + public WatchlistEnhancedPropertiesRecordsInnerEventInner eventDate(LocalDate eventDate) { + this.eventDate = eventDate; + return this; + } + + /** + * Get eventDate + * @return eventDate + **/ + @javax.annotation.Nullable + public LocalDate getEventDate() { + return eventDate; + } + + public void setEventDate(LocalDate eventDate) { + this.eventDate = eventDate; + } + + + public WatchlistEnhancedPropertiesRecordsInnerEventInner eventDescription(String eventDescription) { + this.eventDescription = eventDescription; + return this; + } + + /** + * Get eventDescription + * @return eventDescription + **/ + @javax.annotation.Nullable + public String getEventDescription() { + return eventDescription; + } + + public void setEventDescription(String eventDescription) { + this.eventDescription = eventDescription; + } + + + public WatchlistEnhancedPropertiesRecordsInnerEventInner source(WatchlistEnhancedPropertiesRecordsInnerEventInnerSource source) { + this.source = source; + return this; + } + + /** + * Get source + * @return source + **/ + @javax.annotation.Nullable + public WatchlistEnhancedPropertiesRecordsInnerEventInnerSource getSource() { + return source; + } + + public void setSource(WatchlistEnhancedPropertiesRecordsInnerEventInnerSource source) { + this.source = source; + } + + + public WatchlistEnhancedPropertiesRecordsInnerEventInner subCategory(String subCategory) { + this.subCategory = subCategory; + return this; + } + + /** + * Get subCategory + * @return subCategory + **/ + @javax.annotation.Nullable + public String getSubCategory() { + return subCategory; + } + + public void setSubCategory(String subCategory) { + this.subCategory = subCategory; + } + + /** + * 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 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 WatchlistEnhancedPropertiesRecordsInnerEventInner instance itself + */ + public WatchlistEnhancedPropertiesRecordsInnerEventInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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; + } + WatchlistEnhancedPropertiesRecordsInnerEventInner watchlistEnhancedPropertiesRecordsInnerEventInner = (WatchlistEnhancedPropertiesRecordsInnerEventInner) o; + return Objects.equals(this.category, watchlistEnhancedPropertiesRecordsInnerEventInner.category) && + Objects.equals(this.eventDate, watchlistEnhancedPropertiesRecordsInnerEventInner.eventDate) && + Objects.equals(this.eventDescription, watchlistEnhancedPropertiesRecordsInnerEventInner.eventDescription) && + Objects.equals(this.source, watchlistEnhancedPropertiesRecordsInnerEventInner.source) && + Objects.equals(this.subCategory, watchlistEnhancedPropertiesRecordsInnerEventInner.subCategory)&& + Objects.equals(this.additionalProperties, watchlistEnhancedPropertiesRecordsInnerEventInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(category, eventDate, eventDescription, source, subCategory, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WatchlistEnhancedPropertiesRecordsInnerEventInner {\n"); + sb.append(" category: ").append(toIndentedString(category)).append("\n"); + sb.append(" eventDate: ").append(toIndentedString(eventDate)).append("\n"); + sb.append(" eventDescription: ").append(toIndentedString(eventDescription)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" subCategory: ").append(toIndentedString(subCategory)).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 openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("category"); + openapiFields.add("event_date"); + openapiFields.add("event_description"); + openapiFields.add("source"); + openapiFields.add("sub_category"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 WatchlistEnhancedPropertiesRecordsInnerEventInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WatchlistEnhancedPropertiesRecordsInnerEventInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WatchlistEnhancedPropertiesRecordsInnerEventInner is not found in the empty JSON string", WatchlistEnhancedPropertiesRecordsInnerEventInner.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("category") != null && !jsonObj.get("category").isJsonNull()) && !jsonObj.get("category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category").toString())); + } + if ((jsonObj.get("event_description") != null && !jsonObj.get("event_description").isJsonNull()) && !jsonObj.get("event_description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `event_description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("event_description").toString())); + } + // validate the optional field `source` + if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { + WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.validateJsonElement(jsonObj.get("source")); + } + if ((jsonObj.get("sub_category") != null && !jsonObj.get("sub_category").isJsonNull()) && !jsonObj.get("sub_category").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `sub_category` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sub_category").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WatchlistEnhancedPropertiesRecordsInnerEventInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WatchlistEnhancedPropertiesRecordsInnerEventInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WatchlistEnhancedPropertiesRecordsInnerEventInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WatchlistEnhancedPropertiesRecordsInnerEventInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WatchlistEnhancedPropertiesRecordsInnerEventInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WatchlistEnhancedPropertiesRecordsInnerEventInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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 WatchlistEnhancedPropertiesRecordsInnerEventInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of WatchlistEnhancedPropertiesRecordsInnerEventInner + * @throws IOException if the JSON string is invalid with respect to WatchlistEnhancedPropertiesRecordsInnerEventInner + */ + public static WatchlistEnhancedPropertiesRecordsInnerEventInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WatchlistEnhancedPropertiesRecordsInnerEventInner.class); + } + + /** + * Convert an instance of WatchlistEnhancedPropertiesRecordsInnerEventInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.java b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.java new file mode 100644 index 0000000..dd33edd --- /dev/null +++ b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.java @@ -0,0 +1,372 @@ +/* + * Onfido API v3.6 + * The Onfido API (v3.6) + * + * The version of the OpenAPI document: v3.6 + * + * + * 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.onfido.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.time.LocalDate; +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.Set; + +import com.onfido.JSON; + +/** + * WatchlistEnhancedPropertiesRecordsInnerEventInnerSource + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class WatchlistEnhancedPropertiesRecordsInnerEventInnerSource { + public static final String SERIALIZED_NAME_SOURCE_DATE = "source_date"; + @SerializedName(SERIALIZED_NAME_SOURCE_DATE) + private LocalDate sourceDate; + + public static final String SERIALIZED_NAME_SOURCE_FORMAT = "source_format"; + @SerializedName(SERIALIZED_NAME_SOURCE_FORMAT) + private String sourceFormat; + + public static final String SERIALIZED_NAME_SOURCE_NAME = "source_name"; + @SerializedName(SERIALIZED_NAME_SOURCE_NAME) + private String sourceName; + + public static final String SERIALIZED_NAME_SOURCE_URL = "source_url"; + @SerializedName(SERIALIZED_NAME_SOURCE_URL) + private String sourceUrl; + + public WatchlistEnhancedPropertiesRecordsInnerEventInnerSource() { + } + + public WatchlistEnhancedPropertiesRecordsInnerEventInnerSource sourceDate(LocalDate sourceDate) { + this.sourceDate = sourceDate; + return this; + } + + /** + * Get sourceDate + * @return sourceDate + **/ + @javax.annotation.Nullable + public LocalDate getSourceDate() { + return sourceDate; + } + + public void setSourceDate(LocalDate sourceDate) { + this.sourceDate = sourceDate; + } + + + public WatchlistEnhancedPropertiesRecordsInnerEventInnerSource sourceFormat(String sourceFormat) { + this.sourceFormat = sourceFormat; + return this; + } + + /** + * Get sourceFormat + * @return sourceFormat + **/ + @javax.annotation.Nullable + public String getSourceFormat() { + return sourceFormat; + } + + public void setSourceFormat(String sourceFormat) { + this.sourceFormat = sourceFormat; + } + + + public WatchlistEnhancedPropertiesRecordsInnerEventInnerSource sourceName(String sourceName) { + this.sourceName = sourceName; + return this; + } + + /** + * Get sourceName + * @return sourceName + **/ + @javax.annotation.Nullable + public String getSourceName() { + return sourceName; + } + + public void setSourceName(String sourceName) { + this.sourceName = sourceName; + } + + + public WatchlistEnhancedPropertiesRecordsInnerEventInnerSource sourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + return this; + } + + /** + * Get sourceUrl + * @return sourceUrl + **/ + @javax.annotation.Nullable + public String getSourceUrl() { + return sourceUrl; + } + + public void setSourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + } + + /** + * 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 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 WatchlistEnhancedPropertiesRecordsInnerEventInnerSource instance itself + */ + public WatchlistEnhancedPropertiesRecordsInnerEventInnerSource putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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; + } + WatchlistEnhancedPropertiesRecordsInnerEventInnerSource watchlistEnhancedPropertiesRecordsInnerEventInnerSource = (WatchlistEnhancedPropertiesRecordsInnerEventInnerSource) o; + return Objects.equals(this.sourceDate, watchlistEnhancedPropertiesRecordsInnerEventInnerSource.sourceDate) && + Objects.equals(this.sourceFormat, watchlistEnhancedPropertiesRecordsInnerEventInnerSource.sourceFormat) && + Objects.equals(this.sourceName, watchlistEnhancedPropertiesRecordsInnerEventInnerSource.sourceName) && + Objects.equals(this.sourceUrl, watchlistEnhancedPropertiesRecordsInnerEventInnerSource.sourceUrl)&& + Objects.equals(this.additionalProperties, watchlistEnhancedPropertiesRecordsInnerEventInnerSource.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(sourceDate, sourceFormat, sourceName, sourceUrl, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WatchlistEnhancedPropertiesRecordsInnerEventInnerSource {\n"); + sb.append(" sourceDate: ").append(toIndentedString(sourceDate)).append("\n"); + sb.append(" sourceFormat: ").append(toIndentedString(sourceFormat)).append("\n"); + sb.append(" sourceName: ").append(toIndentedString(sourceName)).append("\n"); + sb.append(" sourceUrl: ").append(toIndentedString(sourceUrl)).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 openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("source_date"); + openapiFields.add("source_format"); + openapiFields.add("source_name"); + openapiFields.add("source_url"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 WatchlistEnhancedPropertiesRecordsInnerEventInnerSource + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WatchlistEnhancedPropertiesRecordsInnerEventInnerSource is not found in the empty JSON string", WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("source_format") != null && !jsonObj.get("source_format").isJsonNull()) && !jsonObj.get("source_format").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source_format` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_format").toString())); + } + if ((jsonObj.get("source_name") != null && !jsonObj.get("source_name").isJsonNull()) && !jsonObj.get("source_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_name").toString())); + } + if ((jsonObj.get("source_url") != null && !jsonObj.get("source_url").isJsonNull()) && !jsonObj.get("source_url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_url").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WatchlistEnhancedPropertiesRecordsInnerEventInnerSource' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WatchlistEnhancedPropertiesRecordsInnerEventInnerSource value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WatchlistEnhancedPropertiesRecordsInnerEventInnerSource read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WatchlistEnhancedPropertiesRecordsInnerEventInnerSource instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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 WatchlistEnhancedPropertiesRecordsInnerEventInnerSource given an JSON string + * + * @param jsonString JSON string + * @return An instance of WatchlistEnhancedPropertiesRecordsInnerEventInnerSource + * @throws IOException if the JSON string is invalid with respect to WatchlistEnhancedPropertiesRecordsInnerEventInnerSource + */ + public static WatchlistEnhancedPropertiesRecordsInnerEventInnerSource fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WatchlistEnhancedPropertiesRecordsInnerEventInnerSource.class); + } + + /** + * Convert an instance of WatchlistEnhancedPropertiesRecordsInnerEventInnerSource to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerSourceInner.java b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerSourceInner.java new file mode 100644 index 0000000..017c9ba --- /dev/null +++ b/src/main/java/com/onfido/model/WatchlistEnhancedPropertiesRecordsInnerSourceInner.java @@ -0,0 +1,374 @@ +/* + * Onfido API v3.6 + * The Onfido API (v3.6) + * + * The version of the OpenAPI document: v3.6 + * + * + * 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.onfido.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.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.Set; + +import com.onfido.JSON; + +/** + * WatchlistEnhancedPropertiesRecordsInnerSourceInner + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0") +public class WatchlistEnhancedPropertiesRecordsInnerSourceInner { + public static final String SERIALIZED_NAME_SOURCE_HEADLINE = "source_headline"; + @SerializedName(SERIALIZED_NAME_SOURCE_HEADLINE) + private String sourceHeadline; + + public static final String SERIALIZED_NAME_SOURCE_NAME = "source_name"; + @SerializedName(SERIALIZED_NAME_SOURCE_NAME) + private String sourceName; + + public static final String SERIALIZED_NAME_SOURCE_URL = "source_url"; + @SerializedName(SERIALIZED_NAME_SOURCE_URL) + private String sourceUrl; + + public static final String SERIALIZED_NAME_SOURCE_FORMAT = "source_format"; + @SerializedName(SERIALIZED_NAME_SOURCE_FORMAT) + private String sourceFormat; + + public WatchlistEnhancedPropertiesRecordsInnerSourceInner() { + } + + public WatchlistEnhancedPropertiesRecordsInnerSourceInner sourceHeadline(String sourceHeadline) { + this.sourceHeadline = sourceHeadline; + return this; + } + + /** + * Get sourceHeadline + * @return sourceHeadline + **/ + @javax.annotation.Nullable + public String getSourceHeadline() { + return sourceHeadline; + } + + public void setSourceHeadline(String sourceHeadline) { + this.sourceHeadline = sourceHeadline; + } + + + public WatchlistEnhancedPropertiesRecordsInnerSourceInner sourceName(String sourceName) { + this.sourceName = sourceName; + return this; + } + + /** + * Get sourceName + * @return sourceName + **/ + @javax.annotation.Nullable + public String getSourceName() { + return sourceName; + } + + public void setSourceName(String sourceName) { + this.sourceName = sourceName; + } + + + public WatchlistEnhancedPropertiesRecordsInnerSourceInner sourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + return this; + } + + /** + * Get sourceUrl + * @return sourceUrl + **/ + @javax.annotation.Nullable + public String getSourceUrl() { + return sourceUrl; + } + + public void setSourceUrl(String sourceUrl) { + this.sourceUrl = sourceUrl; + } + + + public WatchlistEnhancedPropertiesRecordsInnerSourceInner sourceFormat(String sourceFormat) { + this.sourceFormat = sourceFormat; + return this; + } + + /** + * Get sourceFormat + * @return sourceFormat + **/ + @javax.annotation.Nullable + public String getSourceFormat() { + return sourceFormat; + } + + public void setSourceFormat(String sourceFormat) { + this.sourceFormat = sourceFormat; + } + + /** + * 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 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 WatchlistEnhancedPropertiesRecordsInnerSourceInner instance itself + */ + public WatchlistEnhancedPropertiesRecordsInnerSourceInner putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map 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; + } + WatchlistEnhancedPropertiesRecordsInnerSourceInner watchlistEnhancedPropertiesRecordsInnerSourceInner = (WatchlistEnhancedPropertiesRecordsInnerSourceInner) o; + return Objects.equals(this.sourceHeadline, watchlistEnhancedPropertiesRecordsInnerSourceInner.sourceHeadline) && + Objects.equals(this.sourceName, watchlistEnhancedPropertiesRecordsInnerSourceInner.sourceName) && + Objects.equals(this.sourceUrl, watchlistEnhancedPropertiesRecordsInnerSourceInner.sourceUrl) && + Objects.equals(this.sourceFormat, watchlistEnhancedPropertiesRecordsInnerSourceInner.sourceFormat)&& + Objects.equals(this.additionalProperties, watchlistEnhancedPropertiesRecordsInnerSourceInner.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(sourceHeadline, sourceName, sourceUrl, sourceFormat, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class WatchlistEnhancedPropertiesRecordsInnerSourceInner {\n"); + sb.append(" sourceHeadline: ").append(toIndentedString(sourceHeadline)).append("\n"); + sb.append(" sourceName: ").append(toIndentedString(sourceName)).append("\n"); + sb.append(" sourceUrl: ").append(toIndentedString(sourceUrl)).append("\n"); + sb.append(" sourceFormat: ").append(toIndentedString(sourceFormat)).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 openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(); + openapiFields.add("source_headline"); + openapiFields.add("source_name"); + openapiFields.add("source_url"); + openapiFields.add("source_format"); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(); + } + + /** + * 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 WatchlistEnhancedPropertiesRecordsInnerSourceInner + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!WatchlistEnhancedPropertiesRecordsInnerSourceInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format("The required field(s) %s in WatchlistEnhancedPropertiesRecordsInnerSourceInner is not found in the empty JSON string", WatchlistEnhancedPropertiesRecordsInnerSourceInner.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("source_headline") != null && !jsonObj.get("source_headline").isJsonNull()) && !jsonObj.get("source_headline").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source_headline` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_headline").toString())); + } + if ((jsonObj.get("source_name") != null && !jsonObj.get("source_name").isJsonNull()) && !jsonObj.get("source_name").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_name").toString())); + } + if ((jsonObj.get("source_url") != null && !jsonObj.get("source_url").isJsonNull()) && !jsonObj.get("source_url").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_url").toString())); + } + if ((jsonObj.get("source_format") != null && !jsonObj.get("source_format").isJsonNull()) && !jsonObj.get("source_format").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format("Expected the field `source_format` to be a primitive type in the JSON string but got `%s`", jsonObj.get("source_format").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!WatchlistEnhancedPropertiesRecordsInnerSourceInner.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'WatchlistEnhancedPropertiesRecordsInnerSourceInner' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(WatchlistEnhancedPropertiesRecordsInnerSourceInner.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, WatchlistEnhancedPropertiesRecordsInnerSourceInner value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry 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 { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public WatchlistEnhancedPropertiesRecordsInnerSourceInner read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + WatchlistEnhancedPropertiesRecordsInnerSourceInner instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry 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 WatchlistEnhancedPropertiesRecordsInnerSourceInner given an JSON string + * + * @param jsonString JSON string + * @return An instance of WatchlistEnhancedPropertiesRecordsInnerSourceInner + * @throws IOException if the JSON string is invalid with respect to WatchlistEnhancedPropertiesRecordsInnerSourceInner + */ + public static WatchlistEnhancedPropertiesRecordsInnerSourceInner fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, WatchlistEnhancedPropertiesRecordsInnerSourceInner.class); + } + + /** + * Convert an instance of WatchlistEnhancedPropertiesRecordsInnerSourceInner to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +