/*
 * Tribufu API
 * REST API to access Tribufu services.
 *
 * The version of the OpenAPI document: 1.1.0
 * Contact: contact@tribufu.com
 *
 * 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.tribufu.generated.models;

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.tribufu.generated.models.UserType;
import java.io.IOException;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Arrays;
import java.util.UUID;
import org.openapitools.jackson.nullable.JsonNullable;

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.tribufu.generated.JSON;

/**
 * UserInfo
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-05-26T22:04:46.763378600-03:00[America/Sao_Paulo]", comments = "Generator version: 7.12.0")
public class UserInfo {
  public static final String SERIALIZED_NAME_ID = "id";
  @SerializedName(SERIALIZED_NAME_ID)
  @javax.annotation.Nullable
  private String id;

  public static final String SERIALIZED_NAME_UUID = "uuid";
  @SerializedName(SERIALIZED_NAME_UUID)
  @javax.annotation.Nullable
  private UUID uuid;

  public static final String SERIALIZED_NAME_NAME = "name";
  @SerializedName(SERIALIZED_NAME_NAME)
  @javax.annotation.Nullable
  private String name;

  public static final String SERIALIZED_NAME_DISPLAY_NAME = "display_name";
  @SerializedName(SERIALIZED_NAME_DISPLAY_NAME)
  @javax.annotation.Nullable
  private String displayName;

  public static final String SERIALIZED_NAME_EMAIL = "email";
  @SerializedName(SERIALIZED_NAME_EMAIL)
  @javax.annotation.Nullable
  private String email;

  public static final String SERIALIZED_NAME_TYPE = "type";
  @SerializedName(SERIALIZED_NAME_TYPE)
  @javax.annotation.Nullable
  private UserType type;

  public static final String SERIALIZED_NAME_FLAGS = "flags";
  @SerializedName(SERIALIZED_NAME_FLAGS)
  @javax.annotation.Nullable
  private String flags;

  public static final String SERIALIZED_NAME_PERMISSIONS = "permissions";
  @SerializedName(SERIALIZED_NAME_PERMISSIONS)
  @javax.annotation.Nullable
  private String permissions;

  public static final String SERIALIZED_NAME_VERIFIED = "verified";
  @SerializedName(SERIALIZED_NAME_VERIFIED)
  @javax.annotation.Nullable
  private Boolean verified;

  public static final String SERIALIZED_NAME_LEVEL = "level";
  @SerializedName(SERIALIZED_NAME_LEVEL)
  @javax.annotation.Nullable
  private Integer level;

  public static final String SERIALIZED_NAME_EXPERIENCE = "experience";
  @SerializedName(SERIALIZED_NAME_EXPERIENCE)
  @javax.annotation.Nullable
  private Double experience;

  public static final String SERIALIZED_NAME_PUBLIC_BIRTHDAY = "public_birthday";
  @SerializedName(SERIALIZED_NAME_PUBLIC_BIRTHDAY)
  @javax.annotation.Nullable
  private Boolean publicBirthday;

  public static final String SERIALIZED_NAME_BIRTHDAY = "birthday";
  @SerializedName(SERIALIZED_NAME_BIRTHDAY)
  @javax.annotation.Nullable
  private LocalDate birthday;

  public static final String SERIALIZED_NAME_POINTS = "points";
  @SerializedName(SERIALIZED_NAME_POINTS)
  @javax.annotation.Nullable
  private Double points;

  public static final String SERIALIZED_NAME_LOCATION = "location";
  @SerializedName(SERIALIZED_NAME_LOCATION)
  @javax.annotation.Nullable
  private String location;

  public static final String SERIALIZED_NAME_LANGUAGE = "language";
  @SerializedName(SERIALIZED_NAME_LANGUAGE)
  @javax.annotation.Nullable
  private String language;

  public static final String SERIALIZED_NAME_TIMEZONE = "timezone";
  @SerializedName(SERIALIZED_NAME_TIMEZONE)
  @javax.annotation.Nullable
  private String timezone;

  public static final String SERIALIZED_NAME_CURRENCY = "currency";
  @SerializedName(SERIALIZED_NAME_CURRENCY)
  @javax.annotation.Nullable
  private String currency;

  public static final String SERIALIZED_NAME_PHOTO_URL = "photo_url";
  @SerializedName(SERIALIZED_NAME_PHOTO_URL)
  @javax.annotation.Nullable
  private String photoUrl;

  public static final String SERIALIZED_NAME_BANNER_URL = "banner_url";
  @SerializedName(SERIALIZED_NAME_BANNER_URL)
  @javax.annotation.Nullable
  private String bannerUrl;

  public static final String SERIALIZED_NAME_LAST_ONLINE = "last_online";
  @SerializedName(SERIALIZED_NAME_LAST_ONLINE)
  @javax.annotation.Nullable
  private OffsetDateTime lastOnline;

  public static final String SERIALIZED_NAME_BIOGRAPHY = "biography";
  @SerializedName(SERIALIZED_NAME_BIOGRAPHY)
  @javax.annotation.Nullable
  private String biography;

  public static final String SERIALIZED_NAME_VIEW_COUNT = "view_count";
  @SerializedName(SERIALIZED_NAME_VIEW_COUNT)
  @javax.annotation.Nullable
  private Integer viewCount;

  public static final String SERIALIZED_NAME_CREATED = "created";
  @SerializedName(SERIALIZED_NAME_CREATED)
  @javax.annotation.Nullable
  private OffsetDateTime created;

  public static final String SERIALIZED_NAME_UPDATED = "updated";
  @SerializedName(SERIALIZED_NAME_UPDATED)
  @javax.annotation.Nullable
  private OffsetDateTime updated;

  public UserInfo() {
  }

  public UserInfo id(@javax.annotation.Nullable String id) {
    this.id = id;
    return this;
  }

  /**
   * Get id
   * @return id
   */
  @javax.annotation.Nullable
  public String getId() {
    return id;
  }

  public void setId(@javax.annotation.Nullable String id) {
    this.id = id;
  }


  public UserInfo uuid(@javax.annotation.Nullable UUID uuid) {
    this.uuid = uuid;
    return this;
  }

  /**
   * Get uuid
   * @return uuid
   */
  @javax.annotation.Nullable
  public UUID getUuid() {
    return uuid;
  }

  public void setUuid(@javax.annotation.Nullable UUID uuid) {
    this.uuid = uuid;
  }


  public UserInfo name(@javax.annotation.Nullable String name) {
    this.name = name;
    return this;
  }

  /**
   * Get name
   * @return name
   */
  @javax.annotation.Nullable
  public String getName() {
    return name;
  }

  public void setName(@javax.annotation.Nullable String name) {
    this.name = name;
  }


  public UserInfo displayName(@javax.annotation.Nullable String displayName) {
    this.displayName = displayName;
    return this;
  }

  /**
   * Get displayName
   * @return displayName
   */
  @javax.annotation.Nullable
  public String getDisplayName() {
    return displayName;
  }

  public void setDisplayName(@javax.annotation.Nullable String displayName) {
    this.displayName = displayName;
  }


  public UserInfo email(@javax.annotation.Nullable String email) {
    this.email = email;
    return this;
  }

  /**
   * Get email
   * @return email
   */
  @javax.annotation.Nullable
  public String getEmail() {
    return email;
  }

  public void setEmail(@javax.annotation.Nullable String email) {
    this.email = email;
  }


  public UserInfo type(@javax.annotation.Nullable UserType type) {
    this.type = type;
    return this;
  }

  /**
   * Get type
   * @return type
   */
  @javax.annotation.Nullable
  public UserType getType() {
    return type;
  }

  public void setType(@javax.annotation.Nullable UserType type) {
    this.type = type;
  }


  public UserInfo flags(@javax.annotation.Nullable String flags) {
    this.flags = flags;
    return this;
  }

  /**
   * Get flags
   * @return flags
   */
  @javax.annotation.Nullable
  public String getFlags() {
    return flags;
  }

  public void setFlags(@javax.annotation.Nullable String flags) {
    this.flags = flags;
  }


  public UserInfo permissions(@javax.annotation.Nullable String permissions) {
    this.permissions = permissions;
    return this;
  }

  /**
   * Get permissions
   * @return permissions
   */
  @javax.annotation.Nullable
  public String getPermissions() {
    return permissions;
  }

  public void setPermissions(@javax.annotation.Nullable String permissions) {
    this.permissions = permissions;
  }


  public UserInfo verified(@javax.annotation.Nullable Boolean verified) {
    this.verified = verified;
    return this;
  }

  /**
   * Get verified
   * @return verified
   */
  @javax.annotation.Nullable
  public Boolean getVerified() {
    return verified;
  }

  public void setVerified(@javax.annotation.Nullable Boolean verified) {
    this.verified = verified;
  }


  public UserInfo level(@javax.annotation.Nullable Integer level) {
    this.level = level;
    return this;
  }

  /**
   * Get level
   * @return level
   */
  @javax.annotation.Nullable
  public Integer getLevel() {
    return level;
  }

  public void setLevel(@javax.annotation.Nullable Integer level) {
    this.level = level;
  }


  public UserInfo experience(@javax.annotation.Nullable Double experience) {
    this.experience = experience;
    return this;
  }

  /**
   * Get experience
   * @return experience
   */
  @javax.annotation.Nullable
  public Double getExperience() {
    return experience;
  }

  public void setExperience(@javax.annotation.Nullable Double experience) {
    this.experience = experience;
  }


  public UserInfo publicBirthday(@javax.annotation.Nullable Boolean publicBirthday) {
    this.publicBirthday = publicBirthday;
    return this;
  }

  /**
   * Get publicBirthday
   * @return publicBirthday
   */
  @javax.annotation.Nullable
  public Boolean getPublicBirthday() {
    return publicBirthday;
  }

  public void setPublicBirthday(@javax.annotation.Nullable Boolean publicBirthday) {
    this.publicBirthday = publicBirthday;
  }


  public UserInfo birthday(@javax.annotation.Nullable LocalDate birthday) {
    this.birthday = birthday;
    return this;
  }

  /**
   * Get birthday
   * @return birthday
   */
  @javax.annotation.Nullable
  public LocalDate getBirthday() {
    return birthday;
  }

  public void setBirthday(@javax.annotation.Nullable LocalDate birthday) {
    this.birthday = birthday;
  }


  public UserInfo points(@javax.annotation.Nullable Double points) {
    this.points = points;
    return this;
  }

  /**
   * Get points
   * @return points
   */
  @javax.annotation.Nullable
  public Double getPoints() {
    return points;
  }

  public void setPoints(@javax.annotation.Nullable Double points) {
    this.points = points;
  }


  public UserInfo location(@javax.annotation.Nullable String location) {
    this.location = location;
    return this;
  }

  /**
   * Get location
   * @return location
   */
  @javax.annotation.Nullable
  public String getLocation() {
    return location;
  }

  public void setLocation(@javax.annotation.Nullable String location) {
    this.location = location;
  }


  public UserInfo language(@javax.annotation.Nullable String language) {
    this.language = language;
    return this;
  }

  /**
   * Get language
   * @return language
   */
  @javax.annotation.Nullable
  public String getLanguage() {
    return language;
  }

  public void setLanguage(@javax.annotation.Nullable String language) {
    this.language = language;
  }


  public UserInfo timezone(@javax.annotation.Nullable String timezone) {
    this.timezone = timezone;
    return this;
  }

  /**
   * Get timezone
   * @return timezone
   */
  @javax.annotation.Nullable
  public String getTimezone() {
    return timezone;
  }

  public void setTimezone(@javax.annotation.Nullable String timezone) {
    this.timezone = timezone;
  }


  public UserInfo currency(@javax.annotation.Nullable String currency) {
    this.currency = currency;
    return this;
  }

  /**
   * Get currency
   * @return currency
   */
  @javax.annotation.Nullable
  public String getCurrency() {
    return currency;
  }

  public void setCurrency(@javax.annotation.Nullable String currency) {
    this.currency = currency;
  }


  public UserInfo photoUrl(@javax.annotation.Nullable String photoUrl) {
    this.photoUrl = photoUrl;
    return this;
  }

  /**
   * Get photoUrl
   * @return photoUrl
   */
  @javax.annotation.Nullable
  public String getPhotoUrl() {
    return photoUrl;
  }

  public void setPhotoUrl(@javax.annotation.Nullable String photoUrl) {
    this.photoUrl = photoUrl;
  }


  public UserInfo bannerUrl(@javax.annotation.Nullable String bannerUrl) {
    this.bannerUrl = bannerUrl;
    return this;
  }

  /**
   * Get bannerUrl
   * @return bannerUrl
   */
  @javax.annotation.Nullable
  public String getBannerUrl() {
    return bannerUrl;
  }

  public void setBannerUrl(@javax.annotation.Nullable String bannerUrl) {
    this.bannerUrl = bannerUrl;
  }


  public UserInfo lastOnline(@javax.annotation.Nullable OffsetDateTime lastOnline) {
    this.lastOnline = lastOnline;
    return this;
  }

  /**
   * Get lastOnline
   * @return lastOnline
   */
  @javax.annotation.Nullable
  public OffsetDateTime getLastOnline() {
    return lastOnline;
  }

  public void setLastOnline(@javax.annotation.Nullable OffsetDateTime lastOnline) {
    this.lastOnline = lastOnline;
  }


  public UserInfo biography(@javax.annotation.Nullable String biography) {
    this.biography = biography;
    return this;
  }

  /**
   * Get biography
   * @return biography
   */
  @javax.annotation.Nullable
  public String getBiography() {
    return biography;
  }

  public void setBiography(@javax.annotation.Nullable String biography) {
    this.biography = biography;
  }


  public UserInfo viewCount(@javax.annotation.Nullable Integer viewCount) {
    this.viewCount = viewCount;
    return this;
  }

  /**
   * Get viewCount
   * @return viewCount
   */
  @javax.annotation.Nullable
  public Integer getViewCount() {
    return viewCount;
  }

  public void setViewCount(@javax.annotation.Nullable Integer viewCount) {
    this.viewCount = viewCount;
  }


  public UserInfo created(@javax.annotation.Nullable OffsetDateTime created) {
    this.created = created;
    return this;
  }

  /**
   * Get created
   * @return created
   */
  @javax.annotation.Nullable
  public OffsetDateTime getCreated() {
    return created;
  }

  public void setCreated(@javax.annotation.Nullable OffsetDateTime created) {
    this.created = created;
  }


  public UserInfo updated(@javax.annotation.Nullable OffsetDateTime updated) {
    this.updated = updated;
    return this;
  }

  /**
   * Get updated
   * @return updated
   */
  @javax.annotation.Nullable
  public OffsetDateTime getUpdated() {
    return updated;
  }

  public void setUpdated(@javax.annotation.Nullable OffsetDateTime updated) {
    this.updated = updated;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    UserInfo userInfo = (UserInfo) o;
    return Objects.equals(this.id, userInfo.id) &&
        Objects.equals(this.uuid, userInfo.uuid) &&
        Objects.equals(this.name, userInfo.name) &&
        Objects.equals(this.displayName, userInfo.displayName) &&
        Objects.equals(this.email, userInfo.email) &&
        Objects.equals(this.type, userInfo.type) &&
        Objects.equals(this.flags, userInfo.flags) &&
        Objects.equals(this.permissions, userInfo.permissions) &&
        Objects.equals(this.verified, userInfo.verified) &&
        Objects.equals(this.level, userInfo.level) &&
        Objects.equals(this.experience, userInfo.experience) &&
        Objects.equals(this.publicBirthday, userInfo.publicBirthday) &&
        Objects.equals(this.birthday, userInfo.birthday) &&
        Objects.equals(this.points, userInfo.points) &&
        Objects.equals(this.location, userInfo.location) &&
        Objects.equals(this.language, userInfo.language) &&
        Objects.equals(this.timezone, userInfo.timezone) &&
        Objects.equals(this.currency, userInfo.currency) &&
        Objects.equals(this.photoUrl, userInfo.photoUrl) &&
        Objects.equals(this.bannerUrl, userInfo.bannerUrl) &&
        Objects.equals(this.lastOnline, userInfo.lastOnline) &&
        Objects.equals(this.biography, userInfo.biography) &&
        Objects.equals(this.viewCount, userInfo.viewCount) &&
        Objects.equals(this.created, userInfo.created) &&
        Objects.equals(this.updated, userInfo.updated);
  }

  private static <T> boolean equalsNullable(JsonNullable<T> a, JsonNullable<T> b) {
    return a == b || (a != null && b != null && a.isPresent() && b.isPresent() && Objects.deepEquals(a.get(), b.get()));
  }

  @Override
  public int hashCode() {
    return Objects.hash(id, uuid, name, displayName, email, type, flags, permissions, verified, level, experience, publicBirthday, birthday, points, location, language, timezone, currency, photoUrl, bannerUrl, lastOnline, biography, viewCount, created, updated);
  }

  private static <T> int hashCodeNullable(JsonNullable<T> a) {
    if (a == null) {
      return 1;
    }
    return a.isPresent() ? Arrays.deepHashCode(new Object[]{a.get()}) : 31;
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class UserInfo {\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    uuid: ").append(toIndentedString(uuid)).append("\n");
    sb.append("    name: ").append(toIndentedString(name)).append("\n");
    sb.append("    displayName: ").append(toIndentedString(displayName)).append("\n");
    sb.append("    email: ").append(toIndentedString(email)).append("\n");
    sb.append("    type: ").append(toIndentedString(type)).append("\n");
    sb.append("    flags: ").append(toIndentedString(flags)).append("\n");
    sb.append("    permissions: ").append(toIndentedString(permissions)).append("\n");
    sb.append("    verified: ").append(toIndentedString(verified)).append("\n");
    sb.append("    level: ").append(toIndentedString(level)).append("\n");
    sb.append("    experience: ").append(toIndentedString(experience)).append("\n");
    sb.append("    publicBirthday: ").append(toIndentedString(publicBirthday)).append("\n");
    sb.append("    birthday: ").append(toIndentedString(birthday)).append("\n");
    sb.append("    points: ").append(toIndentedString(points)).append("\n");
    sb.append("    location: ").append(toIndentedString(location)).append("\n");
    sb.append("    language: ").append(toIndentedString(language)).append("\n");
    sb.append("    timezone: ").append(toIndentedString(timezone)).append("\n");
    sb.append("    currency: ").append(toIndentedString(currency)).append("\n");
    sb.append("    photoUrl: ").append(toIndentedString(photoUrl)).append("\n");
    sb.append("    bannerUrl: ").append(toIndentedString(bannerUrl)).append("\n");
    sb.append("    lastOnline: ").append(toIndentedString(lastOnline)).append("\n");
    sb.append("    biography: ").append(toIndentedString(biography)).append("\n");
    sb.append("    viewCount: ").append(toIndentedString(viewCount)).append("\n");
    sb.append("    created: ").append(toIndentedString(created)).append("\n");
    sb.append("    updated: ").append(toIndentedString(updated)).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("id");
    openapiFields.add("uuid");
    openapiFields.add("name");
    openapiFields.add("display_name");
    openapiFields.add("email");
    openapiFields.add("type");
    openapiFields.add("flags");
    openapiFields.add("permissions");
    openapiFields.add("verified");
    openapiFields.add("level");
    openapiFields.add("experience");
    openapiFields.add("public_birthday");
    openapiFields.add("birthday");
    openapiFields.add("points");
    openapiFields.add("location");
    openapiFields.add("language");
    openapiFields.add("timezone");
    openapiFields.add("currency");
    openapiFields.add("photo_url");
    openapiFields.add("banner_url");
    openapiFields.add("last_online");
    openapiFields.add("biography");
    openapiFields.add("view_count");
    openapiFields.add("created");
    openapiFields.add("updated");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet<String>();
  }

  /**
   * 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 UserInfo
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!UserInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in UserInfo is not found in the empty JSON string", UserInfo.openapiRequiredFields.toString()));
        }
      }

      Set<Map.Entry<String, JsonElement>> entries = jsonElement.getAsJsonObject().entrySet();
      // check to see if the JSON string contains additional fields
      for (Map.Entry<String, JsonElement> entry : entries) {
        if (!UserInfo.openapiFields.contains(entry.getKey())) {
          throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UserInfo` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("id") != null && !jsonObj.get("id").isJsonNull()) && !jsonObj.get("id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString()));
      }
      if ((jsonObj.get("uuid") != null && !jsonObj.get("uuid").isJsonNull()) && !jsonObj.get("uuid").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `uuid` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uuid").toString()));
      }
      if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
      }
      if ((jsonObj.get("display_name") != null && !jsonObj.get("display_name").isJsonNull()) && !jsonObj.get("display_name").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `display_name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("display_name").toString()));
      }
      if ((jsonObj.get("email") != null && !jsonObj.get("email").isJsonNull()) && !jsonObj.get("email").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString()));
      }
      // validate the optional field `type`
      if (jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) {
        UserType.validateJsonElement(jsonObj.get("type"));
      }
      if ((jsonObj.get("flags") != null && !jsonObj.get("flags").isJsonNull()) && !jsonObj.get("flags").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `flags` to be a primitive type in the JSON string but got `%s`", jsonObj.get("flags").toString()));
      }
      if ((jsonObj.get("permissions") != null && !jsonObj.get("permissions").isJsonNull()) && !jsonObj.get("permissions").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `permissions` to be a primitive type in the JSON string but got `%s`", jsonObj.get("permissions").toString()));
      }
      if ((jsonObj.get("location") != null && !jsonObj.get("location").isJsonNull()) && !jsonObj.get("location").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `location` to be a primitive type in the JSON string but got `%s`", jsonObj.get("location").toString()));
      }
      if ((jsonObj.get("language") != null && !jsonObj.get("language").isJsonNull()) && !jsonObj.get("language").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `language` to be a primitive type in the JSON string but got `%s`", jsonObj.get("language").toString()));
      }
      if ((jsonObj.get("timezone") != null && !jsonObj.get("timezone").isJsonNull()) && !jsonObj.get("timezone").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `timezone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("timezone").toString()));
      }
      if ((jsonObj.get("currency") != null && !jsonObj.get("currency").isJsonNull()) && !jsonObj.get("currency").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `currency` to be a primitive type in the JSON string but got `%s`", jsonObj.get("currency").toString()));
      }
      if ((jsonObj.get("photo_url") != null && !jsonObj.get("photo_url").isJsonNull()) && !jsonObj.get("photo_url").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `photo_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("photo_url").toString()));
      }
      if ((jsonObj.get("banner_url") != null && !jsonObj.get("banner_url").isJsonNull()) && !jsonObj.get("banner_url").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `banner_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("banner_url").toString()));
      }
      if ((jsonObj.get("biography") != null && !jsonObj.get("biography").isJsonNull()) && !jsonObj.get("biography").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `biography` to be a primitive type in the JSON string but got `%s`", jsonObj.get("biography").toString()));
      }
  }

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

       return (TypeAdapter<T>) new TypeAdapter<UserInfo>() {
           @Override
           public void write(JsonWriter out, UserInfo value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             elementAdapter.write(out, obj);
           }

           @Override
           public UserInfo read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             return thisAdapter.fromJsonTree(jsonElement);
           }

       }.nullSafe();
    }
  }

  /**
   * Create an instance of UserInfo given an JSON string
   *
   * @param jsonString JSON string
   * @return An instance of UserInfo
   * @throws IOException if the JSON string is invalid with respect to UserInfo
   */
  public static UserInfo fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, UserInfo.class);
  }

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

