Generate code with openapi-generator (#3)

* Remove examples

* Generate project with openapi-generator

* Add wrapper classes

* Update AndroidManifest.xml
This commit is contained in:
Guilherme Werner 2025-05-27 07:53:37 -03:00 committed by GitHub
parent 0db8d03dcc
commit f0bceab05b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
94 changed files with 28324 additions and 853 deletions

View file

@ -0,0 +1,394 @@
/*
* 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.Application;
import com.tribufu.generated.models.Group;
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;
/**
* GroupGame
*/
@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 GroupGame {
public static final String SERIALIZED_NAME_GROUP_ID = "group_id";
@SerializedName(SERIALIZED_NAME_GROUP_ID)
@javax.annotation.Nullable
private String groupId;
public static final String SERIALIZED_NAME_GROUP = "group";
@SerializedName(SERIALIZED_NAME_GROUP)
@javax.annotation.Nullable
private Group group;
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_APPLICATION = "application";
@SerializedName(SERIALIZED_NAME_APPLICATION)
@javax.annotation.Nullable
private Application application;
public static final String SERIALIZED_NAME_STATS = "stats";
@SerializedName(SERIALIZED_NAME_STATS)
@javax.annotation.Nullable
private Object stats = null;
public static final String SERIALIZED_NAME_ACQUIRED = "acquired";
@SerializedName(SERIALIZED_NAME_ACQUIRED)
@javax.annotation.Nullable
private OffsetDateTime acquired;
public static final String SERIALIZED_NAME_LAST_USED = "last_used";
@SerializedName(SERIALIZED_NAME_LAST_USED)
@javax.annotation.Nullable
private OffsetDateTime lastUsed;
public GroupGame() {
}
public GroupGame groupId(@javax.annotation.Nullable String groupId) {
this.groupId = groupId;
return this;
}
/**
* Get groupId
* @return groupId
*/
@javax.annotation.Nullable
public String getGroupId() {
return groupId;
}
public void setGroupId(@javax.annotation.Nullable String groupId) {
this.groupId = groupId;
}
public GroupGame group(@javax.annotation.Nullable Group group) {
this.group = group;
return this;
}
/**
* Get group
* @return group
*/
@javax.annotation.Nullable
public Group getGroup() {
return group;
}
public void setGroup(@javax.annotation.Nullable Group group) {
this.group = group;
}
public GroupGame 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 GroupGame application(@javax.annotation.Nullable Application application) {
this.application = application;
return this;
}
/**
* Get application
* @return application
*/
@javax.annotation.Nullable
public Application getApplication() {
return application;
}
public void setApplication(@javax.annotation.Nullable Application application) {
this.application = application;
}
public GroupGame stats(@javax.annotation.Nullable Object stats) {
this.stats = stats;
return this;
}
/**
* Get stats
* @return stats
*/
@javax.annotation.Nullable
public Object getStats() {
return stats;
}
public void setStats(@javax.annotation.Nullable Object stats) {
this.stats = stats;
}
public GroupGame acquired(@javax.annotation.Nullable OffsetDateTime acquired) {
this.acquired = acquired;
return this;
}
/**
* Get acquired
* @return acquired
*/
@javax.annotation.Nullable
public OffsetDateTime getAcquired() {
return acquired;
}
public void setAcquired(@javax.annotation.Nullable OffsetDateTime acquired) {
this.acquired = acquired;
}
public GroupGame lastUsed(@javax.annotation.Nullable OffsetDateTime lastUsed) {
this.lastUsed = lastUsed;
return this;
}
/**
* Get lastUsed
* @return lastUsed
*/
@javax.annotation.Nullable
public OffsetDateTime getLastUsed() {
return lastUsed;
}
public void setLastUsed(@javax.annotation.Nullable OffsetDateTime lastUsed) {
this.lastUsed = lastUsed;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
GroupGame groupGame = (GroupGame) o;
return Objects.equals(this.groupId, groupGame.groupId) &&
Objects.equals(this.group, groupGame.group) &&
Objects.equals(this.applicationId, groupGame.applicationId) &&
Objects.equals(this.application, groupGame.application) &&
Objects.equals(this.stats, groupGame.stats) &&
Objects.equals(this.acquired, groupGame.acquired) &&
Objects.equals(this.lastUsed, groupGame.lastUsed);
}
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(groupId, group, applicationId, application, stats, acquired, lastUsed);
}
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 GroupGame {\n");
sb.append(" groupId: ").append(toIndentedString(groupId)).append("\n");
sb.append(" group: ").append(toIndentedString(group)).append("\n");
sb.append(" applicationId: ").append(toIndentedString(applicationId)).append("\n");
sb.append(" application: ").append(toIndentedString(application)).append("\n");
sb.append(" stats: ").append(toIndentedString(stats)).append("\n");
sb.append(" acquired: ").append(toIndentedString(acquired)).append("\n");
sb.append(" lastUsed: ").append(toIndentedString(lastUsed)).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("group_id");
openapiFields.add("group");
openapiFields.add("application_id");
openapiFields.add("application");
openapiFields.add("stats");
openapiFields.add("acquired");
openapiFields.add("last_used");
// 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 GroupGame
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!GroupGame.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in GroupGame is not found in the empty JSON string", GroupGame.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 (!GroupGame.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GroupGame` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("group_id") != null && !jsonObj.get("group_id").isJsonNull()) && !jsonObj.get("group_id").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `group_id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("group_id").toString()));
}
// validate the optional field `group`
if (jsonObj.get("group") != null && !jsonObj.get("group").isJsonNull()) {
Group.validateJsonElement(jsonObj.get("group"));
}
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()));
}
// validate the optional field `application`
if (jsonObj.get("application") != null && !jsonObj.get("application").isJsonNull()) {
Application.validateJsonElement(jsonObj.get("application"));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if (!GroupGame.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'GroupGame' and its subtypes
}
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter<GroupGame> thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(GroupGame.class));
return (TypeAdapter<T>) new TypeAdapter<GroupGame>() {
@Override
public void write(JsonWriter out, GroupGame value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public GroupGame read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of GroupGame given an JSON string
*
* @param jsonString JSON string
* @return An instance of GroupGame
* @throws IOException if the JSON string is invalid with respect to GroupGame
*/
public static GroupGame fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, GroupGame.class);
}
/**
* Convert an instance of GroupGame to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}