java/src/main/java/com/konfigthis/dojah/client/model/GetVoterResponseEntity.java
<reponame>dojah-inc/dojah-sdks<filename>java/src/main/java/com/konfigthis/dojah/client/model/GetVoterResponseEntity.java/*
 * DOJAH APIs
 * Use Dojah to verify, onboard and manage user identity across Africa!
 *
 * The version of the OpenAPI document: 1.0.0
 * 
 *
 * NOTE: This class is auto generated by Konfig (https://konfigthis.com).
 * Do not edit the class manually.
 */


package com.konfigthis.dojah.client.model;

import java.util.Objects;
import java.util.Arrays;
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 io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.IOException;

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 org.apache.commons.lang3.StringUtils;

import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

import com.konfigthis.dojah.client.JSON;

/**
 * GetVoterResponseEntity
 */
@javax.annotation.Generated(value = "Generated by https://konfigthis.com")
public class GetVoterResponseEntity {
  public static final String SERIALIZED_NAME_VOTER_NUMBER = "voter_number";
  @SerializedName(SERIALIZED_NAME_VOTER_NUMBER)
  private String voterNumber;

  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_GENDER = "gender";
  @SerializedName(SERIALIZED_NAME_GENDER)
  private String gender;

  public static final String SERIALIZED_NAME_VILLAGE = "village";
  @SerializedName(SERIALIZED_NAME_VILLAGE)
  private String village;

  public static final String SERIALIZED_NAME_DISTRICT = "district";
  @SerializedName(SERIALIZED_NAME_DISTRICT)
  private String district;

  public static final String SERIALIZED_NAME_CONSTITUENCY = "constituency";
  @SerializedName(SERIALIZED_NAME_CONSTITUENCY)
  private String constituency;

  public static final String SERIALIZED_NAME_SUB_COUNTY = "sub_county";
  @SerializedName(SERIALIZED_NAME_SUB_COUNTY)
  private String subCounty;

  public static final String SERIALIZED_NAME_PARISH = "parish";
  @SerializedName(SERIALIZED_NAME_PARISH)
  private String parish;

  public static final String SERIALIZED_NAME_POLLING_STATION = "polling_station";
  @SerializedName(SERIALIZED_NAME_POLLING_STATION)
  private String pollingStation;

  public static final String SERIALIZED_NAME_IS_FIRST_NAME_MATCH = "is_first_name_match";
  @SerializedName(SERIALIZED_NAME_IS_FIRST_NAME_MATCH)
  private Boolean isFirstNameMatch;

  public static final String SERIALIZED_NAME_IS_LAST_NAME_MATCH = "is_last_name_match";
  @SerializedName(SERIALIZED_NAME_IS_LAST_NAME_MATCH)
  private Boolean isLastNameMatch;

  public GetVoterResponseEntity() {
  }

  public GetVoterResponseEntity voterNumber(String voterNumber) {

    
    
    
    
    this.voterNumber = voterNumber;
    return this;
  }

