/* * 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.LocalDate; 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; /** * Profile */ @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 Profile { 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_LEVEL = "level"; @SerializedName(SERIALIZED_NAME_LEVEL) @javax.annotation.Nullable private Integer level; public static final String SERIALIZED_NAME_EXPERIENCE = "experience"; @SerializedName(SERIALIZED_NAME_EXPERIENCE) @javax.annotation.Nullable private Double experience; public static final String SERIALIZED_NAME_PUBLIC_BIRTHDAY = "public_birthday"; @SerializedName(SERIALIZED_NAME_PUBLIC_BIRTHDAY) @javax.annotation.Nullable private Boolean publicBirthday; public static final String SERIALIZED_NAME_BIRTHDAY = "birthday"; @SerializedName(SERIALIZED_NAME_BIRTHDAY) @javax.annotation.Nullable private LocalDate birthday; public static final String SERIALIZED_NAME_POINTS = "points"; @SerializedName(SERIALIZED_NAME_POINTS) @javax.annotation.Nullable private Double points; public static final String SERIALIZED_NAME_LOCATION = "location"; @SerializedName(SERIALIZED_NAME_LOCATION) @javax.annotation.Nullable private String location; 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_BANNER_URL = "banner_url"; @SerializedName(SERIALIZED_NAME_BANNER_URL) @javax.annotation.Nullable private String bannerUrl; 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_BIOGRAPHY = "biography"; @SerializedName(SERIALIZED_NAME_BIOGRAPHY) @javax.annotation.Nullable private String biography; public static final String SERIALIZED_NAME_VIEW_COUNT = "view_count"; @SerializedName(SERIALIZED_NAME_VIEW_COUNT) @javax.annotation.Nullable private Integer viewCount; 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 Profile() { } public Profile 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 Profile 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 Profile 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 Profile 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 Profile 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 Profile level(@javax.annotation.Nullable Integer level) { this.level = level; return this; } /** * Get level * @return level */ @javax.annotation.Nullable public Integer getLevel() { return level; } public void setLevel(@javax.annotation.Nullable Integer level) { this.level = level; } public Profile experience(@javax.annotation.Nullable Double experience) { this.experience = experience; return this; } /** * Get experience * @return experience */ @javax.annotation.Nullable public Double getExperience() { return experience; } public void setExperience(@javax.annotation.Nullable Double experience) { this.experience = experience; } public Profile publicBirthday(@javax.annotation.Nullable Boolean publicBirthday) { this.publicBirthday = publicBirthday; return this; } /** * Get publicBirthday * @return publicBirthday */ @javax.annotation.Nullable public Boolean getPublicBirthday() { return publicBirthday; } public void setPublicBirthday(@javax.annotation.Nullable Boolean publicBirthday) { this.publicBirthday = publicBirthday; } public Profile birthday(@javax.annotation.Nullable LocalDate birthday) { this.birthday = birthday; return this; } /** * Get birthday * @return birthday */ @javax.annotation.Nullable public LocalDate getBirthday() { return birthday; } public void setBirthday(@javax.annotation.Nullable LocalDate birthday) { this.birthday = birthday; } public Profile points(@javax.annotation.Nullable Double points) { this.points = points; return this; } /** * Get points * @return points */ @javax.annotation.Nullable public Double getPoints() { return points; } public void setPoints(@javax.annotation.Nullable Double points) { this.points = points; } public Profile location(@javax.annotation.Nullable String location) { this.location = location; return this; } /** * Get location * @return location */ @javax.annotation.Nullable public String getLocation() { return location; } public void setLocation(@javax.annotation.Nullable String location) { this.location = location; } public Profile 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 Profile 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 Profile 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 Profile biography(@javax.annotation.Nullable String biography) { this.biography = biography; return this; } /** * Get biography * @return biography */ @javax.annotation.Nullable public String getBiography() { return biography; } public void setBiography(@javax.annotation.Nullable String biography) { this.biography = biography; } public Profile viewCount(@javax.annotation.Nullable Integer viewCount) { this.viewCount = viewCount; return this; } /** * Get viewCount * @return viewCount */ @javax.annotation.Nullable public Integer getViewCount() { return viewCount; } public void setViewCount(@javax.annotation.Nullable Integer viewCount) { this.viewCount = viewCount; } public Profile 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 Profile 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; } Profile profile = (Profile) o; return Objects.equals(this.id, profile.id) && Objects.equals(this.uuid, profile.uuid) && Objects.equals(this.name, profile.name) && Objects.equals(this.displayName, profile.displayName) && Objects.equals(this.verified, profile.verified) && Objects.equals(this.level, profile.level) && Objects.equals(this.experience, profile.experience) && Objects.equals(this.publicBirthday, profile.publicBirthday) && Objects.equals(this.birthday, profile.birthday) && Objects.equals(this.points, profile.points) && Objects.equals(this.location, profile.location) && Objects.equals(this.photoUrl, profile.photoUrl) && Objects.equals(this.bannerUrl, profile.bannerUrl) && Objects.equals(this.lastOnline, profile.lastOnline) && Objects.equals(this.biography, profile.biography) && Objects.equals(this.viewCount, profile.viewCount) && Objects.equals(this.created, profile.created) && Objects.equals(this.updated, profile.updated); } 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, level, experience, publicBirthday, birthday, points, location, photoUrl, bannerUrl, lastOnline, biography, viewCount, created, updated); } 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 Profile {\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(" level: ").append(toIndentedString(level)).append("\n"); sb.append(" experience: ").append(toIndentedString(experience)).append("\n"); sb.append(" publicBirthday: ").append(toIndentedString(publicBirthday)).append("\n"); sb.append(" birthday: ").append(toIndentedString(birthday)).append("\n"); sb.append(" points: ").append(toIndentedString(points)).append("\n"); sb.append(" location: ").append(toIndentedString(location)).append("\n"); sb.append(" photoUrl: ").append(toIndentedString(photoUrl)).append("\n"); sb.append(" bannerUrl: ").append(toIndentedString(bannerUrl)).append("\n"); sb.append(" lastOnline: ").append(toIndentedString(lastOnline)).append("\n"); sb.append(" biography: ").append(toIndentedString(biography)).append("\n"); sb.append(" viewCount: ").append(toIndentedString(viewCount)).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 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("level"); openapiFields.add("experience"); openapiFields.add("public_birthday"); openapiFields.add("birthday"); openapiFields.add("points"); openapiFields.add("location"); openapiFields.add("photo_url"); openapiFields.add("banner_url"); openapiFields.add("last_online"); openapiFields.add("biography"); openapiFields.add("view_count"); openapiFields.add("created"); openapiFields.add("updated"); // 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 Profile */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Profile.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in Profile is not found in the empty JSON string", Profile.openapiRequiredFields.toString())); } } Set> entries = jsonElement.getAsJsonObject().entrySet(); // check to see if the JSON string contains additional fields for (Map.Entry entry : entries) { if (!Profile.openapiFields.contains(entry.getKey())) { throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Profile` 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("location") != null && !jsonObj.get("location").isJsonNull()) && !jsonObj.get("location").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `location` to be a primitive type in the JSON string but got `%s`", jsonObj.get("location").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())); } 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("biography") != null && !jsonObj.get("biography").isJsonNull()) && !jsonObj.get("biography").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `biography` to be a primitive type in the JSON string but got `%s`", jsonObj.get("biography").toString())); } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { if (!Profile.class.isAssignableFrom(type.getRawType())) { return null; // this class only serializes 'Profile' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, TypeToken.get(Profile.class)); return (TypeAdapter) new TypeAdapter() { @Override public void write(JsonWriter out, Profile value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override public Profile read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); } } /** * Create an instance of Profile given an JSON string * * @param jsonString JSON string * @return An instance of Profile * @throws IOException if the JSON string is invalid with respect to Profile */ public static Profile fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, Profile.class); } /** * Convert an instance of Profile to an JSON string * * @return JSON string */ public String toJson() { return JSON.getGson().toJson(this); } }