/* * 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.LoginProvider; 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; /** * Account */ @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 Account { 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_PROVIDER = "provider"; @SerializedName(SERIALIZED_NAME_PROVIDER) @javax.annotation.Nullable private LoginProvider provider; public static final String SERIALIZED_NAME_USER_ID = "user_id"; @SerializedName(SERIALIZED_NAME_USER_ID) @javax.annotation.Nullable private String userId; public static final String SERIALIZED_NAME_AUTHORIZED = "authorized"; @SerializedName(SERIALIZED_NAME_AUTHORIZED) @javax.annotation.Nullable private Boolean authorized; public static final String SERIALIZED_NAME_FIELDS = "fields"; @SerializedName(SERIALIZED_NAME_FIELDS) @javax.annotation.Nullable private Object fields = null; 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 Account() { } public Account 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 Account 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 Account provider(@javax.annotation.Nullable LoginProvider provider) { this.provider = provider; return this; } /** * Get provider * @return provider */ @javax.annotation.Nullable public LoginProvider getProvider() { return provider; } public void setProvider(@javax.annotation.Nullable LoginProvider provider) { this.provider = provider; } public Account userId(@javax.annotation.Nullable String userId) { this.userId = userId; return this; } /** * Get userId * @return userId */ @javax.annotation.Nullable public String getUserId() { return userId; } public void setUserId(@javax.annotation.Nullable String userId) { this.userId = userId; } public Account authorized(@javax.annotation.Nullable Boolean authorized) { this.authorized = authorized; return this; } /** * Get authorized * @return authorized */ @javax.annotation.Nullable public Boolean getAuthorized() { return authorized; } public void setAuthorized(@javax.annotation.Nullable Boolean authorized) { this.authorized = authorized; } public Account fields(@javax.annotation.Nullable Object fields) { this.fields = fields; return this; } /** * Get fields * @return fields */ @javax.annotation.Nullable public Object getFields() { return fields; } public void setFields(@javax.annotation.Nullable Object fields) { this.fields = fields; } public Account 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 Account 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; } Account account = (Account) o; return Objects.equals(this.id, account.id) && Objects.equals(this.name, account.name) && Objects.equals(this.provider, account.provider) && Objects.equals(this.userId, account.userId) && Objects.equals(this.authorized, account.authorized) && Objects.equals(this.fields, account.fields) && Objects.equals(this.created, account.created) && Objects.equals(this.updated, account.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, name, provider, userId, authorized, fields, 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 Account {\n"); sb.append(" id: ").append(toIndentedString(id)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" provider: ").append(toIndentedString(provider)).append("\n"); sb.append(" userId: ").append(toIndentedString(userId)).append("\n"); sb.append(" authorized: ").append(toIndentedString(authorized)).append("\n"); sb.append(" fields: ").append(toIndentedString(fields)).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("name"); openapiFields.add("provider"); openapiFields.add("user_id"); openapiFields.add("authorized"); openapiFields.add("fields"); 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 Account */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!Account.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in Account is not found in the empty JSON string", Account.openapiRequiredFields.toString())); } } Set> entries = jsonElement.getAsJsonObject().entrySet(); // check to see if the JSON string contains additional fields for (Map.Entry entry : entries) { if (!Account.openapiFields.contains(entry.getKey())) { throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `Account` 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("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())); } // validate the optional field `provider` if (jsonObj.get("provider") != null && !jsonObj.get("provider").isJsonNull()) { LoginProvider.validateJsonElement(jsonObj.get("provider")); } if ((jsonObj.get("user_id") != null && !jsonObj.get("user_id").isJsonNull()) && !jsonObj.get("user_id").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `user_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("user_id").toString())); } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { if (!Account.class.isAssignableFrom(type.getRawType())) { return null; // this class only serializes 'Account' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, TypeToken.get(Account.class)); return (TypeAdapter) new TypeAdapter() { @Override public void write(JsonWriter out, Account value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override public Account read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); } } /** * Create an instance of Account given an JSON string * * @param jsonString JSON string * @return An instance of Account * @throws IOException if the JSON string is invalid with respect to Account */ public static Account fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, Account.class); } /** * Convert an instance of Account to an JSON string * * @return JSON string */ public String toJson() { return JSON.getGson().toJson(this); } }