mirror of
https://github.com/Tribufu/TribufuJava
synced 2026-08-15 07:41:05 +00:00
773 lines
24 KiB
Java
773 lines
24 KiB
Java
/*
|
|
* 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.ApplicationType;
|
|
import java.io.IOException;
|
|
import java.net.URI;
|
|
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;
|
|
|
|
/**
|
|
* Game
|
|
*/
|
|
@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 Game {
|
|
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_TYPE = "type";
|
|
@SerializedName(SERIALIZED_NAME_TYPE)
|
|
@javax.annotation.Nullable
|
|
private ApplicationType type;
|
|
|
|
public static final String SERIALIZED_NAME_ORGANIZATION_ID = "organization_id";
|
|
@SerializedName(SERIALIZED_NAME_ORGANIZATION_ID)
|
|
@javax.annotation.Nullable
|
|
private String organizationId;
|
|
|
|
public static final String SERIALIZED_NAME_ICON_URL = "icon_url";
|
|
@SerializedName(SERIALIZED_NAME_ICON_URL)
|
|
@javax.annotation.Nullable
|
|
private URI iconUrl;
|
|
|
|
public static final String SERIALIZED_NAME_BANNER_URL = "banner_url";
|
|
@SerializedName(SERIALIZED_NAME_BANNER_URL)
|
|
@javax.annotation.Nullable
|
|
private URI bannerUrl;
|
|
|
|
public static final String SERIALIZED_NAME_CAPSULE_IMAGE_URL = "capsule_image_url";
|
|
@SerializedName(SERIALIZED_NAME_CAPSULE_IMAGE_URL)
|
|
@javax.annotation.Nullable
|
|
private URI capsuleImageUrl;
|
|
|
|
public static final String SERIALIZED_NAME_LIBRARY_IMAGE_URL = "library_image_url";
|
|
@SerializedName(SERIALIZED_NAME_LIBRARY_IMAGE_URL)
|
|
@javax.annotation.Nullable
|
|
private URI 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_CREATED_AT = "created_at";
|
|
@SerializedName(SERIALIZED_NAME_CREATED_AT)
|
|
@javax.annotation.Nullable
|
|
private OffsetDateTime createdAt;
|
|
|
|
public static final String SERIALIZED_NAME_UPDATED_AT = "updated_at";
|
|
@SerializedName(SERIALIZED_NAME_UPDATED_AT)
|
|
@javax.annotation.Nullable
|
|
private OffsetDateTime updatedAt;
|
|
|
|
public static final String SERIALIZED_NAME_DELETED_AT = "deleted_at";
|
|
@SerializedName(SERIALIZED_NAME_DELETED_AT)
|
|
@javax.annotation.Nullable
|
|
private OffsetDateTime deletedAt;
|
|
|
|
public static final String SERIALIZED_NAME_ENABLE_SERVERS = "enable_servers";
|
|
@SerializedName(SERIALIZED_NAME_ENABLE_SERVERS)
|
|
@javax.annotation.Nullable
|
|
private Boolean enableServers;
|
|
|
|
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_QUERY_PORT = "query_port";
|
|
@SerializedName(SERIALIZED_NAME_QUERY_PORT)
|
|
@javax.annotation.Nullable
|
|
private Integer queryPort;
|
|
|
|
public static final String SERIALIZED_NAME_RCON_PORT = "rcon_port";
|
|
@SerializedName(SERIALIZED_NAME_RCON_PORT)
|
|
@javax.annotation.Nullable
|
|
private Integer rconPort;
|
|
|
|
public static final String SERIALIZED_NAME_GAMEDIG_ID = "gamedig_id";
|
|
@SerializedName(SERIALIZED_NAME_GAMEDIG_ID)
|
|
@javax.annotation.Nullable
|
|
private String gamedigId;
|
|
|
|
public static final String SERIALIZED_NAME_STEAM_APP_ID = "steam_app_id";
|
|
@SerializedName(SERIALIZED_NAME_STEAM_APP_ID)
|
|
@javax.annotation.Nullable
|
|
private Integer steamAppId;
|
|
|
|
public static final String SERIALIZED_NAME_STEAM_SERVER_APP_ID = "steam_server_app_id";
|
|
@SerializedName(SERIALIZED_NAME_STEAM_SERVER_APP_ID)
|
|
@javax.annotation.Nullable
|
|
private Integer steamServerAppId;
|
|
|
|
public Game() {
|
|
}
|
|
|
|
public Game 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 Game 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 Game 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 Game type(@javax.annotation.Nullable ApplicationType type) {
|
|
this.type = type;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get type
|
|
* @return type
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public ApplicationType getType() {
|
|
return type;
|
|
}
|
|
|
|
public void setType(@javax.annotation.Nullable ApplicationType type) {
|
|
this.type = type;
|
|
}
|
|
|
|
|
|
public Game organizationId(@javax.annotation.Nullable String organizationId) {
|
|
this.organizationId = organizationId;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get organizationId
|
|
* @return organizationId
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public String getOrganizationId() {
|
|
return organizationId;
|
|
}
|
|
|
|
public void setOrganizationId(@javax.annotation.Nullable String organizationId) {
|
|
this.organizationId = organizationId;
|
|
}
|
|
|
|
|
|
public Game iconUrl(@javax.annotation.Nullable URI iconUrl) {
|
|
this.iconUrl = iconUrl;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get iconUrl
|
|
* @return iconUrl
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public URI getIconUrl() {
|
|
return iconUrl;
|
|
}
|
|
|
|
public void setIconUrl(@javax.annotation.Nullable URI iconUrl) {
|
|
this.iconUrl = iconUrl;
|
|
}
|
|
|
|
|
|
public Game bannerUrl(@javax.annotation.Nullable URI bannerUrl) {
|
|
this.bannerUrl = bannerUrl;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get bannerUrl
|
|
* @return bannerUrl
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public URI getBannerUrl() {
|
|
return bannerUrl;
|
|
}
|
|
|
|
public void setBannerUrl(@javax.annotation.Nullable URI bannerUrl) {
|
|
this.bannerUrl = bannerUrl;
|
|
}
|
|
|
|
|
|
public Game capsuleImageUrl(@javax.annotation.Nullable URI capsuleImageUrl) {
|
|
this.capsuleImageUrl = capsuleImageUrl;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get capsuleImageUrl
|
|
* @return capsuleImageUrl
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public URI getCapsuleImageUrl() {
|
|
return capsuleImageUrl;
|
|
}
|
|
|
|
public void setCapsuleImageUrl(@javax.annotation.Nullable URI capsuleImageUrl) {
|
|
this.capsuleImageUrl = capsuleImageUrl;
|
|
}
|
|
|
|
|
|
public Game libraryImageUrl(@javax.annotation.Nullable URI libraryImageUrl) {
|
|
this.libraryImageUrl = libraryImageUrl;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get libraryImageUrl
|
|
* @return libraryImageUrl
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public URI getLibraryImageUrl() {
|
|
return libraryImageUrl;
|
|
}
|
|
|
|
public void setLibraryImageUrl(@javax.annotation.Nullable URI libraryImageUrl) {
|
|
this.libraryImageUrl = libraryImageUrl;
|
|
}
|
|
|
|
|
|
public Game 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 Game 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;
|
|
}
|
|
|
|
|
|
public Game updatedAt(@javax.annotation.Nullable OffsetDateTime updatedAt) {
|
|
this.updatedAt = updatedAt;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get updatedAt
|
|
* @return updatedAt
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public OffsetDateTime getUpdatedAt() {
|
|
return updatedAt;
|
|
}
|
|
|
|
public void setUpdatedAt(@javax.annotation.Nullable OffsetDateTime updatedAt) {
|
|
this.updatedAt = updatedAt;
|
|
}
|
|
|
|
|
|
public Game deletedAt(@javax.annotation.Nullable OffsetDateTime deletedAt) {
|
|
this.deletedAt = deletedAt;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get deletedAt
|
|
* @return deletedAt
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public OffsetDateTime getDeletedAt() {
|
|
return deletedAt;
|
|
}
|
|
|
|
public void setDeletedAt(@javax.annotation.Nullable OffsetDateTime deletedAt) {
|
|
this.deletedAt = deletedAt;
|
|
}
|
|
|
|
|
|
public Game enableServers(@javax.annotation.Nullable Boolean enableServers) {
|
|
this.enableServers = enableServers;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get enableServers
|
|
* @return enableServers
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public Boolean getEnableServers() {
|
|
return enableServers;
|
|
}
|
|
|
|
public void setEnableServers(@javax.annotation.Nullable Boolean enableServers) {
|
|
this.enableServers = enableServers;
|
|
}
|
|
|
|
|
|
public Game 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 Game queryPort(@javax.annotation.Nullable Integer queryPort) {
|
|
this.queryPort = queryPort;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get queryPort
|
|
* @return queryPort
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public Integer getQueryPort() {
|
|
return queryPort;
|
|
}
|
|
|
|
public void setQueryPort(@javax.annotation.Nullable Integer queryPort) {
|
|
this.queryPort = queryPort;
|
|
}
|
|
|
|
|
|
public Game rconPort(@javax.annotation.Nullable Integer rconPort) {
|
|
this.rconPort = rconPort;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get rconPort
|
|
* @return rconPort
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public Integer getRconPort() {
|
|
return rconPort;
|
|
}
|
|
|
|
public void setRconPort(@javax.annotation.Nullable Integer rconPort) {
|
|
this.rconPort = rconPort;
|
|
}
|
|
|
|
|
|
public Game gamedigId(@javax.annotation.Nullable String gamedigId) {
|
|
this.gamedigId = gamedigId;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get gamedigId
|
|
* @return gamedigId
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public String getGamedigId() {
|
|
return gamedigId;
|
|
}
|
|
|
|
public void setGamedigId(@javax.annotation.Nullable String gamedigId) {
|
|
this.gamedigId = gamedigId;
|
|
}
|
|
|
|
|
|
public Game steamAppId(@javax.annotation.Nullable Integer steamAppId) {
|
|
this.steamAppId = steamAppId;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get steamAppId
|
|
* @return steamAppId
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public Integer getSteamAppId() {
|
|
return steamAppId;
|
|
}
|
|
|
|
public void setSteamAppId(@javax.annotation.Nullable Integer steamAppId) {
|
|
this.steamAppId = steamAppId;
|
|
}
|
|
|
|
|
|
public Game steamServerAppId(@javax.annotation.Nullable Integer steamServerAppId) {
|
|
this.steamServerAppId = steamServerAppId;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get steamServerAppId
|
|
* @return steamServerAppId
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public Integer getSteamServerAppId() {
|
|
return steamServerAppId;
|
|
}
|
|
|
|
public void setSteamServerAppId(@javax.annotation.Nullable Integer steamServerAppId) {
|
|
this.steamServerAppId = steamServerAppId;
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
public boolean equals(Object o) {
|
|
if (this == o) {
|
|
return true;
|
|
}
|
|
if (o == null || getClass() != o.getClass()) {
|
|
return false;
|
|
}
|
|
Game game = (Game) o;
|
|
return Objects.equals(this.id, game.id) &&
|
|
Objects.equals(this.name, game.name) &&
|
|
Objects.equals(this.description, game.description) &&
|
|
Objects.equals(this.type, game.type) &&
|
|
Objects.equals(this.organizationId, game.organizationId) &&
|
|
Objects.equals(this.iconUrl, game.iconUrl) &&
|
|
Objects.equals(this.bannerUrl, game.bannerUrl) &&
|
|
Objects.equals(this.capsuleImageUrl, game.capsuleImageUrl) &&
|
|
Objects.equals(this.libraryImageUrl, game.libraryImageUrl) &&
|
|
Objects.equals(this.slug, game.slug) &&
|
|
Objects.equals(this.createdAt, game.createdAt) &&
|
|
Objects.equals(this.updatedAt, game.updatedAt) &&
|
|
Objects.equals(this.deletedAt, game.deletedAt) &&
|
|
Objects.equals(this.enableServers, game.enableServers) &&
|
|
Objects.equals(this.gamePort, game.gamePort) &&
|
|
Objects.equals(this.queryPort, game.queryPort) &&
|
|
Objects.equals(this.rconPort, game.rconPort) &&
|
|
Objects.equals(this.gamedigId, game.gamedigId) &&
|
|
Objects.equals(this.steamAppId, game.steamAppId) &&
|
|
Objects.equals(this.steamServerAppId, game.steamServerAppId);
|
|
}
|
|
|
|
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, type, organizationId, iconUrl, bannerUrl, capsuleImageUrl, libraryImageUrl, slug, createdAt, updatedAt, deletedAt, enableServers, gamePort, queryPort, rconPort, gamedigId, steamAppId, steamServerAppId);
|
|
}
|
|
|
|
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 Game {\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(" type: ").append(toIndentedString(type)).append("\n");
|
|
sb.append(" organizationId: ").append(toIndentedString(organizationId)).append("\n");
|
|
sb.append(" iconUrl: ").append(toIndentedString(iconUrl)).append("\n");
|
|
sb.append(" bannerUrl: ").append(toIndentedString(bannerUrl)).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(" createdAt: ").append(toIndentedString(createdAt)).append("\n");
|
|
sb.append(" updatedAt: ").append(toIndentedString(updatedAt)).append("\n");
|
|
sb.append(" deletedAt: ").append(toIndentedString(deletedAt)).append("\n");
|
|
sb.append(" enableServers: ").append(toIndentedString(enableServers)).append("\n");
|
|
sb.append(" gamePort: ").append(toIndentedString(gamePort)).append("\n");
|
|
sb.append(" queryPort: ").append(toIndentedString(queryPort)).append("\n");
|
|
sb.append(" rconPort: ").append(toIndentedString(rconPort)).append("\n");
|
|
sb.append(" gamedigId: ").append(toIndentedString(gamedigId)).append("\n");
|
|
sb.append(" steamAppId: ").append(toIndentedString(steamAppId)).append("\n");
|
|
sb.append(" steamServerAppId: ").append(toIndentedString(steamServerAppId)).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("type");
|
|
openapiFields.add("organization_id");
|
|
openapiFields.add("icon_url");
|
|
openapiFields.add("banner_url");
|
|
openapiFields.add("capsule_image_url");
|
|
openapiFields.add("library_image_url");
|
|
openapiFields.add("slug");
|
|
openapiFields.add("created_at");
|
|
openapiFields.add("updated_at");
|
|
openapiFields.add("deleted_at");
|
|
openapiFields.add("enable_servers");
|
|
openapiFields.add("game_port");
|
|
openapiFields.add("query_port");
|
|
openapiFields.add("rcon_port");
|
|
openapiFields.add("gamedig_id");
|
|
openapiFields.add("steam_app_id");
|
|
openapiFields.add("steam_server_app_id");
|
|
|
|
// a set of required properties/fields (JSON key names)
|
|
openapiRequiredFields = new HashSet<String>();
|
|
openapiRequiredFields.add("name");
|
|
}
|
|
|
|
/**
|
|
* 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 Game
|
|
*/
|
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
|
if (jsonElement == null) {
|
|
if (!Game.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
|
throw new IllegalArgumentException(String.format("The required field(s) %s in Game is not found in the empty JSON string", Game.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 (!Game.openapiFields.contains(entry.getKey())) {
|
|
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Game` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
|
}
|
|
}
|
|
|
|
// check to make sure all required properties/fields are present in the JSON string
|
|
for (String requiredField : Game.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()));
|
|
}
|
|
// validate the optional field `type`
|
|
if (jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) {
|
|
ApplicationType.validateJsonElement(jsonObj.get("type"));
|
|
}
|
|
if ((jsonObj.get("organization_id") != null && !jsonObj.get("organization_id").isJsonNull()) && !jsonObj.get("organization_id").isJsonPrimitive()) {
|
|
throw new IllegalArgumentException(String.format("Expected the field `organization_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("organization_id").toString()));
|
|
}
|
|
if ((jsonObj.get("icon_url") != null && !jsonObj.get("icon_url").isJsonNull()) && !jsonObj.get("icon_url").isJsonPrimitive()) {
|
|
throw new IllegalArgumentException(String.format("Expected the field `icon_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("icon_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("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()));
|
|
}
|
|
if ((jsonObj.get("gamedig_id") != null && !jsonObj.get("gamedig_id").isJsonNull()) && !jsonObj.get("gamedig_id").isJsonPrimitive()) {
|
|
throw new IllegalArgumentException(String.format("Expected the field `gamedig_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("gamedig_id").toString()));
|
|
}
|
|
}
|
|
|
|
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
|
|
@SuppressWarnings("unchecked")
|
|
@Override
|
|
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
|
|
if (!Game.class.isAssignableFrom(type.getRawType())) {
|
|
return null; // this class only serializes 'Game' and its subtypes
|
|
}
|
|
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
|
final TypeAdapter<Game> thisAdapter
|
|
= gson.getDelegateAdapter(this, TypeToken.get(Game.class));
|
|
|
|
return (TypeAdapter<T>) new TypeAdapter<Game>() {
|
|
@Override
|
|
public void write(JsonWriter out, Game value) throws IOException {
|
|
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
|
elementAdapter.write(out, obj);
|
|
}
|
|
|
|
@Override
|
|
public Game read(JsonReader in) throws IOException {
|
|
JsonElement jsonElement = elementAdapter.read(in);
|
|
validateJsonElement(jsonElement);
|
|
return thisAdapter.fromJsonTree(jsonElement);
|
|
}
|
|
|
|
}.nullSafe();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create an instance of Game given an JSON string
|
|
*
|
|
* @param jsonString JSON string
|
|
* @return An instance of Game
|
|
* @throws IOException if the JSON string is invalid with respect to Game
|
|
*/
|
|
public static Game fromJson(String jsonString) throws IOException {
|
|
return JSON.getGson().fromJson(jsonString, Game.class);
|
|
}
|
|
|
|
/**
|
|
* Convert an instance of Game to an JSON string
|
|
*
|
|
* @return JSON string
|
|
*/
|
|
public String toJson() {
|
|
return JSON.getGson().toJson(this);
|
|
}
|
|
}
|
|
|