
com.onfido.model.DocumentPropertiesBarcodeInner 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.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;
/**
* DocumentPropertiesBarcodeInner
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class DocumentPropertiesBarcodeInner {
public static final String SERIALIZED_NAME_FIRST_NAME = "first_name";
@SerializedName(SERIALIZED_NAME_FIRST_NAME)
private String firstName;
public static final String SERIALIZED_NAME_MIDDLE_NAME = "middle_name";
@SerializedName(SERIALIZED_NAME_MIDDLE_NAME)
private String middleName;
public static final String SERIALIZED_NAME_LAST_NAME = "last_name";
@SerializedName(SERIALIZED_NAME_LAST_NAME)
private String lastName;
public static final String SERIALIZED_NAME_DOCUMENT_TYPE = "document_type";
@SerializedName(SERIALIZED_NAME_DOCUMENT_TYPE)
private String documentType;
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_DATE_OF_BIRTH = "date_of_birth";
@SerializedName(SERIALIZED_NAME_DATE_OF_BIRTH)
private LocalDate dateOfBirth;
public static final String SERIALIZED_NAME_ISSUING_DATE = "issuing_date";
@SerializedName(SERIALIZED_NAME_ISSUING_DATE)
private LocalDate issuingDate;
public static final String SERIALIZED_NAME_ADDRESS_LINE1 = "address_line_1";
@SerializedName(SERIALIZED_NAME_ADDRESS_LINE1)
private String addressLine1;
public static final String SERIALIZED_NAME_ADDRESS_LINE2 = "address_line_2";
@SerializedName(SERIALIZED_NAME_ADDRESS_LINE2)
private String addressLine2;
public static final String SERIALIZED_NAME_ADDRESS_LINE3 = "address_line_3";
@SerializedName(SERIALIZED_NAME_ADDRESS_LINE3)
private String addressLine3;
public static final String SERIALIZED_NAME_ADDRESS_LINE4 = "address_line_4";
@SerializedName(SERIALIZED_NAME_ADDRESS_LINE4)
private String addressLine4;
public static final String SERIALIZED_NAME_ADDRESS_LINE5 = "address_line_5";
@SerializedName(SERIALIZED_NAME_ADDRESS_LINE5)
private String addressLine5;
public static final String SERIALIZED_NAME_ISSUING_STATE = "issuing_state";
@SerializedName(SERIALIZED_NAME_ISSUING_STATE)
private String issuingState;
public static final String SERIALIZED_NAME_PROPERTY_CLASS = "class";
@SerializedName(SERIALIZED_NAME_PROPERTY_CLASS)
private String propertyClass;
public static final String SERIALIZED_NAME_GENDER = "gender";
@SerializedName(SERIALIZED_NAME_GENDER)
private String gender;
public static final String SERIALIZED_NAME_ISSUING_COUNTRY = "issuing_country";
@SerializedName(SERIALIZED_NAME_ISSUING_COUNTRY)
private String issuingCountry;
public static final String SERIALIZED_NAME_DOCUMENT_NUMBER = "document_number";
@SerializedName(SERIALIZED_NAME_DOCUMENT_NUMBER)
private String documentNumber;
public static final String SERIALIZED_NAME_REAL_ID_CLASSIFICATION = "real_id_classification";
@SerializedName(SERIALIZED_NAME_REAL_ID_CLASSIFICATION)
private String realIdClassification;
public DocumentPropertiesBarcodeInner() {
}
public DocumentPropertiesBarcodeInner firstName(String firstName) {
this.firstName = firstName;
return this;
}
/**
* Get firstName
* @return firstName
**/
@javax.annotation.Nullable
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public DocumentPropertiesBarcodeInner middleName(String middleName) {
this.middleName = middleName;
return this;
}
/**
* Get middleName
* @return middleName
**/
@javax.annotation.Nullable
public String getMiddleName() {
return middleName;
}
public void setMiddleName(String middleName) {
this.middleName = middleName;
}
public DocumentPropertiesBarcodeInner lastName(String lastName) {
this.lastName = lastName;
return this;
}
/**
* Get lastName
* @return lastName
**/
@javax.annotation.Nullable
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner addressLine2(String addressLine2) {
this.addressLine2 = addressLine2;
return this;
}
/**
* Get addressLine2
* @return addressLine2
**/
@javax.annotation.Nullable
public String getAddressLine2() {
return addressLine2;
}
public void setAddressLine2(String addressLine2) {
this.addressLine2 = addressLine2;
}
public DocumentPropertiesBarcodeInner addressLine3(String addressLine3) {
this.addressLine3 = addressLine3;
return this;
}
/**
* Get addressLine3
* @return addressLine3
**/
@javax.annotation.Nullable
public String getAddressLine3() {
return addressLine3;
}
public void setAddressLine3(String addressLine3) {
this.addressLine3 = addressLine3;
}
public DocumentPropertiesBarcodeInner addressLine4(String addressLine4) {
this.addressLine4 = addressLine4;
return this;
}
/**
* Get addressLine4
* @return addressLine4
**/
@javax.annotation.Nullable
public String getAddressLine4() {
return addressLine4;
}
public void setAddressLine4(String addressLine4) {
this.addressLine4 = addressLine4;
}
public DocumentPropertiesBarcodeInner addressLine5(String addressLine5) {
this.addressLine5 = addressLine5;
return this;
}
/**
* Get addressLine5
* @return addressLine5
**/
@javax.annotation.Nullable
public String getAddressLine5() {
return addressLine5;
}
public void setAddressLine5(String addressLine5) {
this.addressLine5 = addressLine5;
}
public DocumentPropertiesBarcodeInner issuingState(String issuingState) {
this.issuingState = issuingState;
return this;
}
/**
* Get issuingState
* @return issuingState
**/
@javax.annotation.Nullable
public String getIssuingState() {
return issuingState;
}
public void setIssuingState(String issuingState) {
this.issuingState = issuingState;
}
public DocumentPropertiesBarcodeInner propertyClass(String propertyClass) {
this.propertyClass = propertyClass;
return this;
}
/**
* Get propertyClass
* @return propertyClass
**/
@javax.annotation.Nullable
public String getPropertyClass() {
return propertyClass;
}
public void setPropertyClass(String propertyClass) {
this.propertyClass = propertyClass;
}
public DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner realIdClassification(String realIdClassification) {
this.realIdClassification = realIdClassification;
return this;
}
/**
* Get realIdClassification
* @return realIdClassification
**/
@javax.annotation.Nullable
public String getRealIdClassification() {
return realIdClassification;
}
public void setRealIdClassification(String realIdClassification) {
this.realIdClassification = realIdClassification;
}
/**
* 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 DocumentPropertiesBarcodeInner instance itself
*/
public DocumentPropertiesBarcodeInner 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;
}
DocumentPropertiesBarcodeInner documentPropertiesBarcodeInner = (DocumentPropertiesBarcodeInner) o;
return Objects.equals(this.firstName, documentPropertiesBarcodeInner.firstName) &&
Objects.equals(this.middleName, documentPropertiesBarcodeInner.middleName) &&
Objects.equals(this.lastName, documentPropertiesBarcodeInner.lastName) &&
Objects.equals(this.documentType, documentPropertiesBarcodeInner.documentType) &&
Objects.equals(this.dateOfExpiry, documentPropertiesBarcodeInner.dateOfExpiry) &&
Objects.equals(this.dateOfBirth, documentPropertiesBarcodeInner.dateOfBirth) &&
Objects.equals(this.issuingDate, documentPropertiesBarcodeInner.issuingDate) &&
Objects.equals(this.addressLine1, documentPropertiesBarcodeInner.addressLine1) &&
Objects.equals(this.addressLine2, documentPropertiesBarcodeInner.addressLine2) &&
Objects.equals(this.addressLine3, documentPropertiesBarcodeInner.addressLine3) &&
Objects.equals(this.addressLine4, documentPropertiesBarcodeInner.addressLine4) &&
Objects.equals(this.addressLine5, documentPropertiesBarcodeInner.addressLine5) &&
Objects.equals(this.issuingState, documentPropertiesBarcodeInner.issuingState) &&
Objects.equals(this.propertyClass, documentPropertiesBarcodeInner.propertyClass) &&
Objects.equals(this.gender, documentPropertiesBarcodeInner.gender) &&
Objects.equals(this.issuingCountry, documentPropertiesBarcodeInner.issuingCountry) &&
Objects.equals(this.documentNumber, documentPropertiesBarcodeInner.documentNumber) &&
Objects.equals(this.realIdClassification, documentPropertiesBarcodeInner.realIdClassification)&&
Objects.equals(this.additionalProperties, documentPropertiesBarcodeInner.additionalProperties);
}
@Override
public int hashCode() {
return Objects.hash(firstName, middleName, lastName, documentType, dateOfExpiry, dateOfBirth, issuingDate, addressLine1, addressLine2, addressLine3, addressLine4, addressLine5, issuingState, propertyClass, gender, issuingCountry, documentNumber, realIdClassification, additionalProperties);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class DocumentPropertiesBarcodeInner {\n");
sb.append(" firstName: ").append(toIndentedString(firstName)).append("\n");
sb.append(" middleName: ").append(toIndentedString(middleName)).append("\n");
sb.append(" lastName: ").append(toIndentedString(lastName)).append("\n");
sb.append(" documentType: ").append(toIndentedString(documentType)).append("\n");
sb.append(" dateOfExpiry: ").append(toIndentedString(dateOfExpiry)).append("\n");
sb.append(" dateOfBirth: ").append(toIndentedString(dateOfBirth)).append("\n");
sb.append(" issuingDate: ").append(toIndentedString(issuingDate)).append("\n");
sb.append(" addressLine1: ").append(toIndentedString(addressLine1)).append("\n");
sb.append(" addressLine2: ").append(toIndentedString(addressLine2)).append("\n");
sb.append(" addressLine3: ").append(toIndentedString(addressLine3)).append("\n");
sb.append(" addressLine4: ").append(toIndentedString(addressLine4)).append("\n");
sb.append(" addressLine5: ").append(toIndentedString(addressLine5)).append("\n");
sb.append(" issuingState: ").append(toIndentedString(issuingState)).append("\n");
sb.append(" propertyClass: ").append(toIndentedString(propertyClass)).append("\n");
sb.append(" gender: ").append(toIndentedString(gender)).append("\n");
sb.append(" issuingCountry: ").append(toIndentedString(issuingCountry)).append("\n");
sb.append(" documentNumber: ").append(toIndentedString(documentNumber)).append("\n");
sb.append(" realIdClassification: ").append(toIndentedString(realIdClassification)).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("first_name");
openapiFields.add("middle_name");
openapiFields.add("last_name");
openapiFields.add("document_type");
openapiFields.add("date_of_expiry");
openapiFields.add("date_of_birth");
openapiFields.add("issuing_date");
openapiFields.add("address_line_1");
openapiFields.add("address_line_2");
openapiFields.add("address_line_3");
openapiFields.add("address_line_4");
openapiFields.add("address_line_5");
openapiFields.add("issuing_state");
openapiFields.add("class");
openapiFields.add("gender");
openapiFields.add("issuing_country");
openapiFields.add("document_number");
openapiFields.add("real_id_classification");
// 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 DocumentPropertiesBarcodeInner
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!DocumentPropertiesBarcodeInner.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in DocumentPropertiesBarcodeInner is not found in the empty JSON string", DocumentPropertiesBarcodeInner.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("first_name") != null && !jsonObj.get("first_name").isJsonNull()) && !jsonObj.get("first_name").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `first_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("first_name").toString()));
}
if ((jsonObj.get("middle_name") != null && !jsonObj.get("middle_name").isJsonNull()) && !jsonObj.get("middle_name").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `middle_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("middle_name").toString()));
}
if ((jsonObj.get("last_name") != null && !jsonObj.get("last_name").isJsonNull()) && !jsonObj.get("last_name").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `last_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("last_name").toString()));
}
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("address_line_1") != null && !jsonObj.get("address_line_1").isJsonNull()) && !jsonObj.get("address_line_1").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `address_line_1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_line_1").toString()));
}
if ((jsonObj.get("address_line_2") != null && !jsonObj.get("address_line_2").isJsonNull()) && !jsonObj.get("address_line_2").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `address_line_2` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_line_2").toString()));
}
if ((jsonObj.get("address_line_3") != null && !jsonObj.get("address_line_3").isJsonNull()) && !jsonObj.get("address_line_3").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `address_line_3` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_line_3").toString()));
}
if ((jsonObj.get("address_line_4") != null && !jsonObj.get("address_line_4").isJsonNull()) && !jsonObj.get("address_line_4").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `address_line_4` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_line_4").toString()));
}
if ((jsonObj.get("address_line_5") != null && !jsonObj.get("address_line_5").isJsonNull()) && !jsonObj.get("address_line_5").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `address_line_5` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_line_5").toString()));
}
if ((jsonObj.get("issuing_state") != null && !jsonObj.get("issuing_state").isJsonNull()) && !jsonObj.get("issuing_state").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `issuing_state` to be a primitive type in the JSON string but got `%s`", jsonObj.get("issuing_state").toString()));
}
if ((jsonObj.get("class") != null && !jsonObj.get("class").isJsonNull()) && !jsonObj.get("class").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `class` to be a primitive type in the JSON string but got `%s`", jsonObj.get("class").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("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("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("real_id_classification") != null && !jsonObj.get("real_id_classification").isJsonNull()) && !jsonObj.get("real_id_classification").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `real_id_classification` to be a primitive type in the JSON string but got `%s`", jsonObj.get("real_id_classification").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!DocumentPropertiesBarcodeInner.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'DocumentPropertiesBarcodeInner' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(DocumentPropertiesBarcodeInner.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
JsonObject jsonObj = jsonElement.getAsJsonObject();
// store additional fields in the deserialized instance
DocumentPropertiesBarcodeInner 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 DocumentPropertiesBarcodeInner given an JSON string
*
* @param jsonString JSON string
* @return An instance of DocumentPropertiesBarcodeInner
* @throws IOException if the JSON string is invalid with respect to DocumentPropertiesBarcodeInner
*/
public static DocumentPropertiesBarcodeInner fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, DocumentPropertiesBarcodeInner.class);
}
/**
* Convert an instance of DocumentPropertiesBarcodeInner to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy