io.dataspray.stream.control.client.model.TaskStatus Maven / Gradle / Ivy
/*
* DataSpray API
* DataSpray API documentation for controlling and development.
*
* The version of the OpenAPI document: 1.0.0
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
package io.dataspray.stream.control.client.model;
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 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.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import io.dataspray.stream.control.client.JSON;
/**
* TaskStatus
*/
public class TaskStatus {
public static final String SERIALIZED_NAME_TASK_ID = "taskId";
@SerializedName(SERIALIZED_NAME_TASK_ID)
private String taskId;
public static final String SERIALIZED_NAME_VERSION = "version";
@SerializedName(SERIALIZED_NAME_VERSION)
private String version;
/**
* Gets or Sets status
*/
@JsonAdapter(StatusEnum.Adapter.class)
public enum StatusEnum {
CREATING("CREATING"),
STARTING("STARTING"),
UPDATING("UPDATING"),
RUNNING("RUNNING"),
PAUSING("PAUSING"),
PAUSED("PAUSED"),
NOTFOUND("NOTFOUND");
private String value;
StatusEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static StatusEnum fromValue(String value) {
for (StatusEnum b : StatusEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final StatusEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public StatusEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return StatusEnum.fromValue(value);
}
}
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
String value = jsonElement.getAsString();
StatusEnum.fromValue(value);
}
}
public static final String SERIALIZED_NAME_STATUS = "status";
@SerializedName(SERIALIZED_NAME_STATUS)
private StatusEnum status;
/**
* Gets or Sets lastUpdateStatus
*/
@JsonAdapter(LastUpdateStatusEnum.Adapter.class)
public enum LastUpdateStatusEnum {
SUCCESSFUL("SUCCESSFUL"),
FAILED("FAILED"),
IN_PROGRESS("IN_PROGRESS");
private String value;
LastUpdateStatusEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static LastUpdateStatusEnum fromValue(String value) {
for (LastUpdateStatusEnum b : LastUpdateStatusEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final LastUpdateStatusEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public LastUpdateStatusEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return LastUpdateStatusEnum.fromValue(value);
}
}
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
String value = jsonElement.getAsString();
LastUpdateStatusEnum.fromValue(value);
}
}
public static final String SERIALIZED_NAME_LAST_UPDATE_STATUS = "lastUpdateStatus";
@SerializedName(SERIALIZED_NAME_LAST_UPDATE_STATUS)
private LastUpdateStatusEnum lastUpdateStatus;
public static final String SERIALIZED_NAME_LAST_UPDATE_STATUS_REASON = "lastUpdateStatusReason";
@SerializedName(SERIALIZED_NAME_LAST_UPDATE_STATUS_REASON)
private String lastUpdateStatusReason;
public static final String SERIALIZED_NAME_ENDPOINT_URL = "endpointUrl";
@SerializedName(SERIALIZED_NAME_ENDPOINT_URL)
private String endpointUrl;
public TaskStatus() {
}
public TaskStatus taskId(String taskId) {
this.taskId = taskId;
return this;
}
/**
* Get taskId
* @return taskId
**/
@jakarta.annotation.Nonnull
public String getTaskId() {
return taskId;
}
public void setTaskId(String taskId) {
this.taskId = taskId;
}
public TaskStatus version(String version) {
this.version = version;
return this;
}
/**
* Get version
* @return version
**/
@jakarta.annotation.Nullable
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public TaskStatus status(StatusEnum status) {
this.status = status;
return this;
}
/**
* Get status
* @return status
**/
@jakarta.annotation.Nonnull
public StatusEnum getStatus() {
return status;
}
public void setStatus(StatusEnum status) {
this.status = status;
}
public TaskStatus lastUpdateStatus(LastUpdateStatusEnum lastUpdateStatus) {
this.lastUpdateStatus = lastUpdateStatus;
return this;
}
/**
* Get lastUpdateStatus
* @return lastUpdateStatus
**/
@jakarta.annotation.Nullable
public LastUpdateStatusEnum getLastUpdateStatus() {
return lastUpdateStatus;
}
public void setLastUpdateStatus(LastUpdateStatusEnum lastUpdateStatus) {
this.lastUpdateStatus = lastUpdateStatus;
}
public TaskStatus lastUpdateStatusReason(String lastUpdateStatusReason) {
this.lastUpdateStatusReason = lastUpdateStatusReason;
return this;
}
/**
* Get lastUpdateStatusReason
* @return lastUpdateStatusReason
**/
@jakarta.annotation.Nullable
public String getLastUpdateStatusReason() {
return lastUpdateStatusReason;
}
public void setLastUpdateStatusReason(String lastUpdateStatusReason) {
this.lastUpdateStatusReason = lastUpdateStatusReason;
}
public TaskStatus endpointUrl(String endpointUrl) {
this.endpointUrl = endpointUrl;
return this;
}
/**
* Get endpointUrl
* @return endpointUrl
**/
@jakarta.annotation.Nullable
public String getEndpointUrl() {
return endpointUrl;
}
public void setEndpointUrl(String endpointUrl) {
this.endpointUrl = endpointUrl;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
TaskStatus taskStatus = (TaskStatus) o;
return Objects.equals(this.taskId, taskStatus.taskId) &&
Objects.equals(this.version, taskStatus.version) &&
Objects.equals(this.status, taskStatus.status) &&
Objects.equals(this.lastUpdateStatus, taskStatus.lastUpdateStatus) &&
Objects.equals(this.lastUpdateStatusReason, taskStatus.lastUpdateStatusReason) &&
Objects.equals(this.endpointUrl, taskStatus.endpointUrl);
}
@Override
public int hashCode() {
return Objects.hash(taskId, version, status, lastUpdateStatus, lastUpdateStatusReason, endpointUrl);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class TaskStatus {\n");
sb.append(" taskId: ").append(toIndentedString(taskId)).append("\n");
sb.append(" version: ").append(toIndentedString(version)).append("\n");
sb.append(" status: ").append(toIndentedString(status)).append("\n");
sb.append(" lastUpdateStatus: ").append(toIndentedString(lastUpdateStatus)).append("\n");
sb.append(" lastUpdateStatusReason: ").append(toIndentedString(lastUpdateStatusReason)).append("\n");
sb.append(" endpointUrl: ").append(toIndentedString(endpointUrl)).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("taskId");
openapiFields.add("version");
openapiFields.add("status");
openapiFields.add("lastUpdateStatus");
openapiFields.add("lastUpdateStatusReason");
openapiFields.add("endpointUrl");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("taskId");
openapiRequiredFields.add("status");
}
/**
* 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 TaskStatus
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!TaskStatus.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in TaskStatus is not found in the empty JSON string", TaskStatus.openapiRequiredFields.toString()));
}
}
Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Map.Entry entry : entries) {
if (!TaskStatus.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `TaskStatus` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : TaskStatus.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("taskId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `taskId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("taskId").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("status").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `status` to be a primitive type in the JSON string but got `%s`", jsonObj.get("status").toString()));
}
// validate the required field `status`
StatusEnum.validateJsonElement(jsonObj.get("status"));
if ((jsonObj.get("lastUpdateStatus") != null && !jsonObj.get("lastUpdateStatus").isJsonNull()) && !jsonObj.get("lastUpdateStatus").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `lastUpdateStatus` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastUpdateStatus").toString()));
}
// validate the optional field `lastUpdateStatus`
if (jsonObj.get("lastUpdateStatus") != null && !jsonObj.get("lastUpdateStatus").isJsonNull()) {
LastUpdateStatusEnum.validateJsonElement(jsonObj.get("lastUpdateStatus"));
}
if ((jsonObj.get("lastUpdateStatusReason") != null && !jsonObj.get("lastUpdateStatusReason").isJsonNull()) && !jsonObj.get("lastUpdateStatusReason").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `lastUpdateStatusReason` to be a primitive type in the JSON string but got `%s`", jsonObj.get("lastUpdateStatusReason").toString()));
}
if ((jsonObj.get("endpointUrl") != null && !jsonObj.get("endpointUrl").isJsonNull()) && !jsonObj.get("endpointUrl").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `endpointUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("endpointUrl").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!TaskStatus.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'TaskStatus' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(TaskStatus.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, TaskStatus value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public TaskStatus read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of TaskStatus given an JSON string
*
* @param jsonString JSON string
* @return An instance of TaskStatus
* @throws IOException if the JSON string is invalid with respect to TaskStatus
*/
public static TaskStatus fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, TaskStatus.class);
}
/**
* Convert an instance of TaskStatus to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy