TribufuJava/src/main/java/com/tribufu/generated/models/ModelPackage.java

595 lines
20 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.PackageRelease;
import java.io.IOException;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
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;
/**
* ModelPackage
*/
@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 ModelPackage {
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_AUTHOR_ID = "author_id";
@SerializedName(SERIALIZED_NAME_AUTHOR_ID)
@javax.annotation.Nullable
private String authorId;
public static final String SERIALIZED_NAME_IMAGE_URL = "image_url";
@SerializedName(SERIALIZED_NAME_IMAGE_URL)
@javax.annotation.Nullable
private String imageUrl;
public static final String SERIALIZED_NAME_APPLICATION_ID = "application_id";
@SerializedName(SERIALIZED_NAME_APPLICATION_ID)
@javax.annotation.Nullable
private String applicationId;
public static final String SERIALIZED_NAME_CATEGORY_ID = "category_id";
@SerializedName(SERIALIZED_NAME_CATEGORY_ID)
@javax.annotation.Nullable
private String categoryId;
public static final String SERIALIZED_NAME_DOWNLOAD_COUNT = "download_count";
@SerializedName(SERIALIZED_NAME_DOWNLOAD_COUNT)
@javax.annotation.Nullable
private Integer downloadCount;
public static final String SERIALIZED_NAME_LAST_DOWNLOAD = "last_download";
@SerializedName(SERIALIZED_NAME_LAST_DOWNLOAD)
@javax.annotation.Nullable
private OffsetDateTime lastDownload;
public static final String SERIALIZED_NAME_RELEASES = "releases";
@SerializedName(SERIALIZED_NAME_RELEASES)
@javax.annotation.Nullable
private List<PackageRelease> releases;
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 ModelPackage() {
}
public ModelPackage 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 ModelPackage 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 ModelPackage 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 ModelPackage authorId(@javax.annotation.Nullable String authorId) {
this.authorId = authorId;
return this;
}
/**
* Get authorId
* @return authorId
*/
@javax.annotation.Nullable
public String getAuthorId() {
return authorId;
}
public void setAuthorId(@javax.annotation.Nullable String authorId) {
this.authorId = authorId;
}
public ModelPackage imageUrl(@javax.annotation.Nullable String imageUrl) {
this.imageUrl = imageUrl;
return this;
}
/**
* Get imageUrl
* @return imageUrl
*/
@javax.annotation.Nullable
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(@javax.annotation.Nullable String imageUrl) {
this.imageUrl = imageUrl;
}
public ModelPackage applicationId(@javax.annotation.Nullable String applicationId) {
this.applicationId = applicationId;
return this;
}
/**
* Get applicationId
* @return applicationId
*/
@javax.annotation.Nullable
public String getApplicationId() {
return applicationId;
}
public void setApplicationId(@javax.annotation.Nullable String applicationId) {
this.applicationId = applicationId;
}
public ModelPackage categoryId(@javax.annotation.Nullable String categoryId) {
this.categoryId = categoryId;
return this;
}
/**
* Get categoryId
* @return categoryId
*/
@javax.annotation.Nullable
public String getCategoryId() {
return categoryId;
}
public void setCategoryId(@javax.annotation.Nullable String categoryId) {
this.categoryId = categoryId;
}
public ModelPackage downloadCount(@javax.annotation.Nullable Integer downloadCount) {
this.downloadCount = downloadCount;
return this;
}
/**
* Get downloadCount
* @return downloadCount
*/
@javax.annotation.Nullable
public Integer getDownloadCount() {
return downloadCount;
}
public void setDownloadCount(@javax.annotation.Nullable Integer downloadCount) {
this.downloadCount = downloadCount;
}
public ModelPackage lastDownload(@javax.annotation.Nullable OffsetDateTime lastDownload) {
this.lastDownload = lastDownload;
return this;
}
/**
* Get lastDownload
* @return lastDownload
*/
@javax.annotation.Nullable
public OffsetDateTime getLastDownload() {
return lastDownload;
}
public void setLastDownload(@javax.annotation.Nullable OffsetDateTime lastDownload) {
this.lastDownload = lastDownload;
}
public ModelPackage releases(@javax.annotation.Nullable List<PackageRelease> releases) {
this.releases = releases;
return this;
}
public ModelPackage addReleasesItem(PackageRelease releasesItem) {
if (this.releases == null) {
this.releases = new ArrayList<>();
}
this.releases.add(releasesItem);
return this;
}
/**
* Get releases
* @return releases
*/
@javax.annotation.Nullable
public List<PackageRelease> getReleases() {
return releases;
}
public void setReleases(@javax.annotation.Nullable List<PackageRelease> releases) {
this.releases = releases;
}
public ModelPackage 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 ModelPackage 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 ModelPackage 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;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ModelPackage _package = (ModelPackage) o;
return Objects.equals(this.id, _package.id) &&
Objects.equals(this.name, _package.name) &&
Objects.equals(this.description, _package.description) &&
Objects.equals(this.authorId, _package.authorId) &&
Objects.equals(this.imageUrl, _package.imageUrl) &&
Objects.equals(this.applicationId, _package.applicationId) &&
Objects.equals(this.categoryId, _package.categoryId) &&
Objects.equals(this.downloadCount, _package.downloadCount) &&
Objects.equals(this.lastDownload, _package.lastDownload) &&
Objects.equals(this.releases, _package.releases) &&
Objects.equals(this.createdAt, _package.createdAt) &&
Objects.equals(this.updatedAt, _package.updatedAt) &&
Objects.equals(this.deletedAt, _package.deletedAt);
}
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, authorId, imageUrl, applicationId, categoryId, downloadCount, lastDownload, releases, createdAt, updatedAt, deletedAt);
}
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 ModelPackage {\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(" authorId: ").append(toIndentedString(authorId)).append("\n");
sb.append(" imageUrl: ").append(toIndentedString(imageUrl)).append("\n");
sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n");
sb.append(" categoryId: ").append(toIndentedString(categoryId)).append("\n");
sb.append(" downloadCount: ").append(toIndentedString(downloadCount)).append("\n");
sb.append(" lastDownload: ").append(toIndentedString(lastDownload)).append("\n");
sb.append(" releases: ").append(toIndentedString(releases)).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("}");
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("author_id");
openapiFields.add("image_url");
openapiFields.add("application_id");
openapiFields.add("category_id");
openapiFields.add("download_count");
openapiFields.add("last_download");
openapiFields.add("releases");
openapiFields.add("created_at");
openapiFields.add("updated_at");
openapiFields.add("deleted_at");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet<String>();
openapiRequiredFields.add("name");
openapiRequiredFields.add("image_url");
}
/**
* 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 ModelPackage
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!ModelPackage.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ModelPackage is not found in the empty JSON string", ModelPackage.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 (!ModelPackage.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ModelPackage` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : ModelPackage.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()));
}
if ((jsonObj.get("author_id") != null && !jsonObj.get("author_id").isJsonNull()) && !jsonObj.get("author_id").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `author_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("author_id").toString()));
}
if ((jsonObj.get("image_url") != null && !jsonObj.get("image_url").isJsonNull()) && !jsonObj.get("image_url").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `image_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("image_url").toString()));
}
if ((jsonObj.get("application_id") != null && !jsonObj.get("application_id").isJsonNull()) && !jsonObj.get("application_id").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `application_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("application_id").toString()));
}
if ((jsonObj.get("category_id") != null && !jsonObj.get("category_id").isJsonNull()) && !jsonObj.get("category_id").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `category_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("category_id").toString()));
}
if (jsonObj.get("releases") != null && !jsonObj.get("releases").isJsonNull()) {
JsonArray jsonArrayreleases = jsonObj.getAsJsonArray("releases");
if (jsonArrayreleases != null) {
// ensure the json data is an array
if (!jsonObj.get("releases").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `releases` to be an array in the JSON string but got `%s`", jsonObj.get("releases").toString()));
}
// validate the optional field `releases` (array)
for (int i = 0; i < jsonArrayreleases.size(); i++) {
PackageRelease.validateJsonElement(jsonArrayreleases.get(i));
};
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if (!ModelPackage.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'ModelPackage' and its subtypes
}
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter<ModelPackage> thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(ModelPackage.class));
return (TypeAdapter<T>) new TypeAdapter<ModelPackage>() {
@Override
public void write(JsonWriter out, ModelPackage value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public ModelPackage read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of ModelPackage given an JSON string
*
* @param jsonString JSON string
* @return An instance of ModelPackage
* @throws IOException if the JSON string is invalid with respect to ModelPackage
*/
public static ModelPackage fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, ModelPackage.class);
}
/**
* Convert an instance of ModelPackage to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}