/* * 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.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; /** * RegisterRequest */ @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 RegisterRequest { 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.Nonnull private String name; public static final String SERIALIZED_NAME_EMAIL = "email"; @SerializedName(SERIALIZED_NAME_EMAIL) @javax.annotation.Nullable private String email; public static final String SERIALIZED_NAME_PASSWORD = "password"; @SerializedName(SERIALIZED_NAME_PASSWORD) @javax.annotation.Nonnull private String password; public RegisterRequest() { } public RegisterRequest 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 RegisterRequest name(@javax.annotation.Nonnull String name) { this.name = name; return this; } /** * Get name * @return name */ @javax.annotation.Nonnull public String getName() { return name; } public void setName(@javax.annotation.Nonnull String name) { this.name = name; } public RegisterRequest email(@javax.annotation.Nullable String email) { this.email = email; return this; } /** * Get email * @return email */ @javax.annotation.Nullable public String getEmail() { return email; } public void setEmail(@javax.annotation.Nullable String email) { this.email = email; } public RegisterRequest password(@javax.annotation.Nonnull String password) { this.password = password; return this; } /** * Get password * @return password */ @javax.annotation.Nonnull public String getPassword() { return password; } public void setPassword(@javax.annotation.Nonnull String password) { this.password = password; } @Override public boolean equals(Object o) { if (this == o) { return true; } if (o == null || getClass() != o.getClass()) { return false; } RegisterRequest registerRequest = (RegisterRequest) o; return Objects.equals(this.uuid, registerRequest.uuid) && Objects.equals(this.name, registerRequest.name) && Objects.equals(this.email, registerRequest.email) && Objects.equals(this.password, registerRequest.password); } 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(uuid, name, email, password); } 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 RegisterRequest {\n"); sb.append(" uuid: ").append(toIndentedString(uuid)).append("\n"); sb.append(" name: ").append(toIndentedString(name)).append("\n"); sb.append(" email: ").append(toIndentedString(email)).append("\n"); sb.append(" password: ").append("*").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("uuid"); openapiFields.add("name"); openapiFields.add("email"); openapiFields.add("password"); // a set of required properties/fields (JSON key names) openapiRequiredFields = new HashSet(); openapiRequiredFields.add("name"); openapiRequiredFields.add("password"); } /** * 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 RegisterRequest */ public static void validateJsonElement(JsonElement jsonElement) throws IOException { if (jsonElement == null) { if (!RegisterRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null throw new IllegalArgumentException(String.format("The required field(s) %s in RegisterRequest is not found in the empty JSON string", RegisterRequest.openapiRequiredFields.toString())); } } Set> entries = jsonElement.getAsJsonObject().entrySet(); // check to see if the JSON string contains additional fields for (Map.Entry entry : entries) { if (!RegisterRequest.openapiFields.contains(entry.getKey())) { throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `RegisterRequest` properties. JSON: %s", entry.getKey(), jsonElement.toString())); } } // check to make sure all required properties/fields are present in the JSON string for (String requiredField : RegisterRequest.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("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").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("email") != null && !jsonObj.get("email").isJsonNull()) && !jsonObj.get("email").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `email` to be a primitive type in the JSON string but got `%s`", jsonObj.get("email").toString())); } if (!jsonObj.get("password").isJsonPrimitive()) { throw new IllegalArgumentException(String.format("Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); } } public static class CustomTypeAdapterFactory implements TypeAdapterFactory { @SuppressWarnings("unchecked") @Override public TypeAdapter create(Gson gson, TypeToken type) { if (!RegisterRequest.class.isAssignableFrom(type.getRawType())) { return null; // this class only serializes 'RegisterRequest' and its subtypes } final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); final TypeAdapter thisAdapter = gson.getDelegateAdapter(this, TypeToken.get(RegisterRequest.class)); return (TypeAdapter) new TypeAdapter() { @Override public void write(JsonWriter out, RegisterRequest value) throws IOException { JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); elementAdapter.write(out, obj); } @Override public RegisterRequest read(JsonReader in) throws IOException { JsonElement jsonElement = elementAdapter.read(in); validateJsonElement(jsonElement); return thisAdapter.fromJsonTree(jsonElement); } }.nullSafe(); } } /** * Create an instance of RegisterRequest given an JSON string * * @param jsonString JSON string * @return An instance of RegisterRequest * @throws IOException if the JSON string is invalid with respect to RegisterRequest */ public static RegisterRequest fromJson(String jsonString) throws IOException { return JSON.getGson().fromJson(jsonString, RegisterRequest.class); } /** * Convert an instance of RegisterRequest to an JSON string * * @return JSON string */ public String toJson() { return JSON.getGson().toJson(this); } }