/* * Tribufu API * API to access Tribufu services. * * The version of the OpenAPI document: 1.4.3 * 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.GameServerStatus; 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; /** * GameServerQuery */ @javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2026-06-15T20:18:39.326231700-03:00[America/Sao_Paulo]", comments = "Generator version: 7.12.0") public class GameServerQuery { public static final String SERIALIZED_NAME_ID = "id"; @SerializedName(SERIALIZED_NAME_ID) @javax.annotation.Nullable private String id; public static final String SERIALIZED_NAME_SERVER_ID = "server_id"; @SerializedName(SERIALIZED_NAME_SERVER_ID) @javax.annotation.Nullable private String serverId; public static final String SERIALIZED_NAME_STATUS = "status"; @SerializedName(SERIALIZED_NAME_STATUS) @javax.annotation.Nullable private GameServerStatus status; public static final String SERIALIZED_NAME_PING = "ping"; @SerializedName(SERIALIZED_NAME_PING) @javax.annotation.Nullable private Integer ping; public static final String SERIALIZED_NAME_CURRENT_PLAYERS = "current_players"; @SerializedName(SERIALIZED_NAME_CURRENT_PLAYERS) @javax.annotation.Nullable private Integer currentPlayers; public static final String SERIALIZED_NAME_MAX_PLAYERS = "max_players"; @SerializedName(SERIALIZED_NAME_MAX_PLAYERS) @javax.annotation.Nullable private Integer maxPlayers; public static final String SERIALIZED_NAME_MOTD = "motd"; @SerializedName(SERIALIZED_NAME_MOTD) @javax.annotation.Nullable private String motd; public static final String SERIALIZED_NAME_CREATED_AT = "created_at"; @SerializedName(SERIALIZED_NAME_CREATED_AT) @javax.annotation.Nullable private OffsetDateTime createdAt; public GameServerQuery() { } public GameServerQuery 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 GameServerQuery serverId(@javax.annotation.Nullable String serverId) { this.serverId = serverId; return this; } /** * Get serverId * @return serverId */ @javax.annotation.Nullable public String getServerId() { return serverId; } public void setServerId(@javax.annotation.Nullable String serverId) { this.serverId = serverId; } public GameServerQuery status(@javax.annotation.Nullable GameServerStatus status) { this.status = status; return this; } /** * Get status * @return status */ @javax.annotation.Nullable public GameServerStatus getStatus() { return status; } public void setStatus(@javax.annotation.Nullable GameServerStatus status) { this.status = status; } public GameServerQuery ping(@javax.annotation.Nullable Integer ping) { this.ping = ping; return this; } /** * Get ping * @return ping */ @javax.annotation.Nullable public Integer getPing() { return ping; } public void setPing(@javax.annotation.Nullable Integer ping) { this.ping = ping; } public GameServerQuery currentPlayers(@javax.annotation.Nullable Integer currentPlayers) { this.currentPlayers = currentPlayers; return this; } /** * Get currentPlayers * @return currentPlayers */ @javax.annotation.Nullable public Integer getCurrentPlayers() { return currentPlayers; } public void setCurrentPlayers(@javax.annotation.Nullable Integer currentPlayers) { this.currentPlayers = currentPlayers; } public GameServerQuery maxPlayers(@javax.annotation.Nullable Integer maxPlayers) { this.maxPlayers = maxPlayers; return this; } /** * Get maxPlayers * @return maxPlayers */ @javax.annotation.Nullable public Integer getMaxPlayers() { return maxPlayers; } public void setMaxPlayers(@javax.annotation.Nullable Integer maxPlayers) { this.maxPlayers = maxPlayers; } public GameServerQuery motd(@javax.annotation.Nullable String motd) { this.motd = motd; return this; } /** * Get motd * @return motd */ @javax.annotation.Nullable public String getMotd() { return motd; } public void setMotd(@javax.annotation.Nullable String motd) { this.motd = motd; } public GameServerQuery createdAt(@javax.annotation.Nullable OffsetDateTime createdAt) { this.createdAt = createdAt; return this; } /** * Get createdAt * @return createdAt */ @javax.annotation.Nullable public OffsetDateTime getCreatedAt() { return createdAt; } public void setCreatedAt(@javax.annotation.Nullable OffsetDateTime createdAt) { this.createdAt = createdAt; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } GameServerQuery gameServerQuery = (GameServerQuery) o; return Objects.equals(this.id, gameServerQuery.id) && Objects.equals(this.serverId, gameServerQuery.serverId) && Objects.equals(this.status, gameServerQuery.status) && Objects.equals(this.ping, gameServerQuery.ping) && Objects.equals(this.currentPlayers, gameServerQuery.currentPlayers) && Objects.equals(this.maxPlayers, gameServerQuery.maxPlayers) && Objects.equals(this.motd, gameServerQuery.motd) && Objects.equals(this.createdAt, gameServerQuery.createdAt); } private static boolean equalsNullable(JsonNullable a, JsonNullable 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, serverId, status, ping, currentPlayers, maxPlayers, motd, createdAt); } private static int hashCodeNullable(JsonNullable 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 GameServerQuery {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" serverId: ").append(toIndentedString(serverId)).append("\n"); sb.append(" status: ").append(toIndentedString(status)).append("\n"); sb.append(" ping: ").append(toIndentedString(ping)).append("\n"); sb.append(" currentPlayers: ").append(toIndentedString(currentPlayers)).append("\n"); sb.append(" maxPlayers: ").append(toIndentedString(maxPlayers)).append("\n"); sb.append(" motd: ").append(toIndentedString(motd)).append("\n"); sb.append(" createdAt: ").append(toIndentedString(createdAt)).append("\n"); sb.append("}"); return sb.toString(); } /** * Convert the given object to string with each line indented by 4 spaces * (except the first line). */ private String toIndentedString(Object o) { if (o == null) { return "null"; } return o.toString().replace("\n", "\n "); } public static HashSet openapiFields; public static HashSet openapiRequiredFields; static { // a set of all properties/fields (JSON key names) openapiFields = new HashSet(); openapiFields.add("id"); openapiFields.add("server_id"); openapiFields.add("status"); openapiFields.add("ping"); openapiFields.add("current_players"); openapiFields.add("max_players"); openapiFields.add("motd"); openapiFields.add("created_at"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); } /** * Validates the JSON Element and throws an exception if issues found * * @param jsonElement JSON Element * @throws IOException if the JSON Element is invalid with respect to GameServerQuery */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GameServerQuery.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in GameServerQuery is not found in the empty JSON string", GameServerQuery.openapiRequiredFields.toString())); } } Set> entries = jsonElement.getAsJsonObject().entrySet(); // check to see if the JSON string contains additional fields for (Map.Entry entry : entries) { if (!GameServerQuery.openapiFields.contains(entry.getKey())) { throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GameServerQuery` 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("server_id") != null && !jsonObj.get("server_id").isJsonNull()) && !jsonObj.get("server_id").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `server_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("server_id").toString())); } // validate the optional field `status` if (jsonObj.get("status") != null && !jsonObj.get("status").isJsonNull()) { GameServerStatus.validateJsonElement(jsonObj.get("status")); } if ((jsonObj.get("motd") != null && !jsonObj.get("motd").isJsonNull()) && !jsonObj.get("motd").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `motd` to be a primitive type in the JSON string but got `%s`", jsonObj.get("motd").toString())); } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { if (!GameServerQuery.class.isAssignableFrom(type.getRawType())) { return null; // this class only serializes 'GameServerQuery' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, TypeToken.get(GameServerQuery.class)); return (TypeAdapter) new TypeAdapter() { @Override public void write(JsonWriter out, GameServerQuery value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override public GameServerQuery read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); } } /** * Create an instance of GameServerQuery given an JSON string * * @param jsonString JSON string * @return An instance of GameServerQuery * @throws IOException if the JSON string is invalid with respect to GameServerQuery */ public static GameServerQuery fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GameServerQuery.class); } /** * Convert an instance of GameServerQuery to an JSON string * * @return JSON string */ public String toJson() { return JSON.getGson().toJson(this); } }