   /**
   * Get voterNumber
   * @return voterNumber
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getVoterNumber() {
    return voterNumber;
  }


  public void setVoterNumber(String voterNumber) {

    
    
    
    this.voterNumber = voterNumber;
  }


  public GetVoterResponseEntity firstName(String firstName) {

    
    
    
    
    this.firstName = firstName;
    return this;
  }

   /**
   * Get firstName
   * @return firstName
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getFirstName() {
    return firstName;
  }


  public void setFirstName(String firstName) {

    
    
    
    this.firstName = firstName;
  }


  public GetVoterResponseEntity lastName(String lastName) {

    
    
    
    
    this.lastName = lastName;
    return this;
  }

   /**
   * Get lastName
   * @return lastName
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getLastName() {
    return lastName;
  }


  public void setLastName(String lastName) {

    
    
    
    this.lastName = lastName;
  }


  public GetVoterResponseEntity gender(String gender) {

    
    
    
    
    this.gender = gender;
    return this;
  }

   /**
   * Get gender
   * @return gender
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getGender() {
    return gender;
  }


  public void setGender(String gender) {

    
    
    
    this.gender = gender;
  }


  public GetVoterResponseEntity village(String village) {

    
    
    
    
    this.village = village;
    return this;
  }

   /**
   * Get village
   * @return village
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getVillage() {
    return village;
  }


  public void setVillage(String village) {

    
    
    
    this.village = village;
  }


  public GetVoterResponseEntity district(String district) {

    
    
    
    
    this.district = district;
    return this;
  }

   /**
   * Get district
   * @return district
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getDistrict() {
    return district;
  }


  public void setDistrict(String district) {

    
    
    
    this.district = district;
  }


  public GetVoterResponseEntity constituency(String constituency) {

    
    
    
    
    this.constituency = constituency;
    return this;
  }

   /**
   * Get constituency
   * @return constituency
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getConstituency() {
    return constituency;
  }


  public void setConstituency(String constituency) {

    
    
    
    this.constituency = constituency;
  }


  public GetVoterResponseEntity subCounty(String subCounty) {

    
    
    
    
    this.subCounty = subCounty;
    return this;
  }

   /**
   * Get subCounty
   * @return subCounty
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getSubCounty() {
    return subCounty;
  }


  public void setSubCounty(String subCounty) {

    
    
    
    this.subCounty = subCounty;
  }


  public GetVoterResponseEntity parish(String parish) {

    
    
    
    
    this.parish = parish;
    return this;
  }

   /**
   * Get parish
   * @return parish
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getParish() {
    return parish;
  }


  public void setParish(String parish) {

    
    
    
    this.parish = parish;
  }


  public GetVoterResponseEntity pollingStation(String pollingStation) {

    
    
    
    
    this.pollingStation = pollingStation;
    return this;
  }

   /**
   * Get pollingStation
   * @return pollingStation
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public String getPollingStation() {
    return pollingStation;
  }


  public void setPollingStation(String pollingStation) {

    
    
    
    this.pollingStation = pollingStation;
  }


  public GetVoterResponseEntity isFirstNameMatch(Boolean isFirstNameMatch) {

    
    
    
    
    this.isFirstNameMatch = isFirstNameMatch;
    return this;
  }

   /**
   * Get isFirstNameMatch
   * @return isFirstNameMatch
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public Boolean getIsFirstNameMatch() {
    return isFirstNameMatch;
  }


  public void setIsFirstNameMatch(Boolean isFirstNameMatch) {

    
    
    
    this.isFirstNameMatch = isFirstNameMatch;
  }


  public GetVoterResponseEntity isLastNameMatch(Boolean isLastNameMatch) {

    
    
    
    
    this.isLastNameMatch = isLastNameMatch;
    return this;
  }

   /**
   * Get isLastNameMatch
   * @return isLastNameMatch
  **/
  @javax.annotation.Nonnull
  @ApiModelProperty(required = true, value = "")

  public Boolean getIsLastNameMatch() {
    return isLastNameMatch;
  }


  public void setIsLastNameMatch(Boolean isLastNameMatch) {

    
    
    
    this.isLastNameMatch = isLastNameMatch;
  }

  /**
   * 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<String, Object> 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 GetVoterResponseEntity instance itself
   */
  public GetVoterResponseEntity putAdditionalProperty(String key, Object value) {
    if (this.additionalProperties == null) {
        this.additionalProperties = new HashMap<String, Object>();
    }
    this.additionalProperties.put(key, value);
    return this;
  }

