com.onfido.model.DocumentPropertiesNfc Maven / Gradle / Ivy
/*
* 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.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.onfido.JSON;
/**
* DocumentPropertiesNfc
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0")
public class DocumentPropertiesNfc {
public static final String SERIALIZED_NAME_DOCUMENT_TYPE = "document_type";
@SerializedName(SERIALIZED_NAME_DOCUMENT_TYPE)
private String documentType;
public static final String SERIALIZED_NAME_ISSUING_COUNTRY = "issuing_country";
@SerializedName(SERIALIZED_NAME_ISSUING_COUNTRY)
private String issuingCountry;
public static final String SERIALIZED_NAME_FULL_NAME = "full_name";
@SerializedName(SERIALIZED_NAME_FULL_NAME)
private String fullName;
public static final String SERIALIZED_NAME_DOCUMENT_NUMBER = "document_number";
@SerializedName(SERIALIZED_NAME_DOCUMENT_NUMBER)
private String documentNumber;
public static final String SERIALIZED_NAME_NATIONALITY = "nationality";
@SerializedName(SERIALIZED_NAME_NATIONALITY)
private String nationality;
public static final String SERIALIZED_NAME_DATE_OF_BIRTH = "date_of_birth";
@SerializedName(SERIALIZED_NAME_DATE_OF_BIRTH)
private LocalDate dateOfBirth;
public static final String SERIALIZED_NAME_GENDER = "gender";
@SerializedName(SERIALIZED_NAME_GENDER)
private String gender;
public static final String SERIALIZED_NAME_DATE_OF_EXPIRY = "date_of_expiry";
@SerializedName(SERIALIZED_NAME_DATE_OF_EXPIRY)
private LocalDate dateOfExpiry;
public static final String SERIALIZED_NAME_PERSONAL_NUMBER = "personal_number";
@SerializedName(SERIALIZED_NAME_PERSONAL_NUMBER)
private String personalNumber;
public static final String SERIALIZED_NAME_PLACE_OF_BIRTH = "place_of_birth";
@SerializedName(SERIALIZED_NAME_PLACE_OF_BIRTH)
private String placeOfBirth;
public static final String SERIALIZED_NAME_ADDRESS = "address";
@SerializedName(SERIALIZED_NAME_ADDRESS)
private String address;
public static final String SERIALIZED_NAME_ISSUING_DATE = "issuing_date";
@SerializedName(SERIALIZED_NAME_ISSUING_DATE)
private LocalDate issuingDate;
public static final String SERIALIZED_NAME_ISSUING_AUTHORITY = "issuing_authority";
@SerializedName(SERIALIZED_NAME_ISSUING_AUTHORITY)
private String issuingAuthority;
public DocumentPropertiesNfc() {
}
public DocumentPropertiesNfc documentType(String documentType) {
this.documentType = documentType;
return this;
}
/**
* Get documentType
* @return documentType
*/
@javax.annotation.Nullable
public String getDocumentType() {
return documentType;
}
public void setDocumentType(String documentType) {
this.documentType = documentType;
}
public DocumentPropertiesNfc issuingCountry(String issuingCountry) {
this.issuingCountry = issuingCountry;
return this;
}
/**
* Get issuingCountry
* @return issuingCountry
*/
@javax.annotation.Nullable
public String getIssuingCountry() {
return issuingCountry;
}
public void setIssuingCountry(String issuingCountry) {
this.issuingCountry = issuingCountry;
}
public DocumentPropertiesNfc fullName(String fullName) {
this.fullName = fullName;
return this;
}
/**
* Get fullName
* @return fullName
*/
@javax.annotation.Nullable
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public DocumentPropertiesNfc documentNumber(String documentNumber) {
this.documentNumber = documentNumber;
return this;
}
/**
* Get documentNumber
* @return documentNumber
*/
@javax.annotation.Nullable
public String getDocumentNumber() {
return documentNumber;
}
public void setDocumentNumber(String documentNumber) {
this.documentNumber = documentNumber;
}
public DocumentPropertiesNfc nationality(String nationality) {
this.nationality = nationality;
return this;
}
/**
* Get nationality
* @return nationality
*/
@javax.annotation.Nullable
public String getNationality() {
return nationality;
}
public void setNationality(String nationality) {
this.nationality = nationality;
}
public DocumentPropertiesNfc dateOfBirth(LocalDate dateOfBirth) {
this.dateOfBirth = dateOfBirth;
return this;
}
/**
* Get dateOfBirth
* @return dateOfBirth
*/
@javax.annotation.Nullable
public LocalDate getDateOfBirth() {
return dateOfBirth;
}
public void setDateOfBirth(LocalDate dateOfBirth) {
this.dateOfBirth = dateOfBirth;
}
public DocumentPropertiesNfc gender(String gender) {
this.gender = gender;
return this;
}
/**
* Get gender
* @return gender
*/
@javax.annotation.Nullable
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public DocumentPropertiesNfc dateOfExpiry(LocalDate dateOfExpiry) {
this.dateOfExpiry = dateOfExpiry;
return this;
}
/**
* Get dateOfExpiry
* @return dateOfExpiry
*/
@javax.annotation.Nullable
public LocalDate getDateOfExpiry() {
return dateOfExpiry;
}
public void setDateOfExpiry(LocalDate dateOfExpiry) {
this.dateOfExpiry = dateOfExpiry;
}
public DocumentPropertiesNfc personalNumber(String personalNumber) {
this.personalNumber = personalNumber;
return this;
}
/**
* Get personalNumber
* @return personalNumber
*/
@javax.annotation.Nullable
public String getPersonalNumber() {
return personalNumber;
}
public void setPersonalNumber(String personalNumber) {
this.personalNumber = personalNumber;
}
public DocumentPropertiesNfc placeOfBirth(String placeOfBirth) {
this.placeOfBirth = placeOfBirth;
return this;
}
/**
* Get placeOfBirth
* @return placeOfBirth
*/
@javax.annotation.Nullable
public String getPlaceOfBirth() {
return placeOfBirth;
}
public void setPlaceOfBirth(String placeOfBirth) {
this.placeOfBirth = placeOfBirth;
}
public DocumentPropertiesNfc address(String address) {
this.address = address;
return this;
}
/**
* Get address
* @return address
*/
@javax.annotation.Nullable
public String getAddress() {
return address;
}
public void setAddress(String address) {
this.address = address;
}
public DocumentPropertiesNfc issuingDate(LocalDate issuingDate) {
this.issuingDate = issuingDate;
return this;
}
/**
* Get issuingDate
* @return issuingDate
*/
@javax.annotation.Nullable
public LocalDate getIssuingDate() {
return issuingDate;
}
public void setIssuingDate(LocalDate issuingDate) {
this.issuingDate = issuingDate;
}
public DocumentPropertiesNfc issuingAuthority(String issuingAuthority) {
this.issuingAuthority = issuingAuthority;
return this;
}
/**
* Get issuingAuthority
* @return issuingAuthority
*/
@javax.annotation.Nullable
public String getIssuingAuthority() {
return issuingAuthority;
}
public void setIssuingAuthority(String issuingAuthority) {
this.issuingAuthority = issuingAuthority;
}
/**
* 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 DocumentPropertiesNfc instance itself
*/
public DocumentPropertiesNfc 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;
}
DocumentPropertiesNfc documentPropertiesNfc = (DocumentPropertiesNfc) o;
return Objects.equals(this.documentType, documentPropertiesNfc.documentType) &&
Objects.equals(this.issuingCountry, documentPropertiesNfc.issuingCountry) &&
Objects.equals(this.fullName, documentPropertiesNfc.fullName) &&
Objects.equals(this.documentNumber, documentPropertiesNfc.documentNumber) &&
Objects.equals(this.nationality, documentPropertiesNfc.nationality) &&
Objects.equals(this.dateOfBirth, documentPropertiesNfc.dateOfBirth) &&
Objects.equals(this.gender, documentPropertiesNfc.gender) &&
Objects.equals(this.dateOfExpiry, documentPropertiesNfc.dateOfExpiry) &&
Objects.equals(this.personalNumber, documentPropertiesNfc.personalNumber) &&
Objects.equals(this.placeOfBirth, documentPropertiesNfc.placeOfBirth) &&
Objects.equals(this.address, documentPropertiesNfc.address) &&
Objects.equals(this.issuingDate, documentPropertiesNfc.issuingDate) &&
Objects.equals(this.issuingAuthority, documentPropertiesNfc.issuingAuthority)&&
Objects.equals(this.additionalProperties, documentPropertiesNfc.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(documentType, issuingCountry, fullName, documentNumber, nationality, dateOfBirth, gender, dateOfExpiry, personalNumber, placeOfBirth, address, issuingDate, issuingAuthority, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DocumentPropertiesNfc {\n");
sb.append(" documentType: ").append(toIndentedString(documentType)).append("\n");
sb.append(" issuingCountry: ").append(toIndentedString(issuingCountry)).append("\n");
sb.append(" fullName: ").append(toIndentedString(fullName)).append("\n");
sb.append(" documentNumber: ").append(toIndentedString(documentNumber)).append("\n");
sb.append(" nationality: ").append(toIndentedString(nationality)).append("\n");
sb.append(" dateOfBirth: ").append(toIndentedString(dateOfBirth)).append("\n");
sb.append(" gender: ").append(toIndentedString(gender)).append("\n");
sb.append(" dateOfExpiry: ").append(toIndentedString(dateOfExpiry)).append("\n");
sb.append(" personalNumber: ").append(toIndentedString(personalNumber)).append("\n");
sb.append(" placeOfBirth: ").append(toIndentedString(placeOfBirth)).append("\n");
sb.append(" address: ").append(toIndentedString(address)).append("\n");
sb.append(" issuingDate: ").append(toIndentedString(issuingDate)).append("\n");
sb.append(" issuingAuthority: ").append(toIndentedString(issuingAuthority)).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("document_type");
openapiFields.add("issuing_country");
openapiFields.add("full_name");
openapiFields.add("document_number");
openapiFields.add("nationality");
openapiFields.add("date_of_birth");
openapiFields.add("gender");
openapiFields.add("date_of_expiry");
openapiFields.add("personal_number");
openapiFields.add("place_of_birth");
openapiFields.add("address");
openapiFields.add("issuing_date");
openapiFields.add("issuing_authority");
// 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 DocumentPropertiesNfc
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!DocumentPropertiesNfc.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in DocumentPropertiesNfc is not found in the empty JSON string", DocumentPropertiesNfc.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("document_type") != null && !jsonObj.get("document_type").isJsonNull()) && !jsonObj.get("document_type").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `document_type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("document_type").toString()));
}
if ((jsonObj.get("issuing_country") != null && !jsonObj.get("issuing_country").isJsonNull()) && !jsonObj.get("issuing_country").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `issuing_country` to be a primitive type in the JSON string but got `%s`", jsonObj.get("issuing_country").toString()));
}
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()));
}
if ((jsonObj.get("document_number") != null && !jsonObj.get("document_number").isJsonNull()) && !jsonObj.get("document_number").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `document_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("document_number").toString()));
}
if ((jsonObj.get("nationality") != null && !jsonObj.get("nationality").isJsonNull()) && !jsonObj.get("nationality").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `nationality` to be a primitive type in the JSON string but got `%s`", jsonObj.get("nationality").toString()));
}
if ((jsonObj.get("gender") != null && !jsonObj.get("gender").isJsonNull()) && !jsonObj.get("gender").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `gender` to be a primitive type in the JSON string but got `%s`", jsonObj.get("gender").toString()));
}
if ((jsonObj.get("personal_number") != null && !jsonObj.get("personal_number").isJsonNull()) && !jsonObj.get("personal_number").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `personal_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("personal_number").toString()));
}
if ((jsonObj.get("place_of_birth") != null && !jsonObj.get("place_of_birth").isJsonNull()) && !jsonObj.get("place_of_birth").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `place_of_birth` to be a primitive type in the JSON string but got `%s`", jsonObj.get("place_of_birth").toString()));
}
if ((jsonObj.get("address") != null && !jsonObj.get("address").isJsonNull()) && !jsonObj.get("address").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString()));
}
if ((jsonObj.get("issuing_authority") != null && !jsonObj.get("issuing_authority").isJsonNull()) && !jsonObj.get("issuing_authority").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `issuing_authority` to be a primitive type in the JSON string but got `%s`", jsonObj.get("issuing_authority").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!DocumentPropertiesNfc.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'DocumentPropertiesNfc' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(DocumentPropertiesNfc.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, DocumentPropertiesNfc 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 if (jsonElement.isJsonObject()) {
obj.add(entry.getKey(), jsonElement.getAsJsonObject());
}
}
}
}
elementAdapter.write(out, obj);
}
@Override
public DocumentPropertiesNfc read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
DocumentPropertiesNfc 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 DocumentPropertiesNfc given an JSON string
*
* @param jsonString JSON string
* @return An instance of DocumentPropertiesNfc
* @throws IOException if the JSON string is invalid with respect to DocumentPropertiesNfc
*/
public static DocumentPropertiesNfc fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, DocumentPropertiesNfc.class);
}
/**
* Convert an instance of DocumentPropertiesNfc to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy