/*
 * Tribufu API
 * API to access Tribufu services.
 *
 * The version of the OpenAPI document: 1.3.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;

/**
 * GameServer
 */
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-12-27T09:52:38.593392400-03:00[America/Sao_Paulo]", comments = "Generator version: 7.12.0")
public class GameServer {
  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_DESCRIPTION = "description";
  @SerializedName(SERIALIZED_NAME_DESCRIPTION)
  @javax.annotation.Nullable
  private String description;

  public static final String SERIALIZED_NAME_OWNER_ID = "owner_id";
  @SerializedName(SERIALIZED_NAME_OWNER_ID)
  @javax.annotation.Nullable
  private String ownerId;

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

  public static final String SERIALIZED_NAME_QUERY_PORT = "query_port";
  @SerializedName(SERIALIZED_NAME_QUERY_PORT)
  @javax.annotation.Nonnull
  private Integer queryPort;

  public static final String SERIALIZED_NAME_GAME_PORT = "game_port";
  @SerializedName(SERIALIZED_NAME_GAME_PORT)
  @javax.annotation.Nullable
  private Integer gamePort;

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

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

  public static final String SERIALIZED_NAME_GAME_ID = "game_id";
  @SerializedName(SERIALIZED_NAME_GAME_ID)
  @javax.annotation.Nullable
  private String gameId;

  public static final String SERIALIZED_NAME_GAME_ICON_URL = "game_icon_url";
  @SerializedName(SERIALIZED_NAME_GAME_ICON_URL)
  @javax.annotation.Nullable
  private String gameIconUrl;

  public static final String SERIALIZED_NAME_CLUSTER_ID = "cluster_id";
  @SerializedName(SERIALIZED_NAME_CLUSTER_ID)
  @javax.annotation.Nullable
  private String clusterId;

  public static final String SERIALIZED_NAME_WEBSITE_URL = "website_url";
  @SerializedName(SERIALIZED_NAME_WEBSITE_URL)
  @javax.annotation.Nullable
  private String websiteUrl;

  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_UPTIME = "uptime";
  @SerializedName(SERIALIZED_NAME_UPTIME)
  @javax.annotation.Nullable
  private Double uptime;

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

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

  public static final String SERIALIZED_NAME_DISCORD_SERVER_ID = "discord_server_id";
  @SerializedName(SERIALIZED_NAME_DISCORD_SERVER_ID)
  @javax.annotation.Nullable
  private String discordServerId;

  public static final String SERIALIZED_NAME_YOUTUBE_VIDEO_URL = "youtube_video_url";
  @SerializedName(SERIALIZED_NAME_YOUTUBE_VIDEO_URL)
  @javax.annotation.Nullable
  private String youtubeVideoUrl;

  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 GameServer() {
  }

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

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

  public void setDescription(@javax.annotation.Nullable String description) {
    this.description = description;
  }


  public GameServer ownerId(@javax.annotation.Nullable String ownerId) {
    this.ownerId = ownerId;
    return this;
  }

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

  public void setOwnerId(@javax.annotation.Nullable String ownerId) {
    this.ownerId = ownerId;
  }


  public GameServer address(@javax.annotation.Nullable String address) {
    this.address = address;
    return this;
  }

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

  public void setAddress(@javax.annotation.Nullable String address) {
    this.address = address;
  }


  public GameServer queryPort(@javax.annotation.Nonnull Integer queryPort) {
    this.queryPort = queryPort;
    return this;
  }

  /**
   * Get queryPort
   * @return queryPort
   */
  @javax.annotation.Nonnull
  public Integer getQueryPort() {
    return queryPort;
  }

  public void setQueryPort(@javax.annotation.Nonnull Integer queryPort) {
    this.queryPort = queryPort;
  }


  public GameServer gamePort(@javax.annotation.Nullable Integer gamePort) {
    this.gamePort = gamePort;
    return this;
  }

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

  public void setGamePort(@javax.annotation.Nullable Integer gamePort) {
    this.gamePort = gamePort;
  }


  public GameServer map(@javax.annotation.Nullable String map) {
    this.map = map;
    return this;
  }

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

  public void setMap(@javax.annotation.Nullable String map) {
    this.map = map;
  }


  public GameServer version(@javax.annotation.Nullable String version) {
    this.version = version;
    return this;
  }

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

  public void setVersion(@javax.annotation.Nullable String version) {
    this.version = version;
  }


  public GameServer gameId(@javax.annotation.Nullable String gameId) {
    this.gameId = gameId;
    return this;
  }

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

