mirror of
https://github.com/Tribufu/TribufuJava
synced 2026-08-16 08:01:09 +00:00
402 lines
13 KiB
Java
402 lines
13 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.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;
|
|
|
|
/**
|
|
* GroupApplication
|
|
*/
|
|
@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 GroupApplication {
|
|
public static final String SERIALIZED_NAME_GROUP_ID = "group_id";
|
|
@SerializedName(SERIALIZED_NAME_GROUP_ID)
|
|
@javax.annotation.Nonnull
|
|
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 GroupApplication() {
|
|
}
|
|
|
|
public GroupApplication groupId(@javax.annotation.Nonnull String groupId) {
|
|
this.groupId = groupId;
|
|
return this;
|
|
}
|
|
|
|
/**
|
|
* Get groupId
|
|
* @return groupId
|
|
*/
|
|
@javax.annotation.Nonnull
|
|
public String getGroupId() {
|
|
return groupId;
|
|
}
|
|
|
|
public void setGroupId(@javax.annotation.Nonnull String groupId) {
|
|
this.groupId = groupId;
|
|
}
|
|
|
|
|
|
public GroupApplication 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 GroupApplication 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 GroupApplication 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 GroupApplication 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 GroupApplication 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 GroupApplication 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;
|
|
}
|
|
GroupApplication groupApplication = (GroupApplication) o;
|
|
return Objects.equals(this.groupId, groupApplication.groupId) &&
|
|
Objects.equals(this.group, groupApplication.group) &&
|
|
Objects.equals(this.applicationId, groupApplication.applicationId) &&
|
|
Objects.equals(this.application, groupApplication.application) &&
|
|
Objects.equals(this.stats, groupApplication.stats) &&
|
|
Objects.equals(this.acquired, groupApplication.acquired) &&
|
|
Objects.equals(this.lastUsed, groupApplication.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 GroupApplication {\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>();
|
|
openapiRequiredFields.add("group_id");
|
|
}
|
|
|
|
/**
|
|
* 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 GroupApplication
|
|
*/
|
|
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
|
|
if (jsonElement == null) {
|
|
if (!GroupApplication.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
|
|
throw new IllegalArgumentException(String.format("The required field(s) %s in GroupApplication is not found in the empty JSON string", GroupApplication.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 (!GroupApplication.openapiFields.contains(entry.getKey())) {
|
|
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `GroupApplication` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
|
|
}
|
|
}
|
|
|
|
// check to make sure all required properties/fields are present in the JSON string
|
|
for (String requiredField : GroupApplication.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("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 (!GroupApplication.class.isAssignableFrom(type.getRawType())) {
|
|
return null; // this class only serializes 'GroupApplication' and its subtypes
|
|
}
|
|
final TypeAdapter<JsonElement> elementAdapter = gson.getAdapter(JsonElement.class);
|
|
final TypeAdapter<GroupApplication> thisAdapter
|
|
= gson.getDelegateAdapter(this, TypeToken.get(GroupApplication.class));
|
|
|
|
return (TypeAdapter<T>) new TypeAdapter<GroupApplication>() {
|
|
@Override
|
|
public void write(JsonWriter out, GroupApplication value) throws IOException {
|
|
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
|
|
elementAdapter.write(out, obj);
|
|
}
|
|
|
|
@Override
|
|
public GroupApplication read(JsonReader in) throws IOException {
|
|
JsonElement jsonElement = elementAdapter.read(in);
|
|
validateJsonElement(jsonElement);
|
|
return thisAdapter.fromJsonTree(jsonElement);
|
|
}
|
|
|
|
}.nullSafe();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Create an instance of GroupApplication given an JSON string
|
|
*
|
|
* @param jsonString JSON string
|
|
* @return An instance of GroupApplication
|
|
* @throws IOException if the JSON string is invalid with respect to GroupApplication
|
|
*/
|
|
public static GroupApplication fromJson(String jsonString) throws IOException {
|
|
return JSON.getGson().fromJson(jsonString, GroupApplication.class);
|
|
}
|
|
|
|
/**
|
|
* Convert an instance of GroupApplication to an JSON string
|
|
*
|
|
* @return JSON string
|
|
*/
|
|
public String toJson() {
|
|
return JSON.getGson().toJson(this);
|
|
}
|
|
}
|
|
|