All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.onfido.model.ExtractionExtractedData 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 com.onfido.model.CountryCodes;
import com.onfido.model.DocumentTypes;
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;

/**
 * ExtractionExtractedData
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.6.0")
public class ExtractionExtractedData {
  public static final String SERIALIZED_NAME_DOCUMENT_NUMBER = "document_number";
  @SerializedName(SERIALIZED_NAME_DOCUMENT_NUMBER)
  private String documentNumber;

  public static final String SERIALIZED_NAME_FIRST_NAME = "first_name";
  @SerializedName(SERIALIZED_NAME_FIRST_NAME)
  private String firstName;

  public static final String SERIALIZED_NAME_LAST_NAME = "last_name";
  @SerializedName(SERIALIZED_NAME_LAST_NAME)
  private String lastName;

  public static final String SERIALIZED_NAME_FULL_NAME = "full_name";
  @SerializedName(SERIALIZED_NAME_FULL_NAME)
  private String fullName;

  public static final String SERIALIZED_NAME_SPOUSE_NAME = "spouse_name";
  @SerializedName(SERIALIZED_NAME_SPOUSE_NAME)
  private String spouseName;

  public static final String SERIALIZED_NAME_WIDOW_NAME = "widow_name";
  @SerializedName(SERIALIZED_NAME_WIDOW_NAME)
  private String widowName;

  public static final String SERIALIZED_NAME_ALIAS_NAME = "alias_name";
  @SerializedName(SERIALIZED_NAME_ALIAS_NAME)
  private String aliasName;

  /**
   * Gender (Valid values are Male and Female).
   */
  @JsonAdapter(GenderEnum.Adapter.class)
  public enum GenderEnum {
    MALE("Male"),
    
    FEMALE("Female"),
    
    UNKNOWN_DEFAULT_OPEN_API("unknown_default_open_api");

    private String value;

    GenderEnum(String value) {
      this.value = value;
    }

    public String getValue() {
      return value;
    }

    @Override
    public String toString() {
      return String.valueOf(value);
    }

    public static GenderEnum fromValue(String value) {
      for (GenderEnum b : GenderEnum.values()) {
        if (b.value.equals(value)) {
          return b;
        }
      }
      return UNKNOWN_DEFAULT_OPEN_API;
    }

    public static class Adapter extends TypeAdapter {
      @Override
      public void write(final JsonWriter jsonWriter, final GenderEnum enumeration) throws IOException {
        jsonWriter.value(enumeration.getValue());
      }

      @Override
      public GenderEnum read(final JsonReader jsonReader) throws IOException {
        String value =  jsonReader.nextString();
        return GenderEnum.fromValue(value);
      }
    }

    public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      String value = jsonElement.getAsString();
      GenderEnum.fromValue(value);
    }
  }

  public static final String SERIALIZED_NAME_GENDER = "gender";
  @SerializedName(SERIALIZED_NAME_GENDER)
  private GenderEnum gender;

  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_DATE_OF_EXPIRY = "date_of_expiry";
  @SerializedName(SERIALIZED_NAME_DATE_OF_EXPIRY)
  private LocalDate dateOfExpiry;

  public static final String SERIALIZED_NAME_EXPIRY_DATE = "expiry_date";
  @SerializedName(SERIALIZED_NAME_EXPIRY_DATE)
  private LocalDate expiryDate;

  public static final String SERIALIZED_NAME_NATIONALITY = "nationality";
  @SerializedName(SERIALIZED_NAME_NATIONALITY)
  private String nationality;

  public static final String SERIALIZED_NAME_MRZ_LINE1 = "mrz_line_1";
  @SerializedName(SERIALIZED_NAME_MRZ_LINE1)
  private String mrzLine1;

  public static final String SERIALIZED_NAME_MRZ_LINE2 = "mrz_line_2";
  @SerializedName(SERIALIZED_NAME_MRZ_LINE2)
  private String mrzLine2;

  public static final String SERIALIZED_NAME_MRZ_LINE3 = "mrz_line_3";
  @SerializedName(SERIALIZED_NAME_MRZ_LINE3)
  private String mrzLine3;

  public static final String SERIALIZED_NAME_ADDRESS1 = "address_1";
  @SerializedName(SERIALIZED_NAME_ADDRESS1)
  private String address1;

  public static final String SERIALIZED_NAME_ADDRESS2 = "address_2";
  @SerializedName(SERIALIZED_NAME_ADDRESS2)
  private String address2;

  public static final String SERIALIZED_NAME_ADDRESS3 = "address_3";
  @SerializedName(SERIALIZED_NAME_ADDRESS3)
  private String address3;

  public static final String SERIALIZED_NAME_ADDRESS4 = "address_4";
  @SerializedName(SERIALIZED_NAME_ADDRESS4)
  private String address4;

  public static final String SERIALIZED_NAME_ADDRESS5 = "address_5";
  @SerializedName(SERIALIZED_NAME_ADDRESS5)
  private String address5;

  public static final String SERIALIZED_NAME_ISSUING_AUTHORITY = "issuing_authority";
  @SerializedName(SERIALIZED_NAME_ISSUING_AUTHORITY)
  private String issuingAuthority;

  public static final String SERIALIZED_NAME_ISSUING_COUNTRY = "issuing_country";
  @SerializedName(SERIALIZED_NAME_ISSUING_COUNTRY)
  private CountryCodes issuingCountry;

  public static final String SERIALIZED_NAME_DOCUMENT_TYPE = "document_type";
  @SerializedName(SERIALIZED_NAME_DOCUMENT_TYPE)
  private DocumentTypes documentType;

  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_ISSUING_STATE = "issuing_state";
  @SerializedName(SERIALIZED_NAME_ISSUING_STATE)
  private String issuingState;

  public static final String SERIALIZED_NAME_ISSUING_DATE = "issuing_date";
  @SerializedName(SERIALIZED_NAME_ISSUING_DATE)
  private LocalDate issuingDate;

  public static final String SERIALIZED_NAME_PERSONAL_NUMBER = "personal_number";
  @SerializedName(SERIALIZED_NAME_PERSONAL_NUMBER)
  private String personalNumber;

  public ExtractionExtractedData() {
  }

  public ExtractionExtractedData documentNumber(String documentNumber) {
    this.documentNumber = documentNumber;
    return this;
  }

   /**
   * The official document number.
   * @return documentNumber
  **/
  @javax.annotation.Nullable
  public String getDocumentNumber() {
    return documentNumber;
  }

  public void setDocumentNumber(String documentNumber) {
    this.documentNumber = documentNumber;
  }


  public ExtractionExtractedData firstName(String firstName) {
    this.firstName = firstName;
    return this;
  }

   /**
   * First name.
   * @return firstName
  **/
  @javax.annotation.Nullable
  public String getFirstName() {
    return firstName;
  }

  public void setFirstName(String firstName) {
    this.firstName = firstName;
  }


  public ExtractionExtractedData lastName(String lastName) {
    this.lastName = lastName;
    return this;
  }

   /**
   * Last name.
   * @return lastName
  **/
  @javax.annotation.Nullable
  public String getLastName() {
    return lastName;
  }

  public void setLastName(String lastName) {
    this.lastName = lastName;
  }


  public ExtractionExtractedData fullName(String fullName) {
    this.fullName = fullName;
    return this;
  }

   /**
   * Full name.
   * @return fullName
  **/
  @javax.annotation.Nullable
  public String getFullName() {
    return fullName;
  }

  public void setFullName(String fullName) {
    this.fullName = fullName;
  }


  public ExtractionExtractedData spouseName(String spouseName) {
    this.spouseName = spouseName;
    return this;
  }

   /**
   * Spouse name (French documents only).
   * @return spouseName
  **/
  @javax.annotation.Nullable
  public String getSpouseName() {
    return spouseName;
  }

  public void setSpouseName(String spouseName) {
    this.spouseName = spouseName;
  }


  public ExtractionExtractedData widowName(String widowName) {
    this.widowName = widowName;
    return this;
  }

   /**
   * Widow name (French documents only).
   * @return widowName
  **/
  @javax.annotation.Nullable
  public String getWidowName() {
    return widowName;
  }

  public void setWidowName(String widowName) {
    this.widowName = widowName;
  }


  public ExtractionExtractedData aliasName(String aliasName) {
    this.aliasName = aliasName;
    return this;
  }

   /**
   * Alias name (French documents only).
   * @return aliasName
  **/
  @javax.annotation.Nullable
  public String getAliasName() {
    return aliasName;
  }

  public void setAliasName(String aliasName) {
    this.aliasName = aliasName;
  }


  public ExtractionExtractedData gender(GenderEnum gender) {
    this.gender = gender;
    return this;
  }

   /**
   * Gender (Valid values are Male and Female).
   * @return gender
  **/
  @javax.annotation.Nullable
  public GenderEnum getGender() {
    return gender;
  }

  public void setGender(GenderEnum gender) {
    this.gender = gender;
  }


  public ExtractionExtractedData dateOfBirth(LocalDate dateOfBirth) {
    this.dateOfBirth = dateOfBirth;
    return this;
  }

   /**
   * Date of birth in YYYY-MM-DD format.
   * @return dateOfBirth
  **/
  @javax.annotation.Nullable
  public LocalDate getDateOfBirth() {
    return dateOfBirth;
  }

  public void setDateOfBirth(LocalDate dateOfBirth) {
    this.dateOfBirth = dateOfBirth;
  }


  public ExtractionExtractedData dateOfExpiry(LocalDate dateOfExpiry) {
    this.dateOfExpiry = dateOfExpiry;
    return this;
  }

   /**
   * Date of expiry in YYYY-MM-DD format.
   * @return dateOfExpiry
  **/
  @javax.annotation.Nullable
  public LocalDate getDateOfExpiry() {
    return dateOfExpiry;
  }

  public void setDateOfExpiry(LocalDate dateOfExpiry) {
    this.dateOfExpiry = dateOfExpiry;
  }


  public ExtractionExtractedData expiryDate(LocalDate expiryDate) {
    this.expiryDate = expiryDate;
    return this;
  }

   /**
   * Date of expiry in YYYY-MM-DD format.
   * @return expiryDate
  **/
  @javax.annotation.Nullable
  public LocalDate getExpiryDate() {
    return expiryDate;
  }

  public void setExpiryDate(LocalDate expiryDate) {
    this.expiryDate = expiryDate;
  }


  public ExtractionExtractedData nationality(String nationality) {
    this.nationality = nationality;
    return this;
  }

   /**
   * Nationality in 3-letter ISO code.
   * @return nationality
  **/
  @javax.annotation.Nullable
  public String getNationality() {
    return nationality;
  }

  public void setNationality(String nationality) {
    this.nationality = nationality;
  }


  public ExtractionExtractedData mrzLine1(String mrzLine1) {
    this.mrzLine1 = mrzLine1;
    return this;
  }

   /**
   * Line 1 of the MRZ code.
   * @return mrzLine1
  **/
  @javax.annotation.Nullable
  public String getMrzLine1() {
    return mrzLine1;
  }

  public void setMrzLine1(String mrzLine1) {
    this.mrzLine1 = mrzLine1;
  }


  public ExtractionExtractedData mrzLine2(String mrzLine2) {
    this.mrzLine2 = mrzLine2;
    return this;
  }

   /**
   * Line 2 of the MRZ code.
   * @return mrzLine2
  **/
  @javax.annotation.Nullable
  public String getMrzLine2() {
    return mrzLine2;
  }

  public void setMrzLine2(String mrzLine2) {
    this.mrzLine2 = mrzLine2;
  }


  public ExtractionExtractedData mrzLine3(String mrzLine3) {
    this.mrzLine3 = mrzLine3;
    return this;
  }

   /**
   * Line 3 of the MRZ code.
   * @return mrzLine3
  **/
  @javax.annotation.Nullable
  public String getMrzLine3() {
    return mrzLine3;
  }

  public void setMrzLine3(String mrzLine3) {
    this.mrzLine3 = mrzLine3;
  }


  public ExtractionExtractedData address1(String address1) {
    this.address1 = address1;
    return this;
  }

   /**
   * Line 1 of the address.
   * @return address1
  **/
  @javax.annotation.Nullable
  public String getAddress1() {
    return address1;
  }

  public void setAddress1(String address1) {
    this.address1 = address1;
  }


  public ExtractionExtractedData address2(String address2) {
    this.address2 = address2;
    return this;
  }

   /**
   * Line 2 of the address.
   * @return address2
  **/
  @javax.annotation.Nullable
  public String getAddress2() {
    return address2;
  }

  public void setAddress2(String address2) {
    this.address2 = address2;
  }


  public ExtractionExtractedData address3(String address3) {
    this.address3 = address3;
    return this;
  }

   /**
   * Line 3 of the address.
   * @return address3
  **/
  @javax.annotation.Nullable
  public String getAddress3() {
    return address3;
  }

  public void setAddress3(String address3) {
    this.address3 = address3;
  }


  public ExtractionExtractedData address4(String address4) {
    this.address4 = address4;
    return this;
  }

   /**
   * Line 4 of the address.
   * @return address4
  **/
  @javax.annotation.Nullable
  public String getAddress4() {
    return address4;
  }

  public void setAddress4(String address4) {
    this.address4 = address4;
  }


  public ExtractionExtractedData address5(String address5) {
    this.address5 = address5;
    return this;
  }

   /**
   * Line 5 of the address.
   * @return address5
  **/
  @javax.annotation.Nullable
  public String getAddress5() {
    return address5;
  }

  public void setAddress5(String address5) {
    this.address5 = address5;
  }


  public ExtractionExtractedData issuingAuthority(String issuingAuthority) {
    this.issuingAuthority = issuingAuthority;
    return this;
  }

   /**
   * Issuing authority.
   * @return issuingAuthority
  **/
  @javax.annotation.Nullable
  public String getIssuingAuthority() {
    return issuingAuthority;
  }

  public void setIssuingAuthority(String issuingAuthority) {
    this.issuingAuthority = issuingAuthority;
  }


  public ExtractionExtractedData issuingCountry(CountryCodes issuingCountry) {
    this.issuingCountry = issuingCountry;
    return this;
  }

   /**
   * Document country in 3-letter ISO code.
   * @return issuingCountry
  **/
  @javax.annotation.Nullable
  public CountryCodes getIssuingCountry() {
    return issuingCountry;
  }

  public void setIssuingCountry(CountryCodes issuingCountry) {
    this.issuingCountry = issuingCountry;
  }


  public ExtractionExtractedData documentType(DocumentTypes documentType) {
    this.documentType = documentType;
    return this;
  }

   /**
   * Type of document.
   * @return documentType
  **/
  @javax.annotation.Nullable
  public DocumentTypes getDocumentType() {
    return documentType;
  }

  public void setDocumentType(DocumentTypes documentType) {
    this.documentType = documentType;
  }


  public ExtractionExtractedData placeOfBirth(String placeOfBirth) {
    this.placeOfBirth = placeOfBirth;
    return this;
  }

   /**
   * Place of birth.
   * @return placeOfBirth
  **/
  @javax.annotation.Nullable
  public String getPlaceOfBirth() {
    return placeOfBirth;
  }

  public void setPlaceOfBirth(String placeOfBirth) {
    this.placeOfBirth = placeOfBirth;
  }


  public ExtractionExtractedData issuingState(String issuingState) {
    this.issuingState = issuingState;
    return this;
  }

   /**
   * The state that issued the document.
   * @return issuingState
  **/
  @javax.annotation.Nullable
  public String getIssuingState() {
    return issuingState;
  }

  public void setIssuingState(String issuingState) {
    this.issuingState = issuingState;
  }


  public ExtractionExtractedData issuingDate(LocalDate issuingDate) {
    this.issuingDate = issuingDate;
    return this;
  }

   /**
   * Issuing date in YYYY-MM-DD format.
   * @return issuingDate
  **/
  @javax.annotation.Nullable
  public LocalDate getIssuingDate() {
    return issuingDate;
  }

  public void setIssuingDate(LocalDate issuingDate) {
    this.issuingDate = issuingDate;
  }


  public ExtractionExtractedData personalNumber(String personalNumber) {
    this.personalNumber = personalNumber;
    return this;
  }

   /**
   * The owner's unique identification number.
   * @return personalNumber
  **/
  @javax.annotation.Nullable
  public String getPersonalNumber() {
    return personalNumber;
  }

  public void setPersonalNumber(String personalNumber) {
    this.personalNumber = personalNumber;
  }

  /**
   * 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 ExtractionExtractedData instance itself
   */
  public ExtractionExtractedData 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;
    }
    ExtractionExtractedData extractionExtractedData = (ExtractionExtractedData) o;
    return Objects.equals(this.documentNumber, extractionExtractedData.documentNumber) &&
        Objects.equals(this.firstName, extractionExtractedData.firstName) &&
        Objects.equals(this.lastName, extractionExtractedData.lastName) &&
        Objects.equals(this.fullName, extractionExtractedData.fullName) &&
        Objects.equals(this.spouseName, extractionExtractedData.spouseName) &&
        Objects.equals(this.widowName, extractionExtractedData.widowName) &&
        Objects.equals(this.aliasName, extractionExtractedData.aliasName) &&
        Objects.equals(this.gender, extractionExtractedData.gender) &&
        Objects.equals(this.dateOfBirth, extractionExtractedData.dateOfBirth) &&
        Objects.equals(this.dateOfExpiry, extractionExtractedData.dateOfExpiry) &&
        Objects.equals(this.expiryDate, extractionExtractedData.expiryDate) &&
        Objects.equals(this.nationality, extractionExtractedData.nationality) &&
        Objects.equals(this.mrzLine1, extractionExtractedData.mrzLine1) &&
        Objects.equals(this.mrzLine2, extractionExtractedData.mrzLine2) &&
        Objects.equals(this.mrzLine3, extractionExtractedData.mrzLine3) &&
        Objects.equals(this.address1, extractionExtractedData.address1) &&
        Objects.equals(this.address2, extractionExtractedData.address2) &&
        Objects.equals(this.address3, extractionExtractedData.address3) &&
        Objects.equals(this.address4, extractionExtractedData.address4) &&
        Objects.equals(this.address5, extractionExtractedData.address5) &&
        Objects.equals(this.issuingAuthority, extractionExtractedData.issuingAuthority) &&
        Objects.equals(this.issuingCountry, extractionExtractedData.issuingCountry) &&
        Objects.equals(this.documentType, extractionExtractedData.documentType) &&
        Objects.equals(this.placeOfBirth, extractionExtractedData.placeOfBirth) &&
        Objects.equals(this.issuingState, extractionExtractedData.issuingState) &&
        Objects.equals(this.issuingDate, extractionExtractedData.issuingDate) &&
        Objects.equals(this.personalNumber, extractionExtractedData.personalNumber)&&
        Objects.equals(this.additionalProperties, extractionExtractedData.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(documentNumber, firstName, lastName, fullName, spouseName, widowName, aliasName, gender, dateOfBirth, dateOfExpiry, expiryDate, nationality, mrzLine1, mrzLine2, mrzLine3, address1, address2, address3, address4, address5, issuingAuthority, issuingCountry, documentType, placeOfBirth, issuingState, issuingDate, personalNumber, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ExtractionExtractedData {\n");
    sb.append("    documentNumber: ").append(toIndentedString(documentNumber)).append("\n");
    sb.append("    firstName: ").append(toIndentedString(firstName)).append("\n");
    sb.append("    lastName: ").append(toIndentedString(lastName)).append("\n");
    sb.append("    fullName: ").append(toIndentedString(fullName)).append("\n");
    sb.append("    spouseName: ").append(toIndentedString(spouseName)).append("\n");
    sb.append("    widowName: ").append(toIndentedString(widowName)).append("\n");
    sb.append("    aliasName: ").append(toIndentedString(aliasName)).append("\n");
    sb.append("    gender: ").append(toIndentedString(gender)).append("\n");
    sb.append("    dateOfBirth: ").append(toIndentedString(dateOfBirth)).append("\n");
    sb.append("    dateOfExpiry: ").append(toIndentedString(dateOfExpiry)).append("\n");
    sb.append("    expiryDate: ").append(toIndentedString(expiryDate)).append("\n");
    sb.append("    nationality: ").append(toIndentedString(nationality)).append("\n");
    sb.append("    mrzLine1: ").append(toIndentedString(mrzLine1)).append("\n");
    sb.append("    mrzLine2: ").append(toIndentedString(mrzLine2)).append("\n");
    sb.append("    mrzLine3: ").append(toIndentedString(mrzLine3)).append("\n");
    sb.append("    address1: ").append(toIndentedString(address1)).append("\n");
    sb.append("    address2: ").append(toIndentedString(address2)).append("\n");
    sb.append("    address3: ").append(toIndentedString(address3)).append("\n");
    sb.append("    address4: ").append(toIndentedString(address4)).append("\n");
    sb.append("    address5: ").append(toIndentedString(address5)).append("\n");
    sb.append("    issuingAuthority: ").append(toIndentedString(issuingAuthority)).append("\n");
    sb.append("    issuingCountry: ").append(toIndentedString(issuingCountry)).append("\n");
    sb.append("    documentType: ").append(toIndentedString(documentType)).append("\n");
    sb.append("    placeOfBirth: ").append(toIndentedString(placeOfBirth)).append("\n");
    sb.append("    issuingState: ").append(toIndentedString(issuingState)).append("\n");
    sb.append("    issuingDate: ").append(toIndentedString(issuingDate)).append("\n");
    sb.append("    personalNumber: ").append(toIndentedString(personalNumber)).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_number");
    openapiFields.add("first_name");
    openapiFields.add("last_name");
    openapiFields.add("full_name");
    openapiFields.add("spouse_name");
    openapiFields.add("widow_name");
    openapiFields.add("alias_name");
    openapiFields.add("gender");
    openapiFields.add("date_of_birth");
    openapiFields.add("date_of_expiry");
    openapiFields.add("expiry_date");
    openapiFields.add("nationality");
    openapiFields.add("mrz_line_1");
    openapiFields.add("mrz_line_2");
    openapiFields.add("mrz_line_3");
    openapiFields.add("address_1");
    openapiFields.add("address_2");
    openapiFields.add("address_3");
    openapiFields.add("address_4");
    openapiFields.add("address_5");
    openapiFields.add("issuing_authority");
    openapiFields.add("issuing_country");
    openapiFields.add("document_type");
    openapiFields.add("place_of_birth");
    openapiFields.add("issuing_state");
    openapiFields.add("issuing_date");
    openapiFields.add("personal_number");

    // 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 ExtractionExtractedData
  */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!ExtractionExtractedData.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in ExtractionExtractedData is not found in the empty JSON string", ExtractionExtractedData.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      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("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("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("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("spouse_name") != null && !jsonObj.get("spouse_name").isJsonNull()) && !jsonObj.get("spouse_name").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `spouse_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("spouse_name").toString()));
      }
      if ((jsonObj.get("widow_name") != null && !jsonObj.get("widow_name").isJsonNull()) && !jsonObj.get("widow_name").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `widow_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("widow_name").toString()));
      }
      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("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()));
      }
      // validate the optional field `gender`
      if (jsonObj.get("gender") != null && !jsonObj.get("gender").isJsonNull()) {
        GenderEnum.validateJsonElement(jsonObj.get("gender"));
      }
      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("mrz_line_1") != null && !jsonObj.get("mrz_line_1").isJsonNull()) && !jsonObj.get("mrz_line_1").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `mrz_line_1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mrz_line_1").toString()));
      }
      if ((jsonObj.get("mrz_line_2") != null && !jsonObj.get("mrz_line_2").isJsonNull()) && !jsonObj.get("mrz_line_2").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `mrz_line_2` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mrz_line_2").toString()));
      }
      if ((jsonObj.get("mrz_line_3") != null && !jsonObj.get("mrz_line_3").isJsonNull()) && !jsonObj.get("mrz_line_3").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `mrz_line_3` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mrz_line_3").toString()));
      }
      if ((jsonObj.get("address_1") != null && !jsonObj.get("address_1").isJsonNull()) && !jsonObj.get("address_1").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `address_1` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_1").toString()));
      }
      if ((jsonObj.get("address_2") != null && !jsonObj.get("address_2").isJsonNull()) && !jsonObj.get("address_2").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `address_2` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_2").toString()));
      }
      if ((jsonObj.get("address_3") != null && !jsonObj.get("address_3").isJsonNull()) && !jsonObj.get("address_3").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `address_3` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_3").toString()));
      }
      if ((jsonObj.get("address_4") != null && !jsonObj.get("address_4").isJsonNull()) && !jsonObj.get("address_4").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `address_4` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_4").toString()));
      }
      if ((jsonObj.get("address_5") != null && !jsonObj.get("address_5").isJsonNull()) && !jsonObj.get("address_5").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `address_5` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address_5").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()));
      }
      // validate the optional field `issuing_country`
      if (jsonObj.get("issuing_country") != null && !jsonObj.get("issuing_country").isJsonNull()) {
        CountryCodes.validateJsonElement(jsonObj.get("issuing_country"));
      }
      // validate the optional field `document_type`
      if (jsonObj.get("document_type") != null && !jsonObj.get("document_type").isJsonNull()) {
        DocumentTypes.validateJsonElement(jsonObj.get("document_type"));
      }
      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("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("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()));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!ExtractionExtractedData.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'ExtractionExtractedData' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(ExtractionExtractedData.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, ExtractionExtractedData 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 ExtractionExtractedData read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             JsonObject jsonObj = jsonElement.getAsJsonObject();
             // store additional fields in the deserialized instance
             ExtractionExtractedData 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 ExtractionExtractedData given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of ExtractionExtractedData
  * @throws IOException if the JSON string is invalid with respect to ExtractionExtractedData
  */
  public static ExtractionExtractedData fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, ExtractionExtractedData.class);
  }

 /**
  * Convert an instance of ExtractionExtractedData to an JSON string
  *
  * @return JSON string
  */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy