/*
 * 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 java.io.IOException;
import java.time.OffsetDateTime;
import java.util.Arrays;
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;

/**
 * ProfileGame
 */
@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 ProfileGame {
  public static final String SERIALIZED_NAME_ID = "id";
  @SerializedName(SERIALIZED_NAME_ID)
  @javax.annotation.Nullable
  private String id;

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

  public static final String SERIALIZED_NAME_CAPSULE_IMAGE_URL = "capsule_image_url";
  @SerializedName(SERIALIZED_NAME_CAPSULE_IMAGE_URL)
  @javax.annotation.Nullable
  private String capsuleImageUrl;

  public static final String SERIALIZED_NAME_LIBRARY_IMAGE_URL = "library_image_url";
  @SerializedName(SERIALIZED_NAME_LIBRARY_IMAGE_URL)
  @javax.annotation.Nullable
  private String libraryImageUrl;

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

  public static final String SERIALIZED_NAME_TIME_USED = "time_used";
  @SerializedName(SERIALIZED_NAME_TIME_USED)
  @javax.annotation.Nullable
  private Double timeUsed;

  public static final String SERIALIZED_NAME_UNLOCKED_ACHIEVEMENTS = "unlocked_achievements";
  @SerializedName(SERIALIZED_NAME_UNLOCKED_ACHIEVEMENTS)
  @javax.annotation.Nullable
  private Integer unlockedAchievements;

  public static final String SERIALIZED_NAME_TOTAL_ACHIEVEMENTS = "total_achievements";
  @SerializedName(SERIALIZED_NAME_TOTAL_ACHIEVEMENTS)
  @javax.annotation.Nullable
  private Integer totalAchievements;

  public static final String SERIALIZED_NAME_STATS = "stats";
  @SerializedName(SERIALIZED_NAME_STATS)
  @javax.annotation.Nullable
  private Object stats = null;

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

  public static final String SERIALIZED_NAME_LAST_USED = "last_used";
  @SerializedName(SERIALIZED_NAME_LAST_USED)
  @javax.annotation.Nullable
  private OffsetDateTime lastUsed;

  public ProfileGame() {
  }

  public ProfileGame 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 ProfileGame 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 ProfileGame capsuleImageUrl(@javax.annotation.Nullable String capsuleImageUrl) {
    this.capsuleImageUrl = capsuleImageUrl;
    return this;
  }

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

  public void setCapsuleImageUrl(@javax.annotation.Nullable String capsuleImageUrl) {
    this.capsuleImageUrl = capsuleImageUrl;
  }


  public ProfileGame libraryImageUrl(@javax.annotation.Nullable String libraryImageUrl) {
    this.libraryImageUrl = libraryImageUrl;
    return this;
  }

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

  public void setLibraryImageUrl(@javax.annotation.Nullable String libraryImageUrl) {
    this.libraryImageUrl = libraryImageUrl;
  }


  public ProfileGame slug(@javax.annotation.Nullable String slug) {
    this.slug = slug;
    return this;
  }

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

  public void setSlug(@javax.annotation.Nullable String slug) {
    this.slug = slug;
  }


  public ProfileGame timeUsed(@javax.annotation.Nullable Double timeUsed) {
    this.timeUsed = timeUsed;
    return this;
  }

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

  public void setTimeUsed(@javax.annotation.Nullable Double timeUsed) {
    this.timeUsed = timeUsed;
  }


  public ProfileGame unlockedAchievements(@javax.annotation.Nullable Integer unlockedAchievements) {
    this.unlockedAchievements = unlockedAchievements;
    return this;
  }

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

  public void setUnlockedAchievements(@javax.annotation.Nullable Integer unlockedAchievements) {
    this.unlockedAchievements = unlockedAchievements;
  }


  public ProfileGame totalAchievements(@javax.annotation.Nullable Integer totalAchievements) {
    this.totalAchievements = totalAchievements;
    return this;
  }

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

  public void setTotalAchievements(@javax.annotation.Nullable Integer totalAchievements) {
    this.totalAchievements = totalAchievements;
  }


  public ProfileGame stats(@javax.annotation.Nullable Object stats) {
    this.stats = stats;
    return this;
  }

  /**
   * Get stats
   * @return stats
   */
  @javax.annotation.Nullable
  public Object getStats() {
    return stats;
  }

  public void setStats(@javax.annotation.Nullable Object stats) {
    this.stats = stats;
  }


  public ProfileGame acquired(@javax.annotation.Nullable OffsetDateTime acquired) {
    this.acquired = acquired;
    return this;
  }

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

  public void setAcquired(@javax.annotation.Nullable OffsetDateTime acquired) {
    this.acquired = acquired;
  }


  public ProfileGame lastUsed(@javax.annotation.Nullable OffsetDateTime lastUsed) {
    this.lastUsed = lastUsed;
    return this;
  }

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

  public void setLastUsed(@javax.annotation.Nullable OffsetDateTime lastUsed) {
    this.lastUsed = lastUsed;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    ProfileGame profileGame = (ProfileGame) o;
    return Objects.equals(this.id, profileGame.id) &&
        Objects.equals(this.name, profileGame.name) &&
        Objects.equals(this.capsuleImageUrl, profileGame.capsuleImageUrl) &&
        Objects.equals(this.libraryImageUrl, profileGame.libraryImageUrl) &&
        Objects.equals(this.slug, profileGame.slug) &&
        Objects.equals(this.timeUsed, profileGame.timeUsed) &&
        Objects.equals(this.unlockedAchievements, profileGame.unlockedAchievements) &&
        Objects.equals(this.totalAchievements, profileGame.totalAchievements) &&
        Objects.equals(this.stats, profileGame.stats) &&
        Objects.equals(this.acquired, profileGame.acquired) &&
        Objects.equals(this.lastUsed, profileGame.lastUsed);
  }

  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, name, capsuleImageUrl, libraryImageUrl, slug, timeUsed, unlockedAchievements, totalAchievements, stats, acquired, lastUsed);
  }

  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 ProfileGame {\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    name: ").append(toIndentedString(name)).append("\n");
    sb.append("    capsuleImageUrl: ").append(toIndentedString(capsuleImageUrl)).append("\n");
    sb.append("    libraryImageUrl: ").append(toIndentedString(libraryImageUrl)).append("\n");
    sb.append("    slug: ").append(toIndentedString(slug)).append("\n");
    sb.append("    timeUsed: ").append(toIndentedString(timeUsed)).append("\n");
    sb.append("    unlockedAchievements: ").append(toIndentedString(unlockedAchievements)).append("\n");
    sb.append("    totalAchievements: ").append(toIndentedString(totalAchievements)).append("\n");
    sb.append("    stats: ").append(toIndentedString(stats)).append("\n");
    sb.append("    acquired: ").append(toIndentedString(acquired)).append("\n");
    sb.append("    lastUsed: ").append(toIndentedString(lastUsed)).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("name");
    openapiFields.add("capsule_image_url");
    openapiFields.add("library_image_url");
    openapiFields.add("slug");
    openapiFields.add("time_used");
    openapiFields.add("unlocked_achievements");
    openapiFields.add("total_achievements");
    openapiFields.add("stats");
    openapiFields.add("acquired");
    openapiFields.add("last_used");

    // 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 ProfileGame
   */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!ProfileGame.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in ProfileGame is not found in the empty JSON string", ProfileGame.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 (!ProfileGame.openapiFields.contains(entry.getKey())) {
          throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ProfileGame` 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("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("capsule_image_url") != null && !jsonObj.get("capsule_image_url").isJsonNull()) && !jsonObj.get("capsule_image_url").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `capsule_image_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("capsule_image_url").toString()));
      }
      if ((jsonObj.get("library_image_url") != null && !jsonObj.get("library_image_url").isJsonNull()) && !jsonObj.get("library_image_url").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `library_image_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("library_image_url").toString()));
      }
      if ((jsonObj.get("slug") != null && !jsonObj.get("slug").isJsonNull()) && !jsonObj.get("slug").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `slug` to be a primitive type in the JSON string but got `%s`", jsonObj.get("slug").toString()));
      }
  }

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

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

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

       }.nullSafe();
    }
  }

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

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