  public void setGameId(@javax.annotation.Nullable String gameId) {
    this.gameId = gameId;
  }


  public GameServer gameIconUrl(@javax.annotation.Nullable String gameIconUrl) {
    this.gameIconUrl = gameIconUrl;
    return this;
  }

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

  public void setGameIconUrl(@javax.annotation.Nullable String gameIconUrl) {
    this.gameIconUrl = gameIconUrl;
  }


  public GameServer clusterId(@javax.annotation.Nullable String clusterId) {
    this.clusterId = clusterId;
    return this;
  }

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

  public void setClusterId(@javax.annotation.Nullable String clusterId) {
    this.clusterId = clusterId;
  }


  public GameServer websiteUrl(@javax.annotation.Nullable String websiteUrl) {
    this.websiteUrl = websiteUrl;
    return this;
  }

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

  public void setWebsiteUrl(@javax.annotation.Nullable String websiteUrl) {
    this.websiteUrl = websiteUrl;
  }


  public GameServer 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 GameServer uptime(@javax.annotation.Nullable Double uptime) {
    this.uptime = uptime;
    return this;
  }

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

  public void setUptime(@javax.annotation.Nullable Double uptime) {
    this.uptime = uptime;
  }


  public GameServer country(@javax.annotation.Nullable String country) {
    this.country = country;
    return this;
  }

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

  public void setCountry(@javax.annotation.Nullable String country) {
    this.country = country;
  }


  public GameServer steam(@javax.annotation.Nullable Boolean steam) {
    this.steam = steam;
    return this;
  }

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

  public void setSteam(@javax.annotation.Nullable Boolean steam) {
    this.steam = steam;
  }


  public GameServer discordServerId(@javax.annotation.Nullable String discordServerId) {
    this.discordServerId = discordServerId;
    return this;
  }

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

  public void setDiscordServerId(@javax.annotation.Nullable String discordServerId) {
    this.discordServerId = discordServerId;
  }


  public GameServer youtubeVideoUrl(@javax.annotation.Nullable String youtubeVideoUrl) {
    this.youtubeVideoUrl = youtubeVideoUrl;
    return this;
  }

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

  public void setYoutubeVideoUrl(@javax.annotation.Nullable String youtubeVideoUrl) {
    this.youtubeVideoUrl = youtubeVideoUrl;
  }


