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

com.onfido.model.DocumentIQReasons 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.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;

/**
 * DocumentIQReasons
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.9.0")
public class DocumentIQReasons {
  public static final String SERIALIZED_NAME_DARK_PHOTO = "dark_photo";
  @SerializedName(SERIALIZED_NAME_DARK_PHOTO)
  private String darkPhoto;

  public static final String SERIALIZED_NAME_GLARE_ON_PHOTO = "glare_on_photo";
  @SerializedName(SERIALIZED_NAME_GLARE_ON_PHOTO)
  private String glareOnPhoto;

  public static final String SERIALIZED_NAME_BLURRED_PHOTO = "blurred_photo";
  @SerializedName(SERIALIZED_NAME_BLURRED_PHOTO)
  private String blurredPhoto;

  public static final String SERIALIZED_NAME_COVERED_PHOTO = "covered_photo";
  @SerializedName(SERIALIZED_NAME_COVERED_PHOTO)
  private String coveredPhoto;

  public static final String SERIALIZED_NAME_OTHER_PHOTO_ISSUE = "other_photo_issue";
  @SerializedName(SERIALIZED_NAME_OTHER_PHOTO_ISSUE)
  private String otherPhotoIssue;

  public static final String SERIALIZED_NAME_DAMAGED_DOCUMENT = "damaged_document";
  @SerializedName(SERIALIZED_NAME_DAMAGED_DOCUMENT)
  private String damagedDocument;

  public static final String SERIALIZED_NAME_INCORRECT_SIDE = "incorrect_side";
  @SerializedName(SERIALIZED_NAME_INCORRECT_SIDE)
  private String incorrectSide;

  public static final String SERIALIZED_NAME_CUT_OFF_DOCUMENT = "cut_off_document";
  @SerializedName(SERIALIZED_NAME_CUT_OFF_DOCUMENT)
  private String cutOffDocument;

  public static final String SERIALIZED_NAME_NO_DOCUMENT_IN_IMAGE = "no_document_in_image";
  @SerializedName(SERIALIZED_NAME_NO_DOCUMENT_IN_IMAGE)
  private String noDocumentInImage;

  public static final String SERIALIZED_NAME_TWO_DOCUMENTS_UPLOADED = "two_documents_uploaded";
  @SerializedName(SERIALIZED_NAME_TWO_DOCUMENTS_UPLOADED)
  private String twoDocumentsUploaded;

  public DocumentIQReasons() {
  }

  public DocumentIQReasons darkPhoto(String darkPhoto) {
    this.darkPhoto = darkPhoto;
    return this;
  }

  /**
   * When an image of the document is too dark to be able to see data points.
   * @return darkPhoto
   */
  @javax.annotation.Nullable
  public String getDarkPhoto() {
    return darkPhoto;
  }

  public void setDarkPhoto(String darkPhoto) {
    this.darkPhoto = darkPhoto;
  }


  public DocumentIQReasons glareOnPhoto(String glareOnPhoto) {
    this.glareOnPhoto = glareOnPhoto;
    return this;
  }

  /**
   * When there is light reflecting on the document causing glare to obstruct data points.
   * @return glareOnPhoto
   */
  @javax.annotation.Nullable
  public String getGlareOnPhoto() {
    return glareOnPhoto;
  }

  public void setGlareOnPhoto(String glareOnPhoto) {
    this.glareOnPhoto = glareOnPhoto;
  }


  public DocumentIQReasons blurredPhoto(String blurredPhoto) {
    this.blurredPhoto = blurredPhoto;
    return this;
  }

  /**
   * When data points are blurred and no reference can be made elsewhere in the document or if the data points are too blurry and 'they could be something else'.
   * @return blurredPhoto
   */
  @javax.annotation.Nullable
  public String getBlurredPhoto() {
    return blurredPhoto;
  }

  public void setBlurredPhoto(String blurredPhoto) {
    this.blurredPhoto = blurredPhoto;
  }


  public DocumentIQReasons coveredPhoto(String coveredPhoto) {
    this.coveredPhoto = coveredPhoto;
    return this;
  }

  /**
   * When data points have been covered either by the applicant or by another object such as a sticker.
   * @return coveredPhoto
   */
  @javax.annotation.Nullable
  public String getCoveredPhoto() {
    return coveredPhoto;
  }

  public void setCoveredPhoto(String coveredPhoto) {
    this.coveredPhoto = coveredPhoto;
  }


  public DocumentIQReasons otherPhotoIssue(String otherPhotoIssue) {
    this.otherPhotoIssue = otherPhotoIssue;
    return this;
  }

  /**
   * Any other reason not listed, such as when holograms are obscuring data points.
   * @return otherPhotoIssue
   */
  @javax.annotation.Nullable
  public String getOtherPhotoIssue() {
    return otherPhotoIssue;
  }

  public void setOtherPhotoIssue(String otherPhotoIssue) {
    this.otherPhotoIssue = otherPhotoIssue;
  }


  public DocumentIQReasons damagedDocument(String damagedDocument) {
    this.damagedDocument = damagedDocument;
    return this;
  }

  /**
   * When a document is damaged and we are unable to make out data points.
   * @return damagedDocument
   */
  @javax.annotation.Nullable
  public String getDamagedDocument() {
    return damagedDocument;
  }

  public void setDamagedDocument(String damagedDocument) {
    this.damagedDocument = damagedDocument;
  }


  public DocumentIQReasons incorrectSide(String incorrectSide) {
    this.incorrectSide = incorrectSide;
    return this;
  }

  /**
   * When the incorrect side of a document has been uploaded, and we have not received the front.
   * @return incorrectSide
   */
  @javax.annotation.Nullable
  public String getIncorrectSide() {
    return incorrectSide;
  }

  public void setIncorrectSide(String incorrectSide) {
    this.incorrectSide = incorrectSide;
  }


  public DocumentIQReasons cutOffDocument(String cutOffDocument) {
    this.cutOffDocument = cutOffDocument;
    return this;
  }

  /**
   * When data points are not included in the image due to the document being cut off.
   * @return cutOffDocument
   */
  @javax.annotation.Nullable
  public String getCutOffDocument() {
    return cutOffDocument;
  }

  public void setCutOffDocument(String cutOffDocument) {
    this.cutOffDocument = cutOffDocument;
  }


  public DocumentIQReasons noDocumentInImage(String noDocumentInImage) {
    this.noDocumentInImage = noDocumentInImage;
    return this;
  }

  /**
   * If no document has been uploaded or there is a blank image.
   * @return noDocumentInImage
   */
  @javax.annotation.Nullable
  public String getNoDocumentInImage() {
    return noDocumentInImage;
  }

  public void setNoDocumentInImage(String noDocumentInImage) {
    this.noDocumentInImage = noDocumentInImage;
  }


  public DocumentIQReasons twoDocumentsUploaded(String twoDocumentsUploaded) {
    this.twoDocumentsUploaded = twoDocumentsUploaded;
    return this;
  }

  /**
   * When 2 different documents are submitted in the same check.
   * @return twoDocumentsUploaded
   */
  @javax.annotation.Nullable
  public String getTwoDocumentsUploaded() {
    return twoDocumentsUploaded;
  }

  public void setTwoDocumentsUploaded(String twoDocumentsUploaded) {
    this.twoDocumentsUploaded = twoDocumentsUploaded;
  }

  /**
   * 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 DocumentIQReasons instance itself
   */
  public DocumentIQReasons 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;
    }
    DocumentIQReasons documentIQReasons = (DocumentIQReasons) o;
    return Objects.equals(this.darkPhoto, documentIQReasons.darkPhoto) &&
        Objects.equals(this.glareOnPhoto, documentIQReasons.glareOnPhoto) &&
        Objects.equals(this.blurredPhoto, documentIQReasons.blurredPhoto) &&
        Objects.equals(this.coveredPhoto, documentIQReasons.coveredPhoto) &&
        Objects.equals(this.otherPhotoIssue, documentIQReasons.otherPhotoIssue) &&
        Objects.equals(this.damagedDocument, documentIQReasons.damagedDocument) &&
        Objects.equals(this.incorrectSide, documentIQReasons.incorrectSide) &&
        Objects.equals(this.cutOffDocument, documentIQReasons.cutOffDocument) &&
        Objects.equals(this.noDocumentInImage, documentIQReasons.noDocumentInImage) &&
        Objects.equals(this.twoDocumentsUploaded, documentIQReasons.twoDocumentsUploaded)&&
        Objects.equals(this.additionalProperties, documentIQReasons.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(darkPhoto, glareOnPhoto, blurredPhoto, coveredPhoto, otherPhotoIssue, damagedDocument, incorrectSide, cutOffDocument, noDocumentInImage, twoDocumentsUploaded, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class DocumentIQReasons {\n");
    sb.append("    darkPhoto: ").append(toIndentedString(darkPhoto)).append("\n");
    sb.append("    glareOnPhoto: ").append(toIndentedString(glareOnPhoto)).append("\n");
    sb.append("    blurredPhoto: ").append(toIndentedString(blurredPhoto)).append("\n");
    sb.append("    coveredPhoto: ").append(toIndentedString(coveredPhoto)).append("\n");
    sb.append("    otherPhotoIssue: ").append(toIndentedString(otherPhotoIssue)).append("\n");
    sb.append("    damagedDocument: ").append(toIndentedString(damagedDocument)).append("\n");
    sb.append("    incorrectSide: ").append(toIndentedString(incorrectSide)).append("\n");
    sb.append("    cutOffDocument: ").append(toIndentedString(cutOffDocument)).append("\n");
    sb.append("    noDocumentInImage: ").append(toIndentedString(noDocumentInImage)).append("\n");
    sb.append("    twoDocumentsUploaded: ").append(toIndentedString(twoDocumentsUploaded)).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("dark_photo");
    openapiFields.add("glare_on_photo");
    openapiFields.add("blurred_photo");
    openapiFields.add("covered_photo");
    openapiFields.add("other_photo_issue");
    openapiFields.add("damaged_document");
    openapiFields.add("incorrect_side");
    openapiFields.add("cut_off_document");
    openapiFields.add("no_document_in_image");
    openapiFields.add("two_documents_uploaded");

    // 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 DocumentIQReasons
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!DocumentIQReasons.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in DocumentIQReasons is not found in the empty JSON string", DocumentIQReasons.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("dark_photo") != null && !jsonObj.get("dark_photo").isJsonNull()) && !jsonObj.get("dark_photo").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `dark_photo` to be a primitive type in the JSON string but got `%s`", jsonObj.get("dark_photo").toString()));
      }
      if ((jsonObj.get("glare_on_photo") != null && !jsonObj.get("glare_on_photo").isJsonNull()) && !jsonObj.get("glare_on_photo").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `glare_on_photo` to be a primitive type in the JSON string but got `%s`", jsonObj.get("glare_on_photo").toString()));
      }
      if ((jsonObj.get("blurred_photo") != null && !jsonObj.get("blurred_photo").isJsonNull()) && !jsonObj.get("blurred_photo").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `blurred_photo` to be a primitive type in the JSON string but got `%s`", jsonObj.get("blurred_photo").toString()));
      }
      if ((jsonObj.get("covered_photo") != null && !jsonObj.get("covered_photo").isJsonNull()) && !jsonObj.get("covered_photo").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `covered_photo` to be a primitive type in the JSON string but got `%s`", jsonObj.get("covered_photo").toString()));
      }
      if ((jsonObj.get("other_photo_issue") != null && !jsonObj.get("other_photo_issue").isJsonNull()) && !jsonObj.get("other_photo_issue").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `other_photo_issue` to be a primitive type in the JSON string but got `%s`", jsonObj.get("other_photo_issue").toString()));
      }
      if ((jsonObj.get("damaged_document") != null && !jsonObj.get("damaged_document").isJsonNull()) && !jsonObj.get("damaged_document").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `damaged_document` to be a primitive type in the JSON string but got `%s`", jsonObj.get("damaged_document").toString()));
      }
      if ((jsonObj.get("incorrect_side") != null && !jsonObj.get("incorrect_side").isJsonNull()) && !jsonObj.get("incorrect_side").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `incorrect_side` to be a primitive type in the JSON string but got `%s`", jsonObj.get("incorrect_side").toString()));
      }
      if ((jsonObj.get("cut_off_document") != null && !jsonObj.get("cut_off_document").isJsonNull()) && !jsonObj.get("cut_off_document").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `cut_off_document` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cut_off_document").toString()));
      }
      if ((jsonObj.get("no_document_in_image") != null && !jsonObj.get("no_document_in_image").isJsonNull()) && !jsonObj.get("no_document_in_image").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `no_document_in_image` to be a primitive type in the JSON string but got `%s`", jsonObj.get("no_document_in_image").toString()));
      }
      if ((jsonObj.get("two_documents_uploaded") != null && !jsonObj.get("two_documents_uploaded").isJsonNull()) && !jsonObj.get("two_documents_uploaded").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `two_documents_uploaded` to be a primitive type in the JSON string but got `%s`", jsonObj.get("two_documents_uploaded").toString()));
      }
  }

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

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

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





© 2015 - 2025 Weber Informatics LLC | Privacy Policy