mirror of
https://github.com/Tribufu/TribufuJava
synced 2026-08-08 20:31:07 +00:00
* Remove examples * Generate project with openapi-generator * Add wrapper classes * Update AndroidManifest.xml
534 lines
17 KiB
Java
534 lines
17 KiB
Java
/*
|
|
* 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.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;
|
|
|
|
/**
|
|
* ModelPackage
|
|
*/
|
|
@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 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_IMAGE_URL = "image_url";
|
|
@SerializedName(SERIALIZED_NAME_IMAGE_URL)
|
|
@javax.annotation.Nullable
|
|
private String imageUrl;
|
|
|
|
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_VERSION = "version";
|
|
@SerializedName(SERIALIZED_NAME_VERSION)
|
|
@javax.annotation.Nullable
|
|
private String version;
|
|
|
|
public static final String SERIALIZED_NAME_FILE_URL = "file_url";
|
|
@SerializedName(SERIALIZED_NAME_FILE_URL)
|
|
@javax.annotation.Nullable
|
|
private String fileUrl;
|
|
|
|
public static final String SERIALIZED_NAME_RAW_SIZE = "raw_size";
|
|
@SerializedName(SERIALIZED_NAME_RAW_SIZE)
|
|
@javax.annotation.Nullable
|
|
private Double rawSize;
|
|
|
|
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_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 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 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 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 version(@javax.annotation.Nullable String version) {
|
|
this.version = version;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get version
|
|
* @return version
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public String getVersion() {
|
|
return version;
|
|
}
|
|
|
|
public void setVersion(@javax.annotation.Nullable String version) {
|
|
this.version = version;
|
|
}
|
|
|
|
|
|
public ModelPackage fileUrl(@javax.annotation.Nullable String fileUrl) {
|
|
this.fileUrl = fileUrl;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get fileUrl
|
|
* @return fileUrl
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public String getFileUrl() {
|
|
return fileUrl;
|
|
}
|
|
|
|
public void setFileUrl(@javax.annotation.Nullable String fileUrl) {
|
|
this.fileUrl = fileUrl;
|
|
}
|
|
|
|
|
|
public ModelPackage rawSize(@javax.annotation.Nullable Double rawSize) {
|
|
this.rawSize = rawSize;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get rawSize
|
|
* @return rawSize
|
|
*/
|
|
@javax.annotation.Nullable
|
|
public Double getRawSize() {
|
|
return rawSize;
|
|
}
|
|
|
|
public void setRawSize(@javax.annotation.Nullable Double rawSize) {
|
|
this.rawSize = rawSize;
|
|
}
|
|
|
|
|
|
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 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 ModelPackage 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;
|
|
}
|
|
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.imageUrl, _package.imageUrl) &&
|
|
Objects.equals(this.authorId, _package.authorId) &&
|
|
Objects.equals(this.version, _package.version) &&
|
|
Objects.equals(this.fileUrl, _package.fileUrl) &&
|
|
Objects.equals(this.rawSize, _package.rawSize) &&
|
|
Objects.equals(this.downloadCount, _package.downloadCount) &&
|
|
Objects.equals(this.lastDownload, _package.lastDownload) &&
|
|
Objects.equals(this.created, _package.created) &&
|
|
Objects.equals(this.updated, _package.updated);
|
|
}
|
|
|
|
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, imageUrl, authorId, version, fileUrl, rawSize, downloadCount, lastDownload, created, updated);
|
|
}
|
|
|
|
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(" imageUrl: ").append(toIndentedString(imageUrl)).append("\n");
|
|
sb.append(" authorId: ").append(toIndentedString(authorId)).append("\n");
|
|
sb.append(" version: ").append(toIndentedString(version)).append("\n");
|
|
sb.append(" fileUrl: ").append(toIndentedString(fileUrl)).append("\n");
|
|
sb.append(" rawSize: ").append(toIndentedString(rawSize)).append("\n");
|
|
sb.append(" downloadCount: ").append(toIndentedString(downloadCount)).append("\n");
|
|
sb.append(" lastDownload: ").append(toIndentedString(lastDownload)).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<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("image_url");
|
|
openapiFields.add("author_id");
|
|
openapiFields.add("version");
|
|
openapiFields.add("file_url");
|
|
openapiFields.add("raw_size");
|
|
openapiFields.add("download_count");
|
|
openapiFields.add("last_download");
|
|
openapiFields.add("created");
|
|
openapiFields.add("updated");
|
|
|
|
// a set of required properties/fields (JSON key names)
|
|
openapiRequiredFields = new HashSet<String>();
|
|
}
|
|
|
|
/**
|
|
* 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()));
|
|
}
|
|
}
|
|
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("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("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("version") != null && !jsonObj.get("version").isJsonNull()) && !jsonObj.get("version").isJsonPrimitive()) {
|
|
throw new IllegalArgumentException(String.format("Expected the field `version` to be a primitive type in the JSON string but got `%s`", jsonObj.get("version").toString()));
|
|
}
|
|
if ((jsonObj.get("file_url") != null && !jsonObj.get("file_url").isJsonNull()) && !jsonObj.get("file_url").isJsonPrimitive()) {
|
|
throw new IllegalArgumentException(String.format("Expected the field `file_url` to be a primitive type in the JSON string but got `%s`", jsonObj.get("file_url").toString()));
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
}
|
|
|