  /**
   * Return the additional (undeclared) property.
   *
   * @return a map of objects
   */
  public Map<String, Object> 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;
    }
    GetVoterResponseEntity getVoterResponseEntity = (GetVoterResponseEntity) o;
    return Objects.equals(this.voterNumber, getVoterResponseEntity.voterNumber) &&
        Objects.equals(this.firstName, getVoterResponseEntity.firstName) &&
        Objects.equals(this.lastName, getVoterResponseEntity.lastName) &&
        Objects.equals(this.gender, getVoterResponseEntity.gender) &&
        Objects.equals(this.village, getVoterResponseEntity.village) &&
        Objects.equals(this.district, getVoterResponseEntity.district) &&
        Objects.equals(this.constituency, getVoterResponseEntity.constituency) &&
        Objects.equals(this.subCounty, getVoterResponseEntity.subCounty) &&
        Objects.equals(this.parish, getVoterResponseEntity.parish) &&
        Objects.equals(this.pollingStation, getVoterResponseEntity.pollingStation) &&
        Objects.equals(this.isFirstNameMatch, getVoterResponseEntity.isFirstNameMatch) &&
        Objects.equals(this.isLastNameMatch, getVoterResponseEntity.isLastNameMatch)&&
        Objects.equals(this.additionalProperties, getVoterResponseEntity.additionalProperties);
  }

  @Override
  public int hashCode() {
    return Objects.hash(voterNumber, firstName, lastName, gender, village, district, constituency, subCounty, parish, pollingStation, isFirstNameMatch, isLastNameMatch, additionalProperties);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class GetVoterResponseEntity {\n");
    sb.append("    voterNumber: ").append(toIndentedString(voterNumber)).append("\n");
    sb.append("    firstName: ").append(toIndentedString(firstName)).append("\n");
    sb.append("    lastName: ").append(toIndentedString(lastName)).append("\n");
    sb.append("    gender: ").append(toIndentedString(gender)).append("\n");
    sb.append("    village: ").append(toIndentedString(village)).append("\n");
    sb.append("    district: ").append(toIndentedString(district)).append("\n");
    sb.append("    constituency: ").append(toIndentedString(constituency)).append("\n");
    sb.append("    subCounty: ").append(toIndentedString(subCounty)).append("\n");
    sb.append("    parish: ").append(toIndentedString(parish)).append("\n");
    sb.append("    pollingStation: ").append(toIndentedString(pollingStation)).append("\n");
    sb.append("    isFirstNameMatch: ").append(toIndentedString(isFirstNameMatch)).append("\n");
    sb.append("    isLastNameMatch: ").append(toIndentedString(isLastNameMatch)).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<String> openapiFields;
  public static HashSet<String> openapiRequiredFields;

  static {
    // a set of all properties/fields (JSON key names)
    openapiFields = new HashSet<String>();
    openapiFields.add("voter_number");
    openapiFields.add("first_name");
    openapiFields.add("last_name");
    openapiFields.add("gender");
    openapiFields.add("village");
    openapiFields.add("district");
    openapiFields.add("constituency");
    openapiFields.add("sub_county");
    openapiFields.add("parish");
    openapiFields.add("polling_station");
    openapiFields.add("is_first_name_match");
    openapiFields.add("is_last_name_match");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet<String>();
    openapiRequiredFields.add("voter_number");
    openapiRequiredFields.add("first_name");
    openapiRequiredFields.add("last_name");
    openapiRequiredFields.add("gender");
    openapiRequiredFields.add("village");
    openapiRequiredFields.add("district");
    openapiRequiredFields.add("constituency");
    openapiRequiredFields.add("sub_county");
    openapiRequiredFields.add("parish");
    openapiRequiredFields.add("polling_station");
    openapiRequiredFields.add("is_first_name_match");
    openapiRequiredFields.add("is_last_name_match");
  }

 /**
  * Validates the JSON Object and throws an exception if issues found
  *
  * @param jsonObj JSON Object
  * @throws IOException if the JSON Object is invalid with respect to GetVoterResponseEntity
  */
  public static void validateJsonObject(JsonObject jsonObj) throws IOException {
      if (jsonObj == null) {
        if (!GetVoterResponseEntity.openapiRequiredFields.isEmpty()) { // has required fields but JSON object is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in GetVoterResponseEntity is not found in the empty JSON string", GetVoterResponseEntity.openapiRequiredFields.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : GetVoterResponseEntity.openapiRequiredFields) {
        if (jsonObj.get(requiredField) == null) {
          throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, jsonObj.toString()));
        }
      }
      if (!jsonObj.get("voter_number").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `voter_number` to be a primitive type in the JSON string but got `%s`", jsonObj.get("voter_number").toString()));
      }
      if (!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").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("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("village").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `village` to be a primitive type in the JSON string but got `%s`", jsonObj.get("village").toString()));
      }
      if (!jsonObj.get("district").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `district` to be a primitive type in the JSON string but got `%s`", jsonObj.get("district").toString()));
      }
      if (!jsonObj.get("constituency").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `constituency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("constituency").toString()));
      }
      if (!jsonObj.get("sub_county").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `sub_county` to be a primitive type in the JSON string but got `%s`", jsonObj.get("sub_county").toString()));
      }
      if (!jsonObj.get("parish").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `parish` to be a primitive type in the JSON string but got `%s`", jsonObj.get("parish").toString()));
      }
      if (!jsonObj.get("polling_station").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `polling_station` to be a primitive type in the JSON string but got `%s`", jsonObj.get("polling_station").toString()));
      }
  }

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

       return (TypeAdapter<T>) new TypeAdapter<GetVoterResponseEntity>() {
           @Override
           public void write(JsonWriter out, GetVoterResponseEntity value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             obj.remove("additionalProperties");
             // serialize additonal properties
             if (value.getAdditionalProperties() != null) {
               for (Map.Entry<String, Object> 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 {
                   obj.add(entry.getKey(), gson.toJsonTree(entry.getValue()).getAsJsonObject());
                 }
               }
             }
             elementAdapter.write(out, obj);
           }

           @Override
           public GetVoterResponseEntity read(JsonReader in) throws IOException {
             JsonObject jsonObj = elementAdapter.read(in).getAsJsonObject();
             validateJsonObject(jsonObj);
             // store additional fields in the deserialized instance
             GetVoterResponseEntity instance = thisAdapter.fromJsonTree(jsonObj);
             for (Map.Entry<String, JsonElement> 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 GetVoterResponseEntity given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of GetVoterResponseEntity
  * @throws IOException if the JSON string is invalid with respect to GetVoterResponseEntity
  */
  public static GetVoterResponseEntity fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, GetVoterResponseEntity.class);
  }

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

