/* * 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.GroupRank; import java.io.IOException; 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; /** * GroupMember */ @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 GroupMember { 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_VERIFIED = "verified"; @SerializedName(SERIALIZED_NAME_VERIFIED) @javax.annotation.Nullable private Boolean verified; 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_LAST_ONLINE = "last_online"; @SerializedName(SERIALIZED_NAME_LAST_ONLINE) @javax.annotation.Nullable private OffsetDateTime lastOnline; public static final String SERIALIZED_NAME_RANK = "rank"; @SerializedName(SERIALIZED_NAME_RANK) @javax.annotation.Nullable private GroupRank rank; public static final String SERIALIZED_NAME_SINCE = "since"; @SerializedName(SERIALIZED_NAME_SINCE) @javax.annotation.Nullable private OffsetDateTime since; public GroupMember() { } public GroupMember 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 GroupMember 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 GroupMember 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 GroupMember 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 GroupMember 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 GroupMember 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 GroupMember 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 GroupMember rank(@javax.annotation.Nullable GroupRank rank) { this.rank = rank; return this; } /** * Get rank * @return rank */ @javax.annotation.Nullable public GroupRank getRank() { return rank; } public void setRank(@javax.annotation.Nullable GroupRank rank) { this.rank = rank; } public GroupMember since(@javax.annotation.Nullable OffsetDateTime since) { this.since = since; return this; } /** * Get since * @return since */ @javax.annotation.Nullable public OffsetDateTime getSince() { return since; } public void setSince(@javax.annotation.Nullable OffsetDateTime since) { this.since = since; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } GroupMember groupMember = (GroupMember) o; return Objects.equals(this.id, groupMember.id) && Objects.equals(this.uuid, groupMember.uuid) && Objects.equals(this.name, groupMember.name) && Objects.equals(this.displayName, groupMember.displayName) && Objects.equals(this.verified, groupMember.verified) && Objects.equals(this.photoUrl, groupMember.photoUrl) && Objects.equals(this.lastOnline, groupMember.lastOnline) && Objects.equals(this.rank, groupMember.rank) && Objects.equals(this.since, groupMember.since); } 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, uuid, name, displayName, verified, photoUrl, lastOnline, rank, since); } 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 GroupMember {\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(" verified: ").append(toIndentedString(verified)).append("\n"); sb.append(" photoUrl: ").append(toIndentedString(photoUrl)).append("\n"); sb.append(" lastOnline: ").append(toIndentedString(lastOnline)).append("\n"); sb.append(" rank: ").append(toIndentedString(rank)).append("\n"); sb.append(" since: ").append(toIndentedString(since)).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("uuid"); openapiFields.add("name"); openapiFields.add("display_name"); openapiFields.add("verified"); openapiFields.add("photo_url"); openapiFields.add("last_online"); openapiFields.add("rank"); openapiFields.add("since"); // 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 GroupMember */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!GroupMember.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in GroupMember is not found in the empty JSON string", GroupMember.openapiRequiredFields.toString())); } } Set> entries = jsonElement.getAsJsonObject().entrySet(); // check to see if the JSON string contains additional fields for (Map.Entry entry : entries) { if (!GroupMember.openapiFields.contains(entry.getKey())) { throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GroupMember` 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("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())); } // validate the optional field `rank` if (jsonObj.get("rank") != null && !jsonObj.get("rank").isJsonNull()) { GroupRank.validateJsonElement(jsonObj.get("rank")); } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { if (!GroupMember.class.isAssignableFrom(type.getRawType())) { return null; // this class only serializes 'GroupMember' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, TypeToken.get(GroupMember.class)); return (TypeAdapter) new TypeAdapter() { @Override public void write(JsonWriter out, GroupMember value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override public GroupMember read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); } } /** * Create an instance of GroupMember given an JSON string * * @param jsonString JSON string * @return An instance of GroupMember * @throws IOException if the JSON string is invalid with respect to GroupMember */ public static GroupMember fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, GroupMember.class); } /** * Convert an instance of GroupMember to an JSON string * * @return JSON string */ public String toJson() { return JSON.getGson().toJson(this); } }