  public GameServer 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 GameServer 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;
    }
    GameServer gameServer = (GameServer) o;
    return Objects.equals(this.id, gameServer.id) &&
        Objects.equals(this.name, gameServer.name) &&
        Objects.equals(this.description, gameServer.description) &&
        Objects.equals(this.ownerId, gameServer.ownerId) &&
        Objects.equals(this.address, gameServer.address) &&
        Objects.equals(this.queryPort, gameServer.queryPort) &&
        Objects.equals(this.gamePort, gameServer.gamePort) &&
        Objects.equals(this.map, gameServer.map) &&
        Objects.equals(this.version, gameServer.version) &&
        Objects.equals(this.gameId, gameServer.gameId) &&
        Objects.equals(this.gameIconUrl, gameServer.gameIconUrl) &&
        Objects.equals(this.clusterId, gameServer.clusterId) &&
        Objects.equals(this.websiteUrl, gameServer.websiteUrl) &&
        Objects.equals(this.bannerUrl, gameServer.bannerUrl) &&
        Objects.equals(this.uptime, gameServer.uptime) &&
        Objects.equals(this.country, gameServer.country) &&
        Objects.equals(this.steam, gameServer.steam) &&
        Objects.equals(this.discordServerId, gameServer.discordServerId) &&
        Objects.equals(this.youtubeVideoUrl, gameServer.youtubeVideoUrl) &&
        Objects.equals(this.created, gameServer.created) &&
        Objects.equals(this.updated, gameServer.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, name, description, ownerId, address, queryPort, gamePort, map, version, gameId, gameIconUrl, clusterId, websiteUrl, bannerUrl, uptime, country, steam, discordServerId, youtubeVideoUrl, 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 GameServer {\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    name: ").append(toIndentedString(name)).append("\n");
    sb.append("    description: ").append(toIndentedString(description)).append("\n");
    sb.append("    ownerId: ").append(toIndentedString(ownerId)).append("\n");
    sb.append("    address: ").append(toIndentedString(address)).append("\n");
    sb.append("    queryPort: ").append(toIndentedString(queryPort)).append("\n");
    sb.append("    gamePort: ").append(toIndentedString(gamePort)).append("\n");
    sb.append("    map: ").append(toIndentedString(map)).append("\n");
    sb.append("    version: ").append(toIndentedString(version)).append("\n");
    sb.append("    gameId: ").append(toIndentedString(gameId)).append("\n");
    sb.append("    gameIconUrl: ").append(toIndentedString(gameIconUrl)).append("\n");
    sb.append("    clusterId: ").append(toIndentedString(clusterId)).append("\n");
    sb.append("    websiteUrl: ").append(toIndentedString(websiteUrl)).append("\n");
    sb.append("    bannerUrl: ").append(toIndentedString(bannerUrl)).append("\n");
    sb.append("    uptime: ").append(toIndentedString(uptime)).append("\n");
    sb.append("    country: ").append(toIndentedString(country)).append("\n");
    sb.append("    steam: ").append(toIndentedString(steam)).append("\n");
    sb.append("    discordServerId: ").append(toIndentedString(discordServerId)).append("\n");
    sb.append("    youtubeVideoUrl: ").append(toIndentedString(youtubeVideoUrl)).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("name");
    openapiFields.add("description");
    openapiFields.add("owner_id");
    openapiFields.add("address");
    openapiFields.add("query_port");
    openapiFields.add("game_port");
    openapiFields.add("map");
    openapiFields.add("version");
    openapiFields.add("game_id");
    openapiFields.add("game_icon_url");
    openapiFields.add("cluster_id");
    openapiFields.add("website_url");
    openapiFields.add("banner_url");
    openapiFields.add("uptime");
    openapiFields.add("country");
    openapiFields.add("steam");
    openapiFields.add("discord_server_id");
    openapiFields.add("youtube_video_url");
    openapiFields.add("created");
    openapiFields.add("updated");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet<String>();
    openapiRequiredFields.add("name");
    openapiRequiredFields.add("address");
    openapiRequiredFields.add("query_port");
  }

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

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : GameServer.openapiRequiredFields) {
        if (jsonElement.getAsJsonObject().get(requiredField) == null) {
          throw new IllegalArgumentException(String.format("The required field `%s` is not found in the JSON string: %s", requiredField, 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("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString()));
      }
      if ((jsonObj.get("owner_id") != null && !jsonObj.get("owner_id").isJsonNull()) && !jsonObj.get("owner_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `owner_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("owner_id").toString()));
      }
      if ((jsonObj.get("address") != null && !jsonObj.get("address").isJsonNull()) && !jsonObj.get("address").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `address` to be a primitive type in the JSON string but got `%s`", jsonObj.get("address").toString()));
      }
      if ((jsonObj.get("map") != null && !jsonObj.get("map").isJsonNull()) && !jsonObj.get("map").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `map` to be a primitive type in the JSON string but got `%s`", jsonObj.get("map").toString()));
      }
      if ((jsonObj.get("version") != null && !jsonObj.get("version").isJsonNull()) && !jsonObj.get("version").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString()));
      }
      if ((jsonObj.get("game_id") != null && !jsonObj.get("game_id").isJsonNull()) && !jsonObj.get("game_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `game_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("game_id").toString()));
      }
      if ((jsonObj.get("game_icon_url") != null && !jsonObj.get("game_icon_url").isJsonNull()) && !jsonObj.get("game_icon_url").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `game_icon_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("game_icon_url").toString()));
      }
      if ((jsonObj.get("cluster_id") != null && !jsonObj.get("cluster_id").isJsonNull()) && !jsonObj.get("cluster_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `cluster_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("cluster_id").toString()));
      }
      if ((jsonObj.get("website_url") != null && !jsonObj.get("website_url").isJsonNull()) && !jsonObj.get("website_url").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `website_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("website_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("country") != null && !jsonObj.get("country").isJsonNull()) && !jsonObj.get("country").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `country` to be a primitive type in the JSON string but got `%s`", jsonObj.get("country").toString()));
      }
      if ((jsonObj.get("discord_server_id") != null && !jsonObj.get("discord_server_id").isJsonNull()) && !jsonObj.get("discord_server_id").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `discord_server_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("discord_server_id").toString()));
      }
      if ((jsonObj.get("youtube_video_url") != null && !jsonObj.get("youtube_video_url").isJsonNull()) && !jsonObj.get("youtube_video_url").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `youtube_video_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("youtube_video_url").toString()));
      }
  }

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

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

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

       }.nullSafe();
    }
  }

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

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

