com.finbourne.workflow.model.WorkerStatusTriggers Maven / Gradle / Ivy
/*
* FINBOURNE Workflow API
*
* Contact: [email protected]
*
* 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.finbourne.workflow.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 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.lang.reflect.Type;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import com.finbourne.workflow.JSON;
/**
* Defines triggers that will be invoked per Worker outcome
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class WorkerStatusTriggers {
public static final String SERIALIZED_NAME_STARTED = "started";
@SerializedName(SERIALIZED_NAME_STARTED)
private String started;
public static final String SERIALIZED_NAME_COMPLETED_WITH_RESULTS = "completedWithResults";
@SerializedName(SERIALIZED_NAME_COMPLETED_WITH_RESULTS)
private String completedWithResults;
public static final String SERIALIZED_NAME_COMPLETED_NO_RESULTS = "completedNoResults";
@SerializedName(SERIALIZED_NAME_COMPLETED_NO_RESULTS)
private String completedNoResults;
public static final String SERIALIZED_NAME_FAILED_TO_START = "failedToStart";
@SerializedName(SERIALIZED_NAME_FAILED_TO_START)
private String failedToStart;
public static final String SERIALIZED_NAME_FAILED_TO_COMPLETE = "failedToComplete";
@SerializedName(SERIALIZED_NAME_FAILED_TO_COMPLETE)
private String failedToComplete;
public WorkerStatusTriggers() {
}
public WorkerStatusTriggers started(String started) {
this.started = started;
return this;
}
/**
* Trigger to invoke when the Worker has Started
* @return started
**/
@jakarta.annotation.Nullable
public String getStarted() {
return started;
}
public void setStarted(String started) {
this.started = started;
}
public WorkerStatusTriggers completedWithResults(String completedWithResults) {
this.completedWithResults = completedWithResults;
return this;
}
/**
* Trigger to invoke when the Worker has Completed (with results)
* @return completedWithResults
**/
@jakarta.annotation.Nullable
public String getCompletedWithResults() {
return completedWithResults;
}
public void setCompletedWithResults(String completedWithResults) {
this.completedWithResults = completedWithResults;
}
public WorkerStatusTriggers completedNoResults(String completedNoResults) {
this.completedNoResults = completedNoResults;
return this;
}
/**
* Trigger to invoke when the Worker has Completed (no results)
* @return completedNoResults
**/
@jakarta.annotation.Nullable
public String getCompletedNoResults() {
return completedNoResults;
}
public void setCompletedNoResults(String completedNoResults) {
this.completedNoResults = completedNoResults;
}
public WorkerStatusTriggers failedToStart(String failedToStart) {
this.failedToStart = failedToStart;
return this;
}
/**
* Trigger to invoke when the Worker has Failed to Start
* @return failedToStart
**/
@jakarta.annotation.Nullable
public String getFailedToStart() {
return failedToStart;
}
public void setFailedToStart(String failedToStart) {
this.failedToStart = failedToStart;
}
public WorkerStatusTriggers failedToComplete(String failedToComplete) {
this.failedToComplete = failedToComplete;
return this;
}
/**
* Trigger to invoke when the Worker has Failed to Complete
* @return failedToComplete
**/
@jakarta.annotation.Nullable
public String getFailedToComplete() {
return failedToComplete;
}
public void setFailedToComplete(String failedToComplete) {
this.failedToComplete = failedToComplete;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
WorkerStatusTriggers workerStatusTriggers = (WorkerStatusTriggers) o;
return Objects.equals(this.started, workerStatusTriggers.started) &&
Objects.equals(this.completedWithResults, workerStatusTriggers.completedWithResults) &&
Objects.equals(this.completedNoResults, workerStatusTriggers.completedNoResults) &&
Objects.equals(this.failedToStart, workerStatusTriggers.failedToStart) &&
Objects.equals(this.failedToComplete, workerStatusTriggers.failedToComplete);
}
private static boolean equalsNullable(JsonNullable a, JsonNullable 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(started, completedWithResults, completedNoResults, failedToStart, failedToComplete);
}
private static int hashCodeNullable(JsonNullable 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 WorkerStatusTriggers {\n");
sb.append(" started: ").append(toIndentedString(started)).append("\n");
sb.append(" completedWithResults: ").append(toIndentedString(completedWithResults)).append("\n");
sb.append(" completedNoResults: ").append(toIndentedString(completedNoResults)).append("\n");
sb.append(" failedToStart: ").append(toIndentedString(failedToStart)).append("\n");
sb.append(" failedToComplete: ").append(toIndentedString(failedToComplete)).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("started");
openapiFields.add("completedWithResults");
openapiFields.add("completedNoResults");
openapiFields.add("failedToStart");
openapiFields.add("failedToComplete");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
}
/**
* 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 WorkerStatusTriggers
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!WorkerStatusTriggers.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in WorkerStatusTriggers is not found in the empty JSON string", WorkerStatusTriggers.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("started") != null && !jsonObj.get("started").isJsonNull()) && !jsonObj.get("started").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `started` to be a primitive type in the JSON string but got `%s`", jsonObj.get("started").toString()));
}
if ((jsonObj.get("completedWithResults") != null && !jsonObj.get("completedWithResults").isJsonNull()) && !jsonObj.get("completedWithResults").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `completedWithResults` to be a primitive type in the JSON string but got `%s`", jsonObj.get("completedWithResults").toString()));
}
if ((jsonObj.get("completedNoResults") != null && !jsonObj.get("completedNoResults").isJsonNull()) && !jsonObj.get("completedNoResults").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `completedNoResults` to be a primitive type in the JSON string but got `%s`", jsonObj.get("completedNoResults").toString()));
}
if ((jsonObj.get("failedToStart") != null && !jsonObj.get("failedToStart").isJsonNull()) && !jsonObj.get("failedToStart").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `failedToStart` to be a primitive type in the JSON string but got `%s`", jsonObj.get("failedToStart").toString()));
}
if ((jsonObj.get("failedToComplete") != null && !jsonObj.get("failedToComplete").isJsonNull()) && !jsonObj.get("failedToComplete").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `failedToComplete` to be a primitive type in the JSON string but got `%s`", jsonObj.get("failedToComplete").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!WorkerStatusTriggers.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'WorkerStatusTriggers' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(WorkerStatusTriggers.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, WorkerStatusTriggers value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public WorkerStatusTriggers read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of WorkerStatusTriggers given an JSON string
*
* @param jsonString JSON string
* @return An instance of WorkerStatusTriggers
* @throws IOException if the JSON string is invalid with respect to WorkerStatusTriggers
*/
public static WorkerStatusTriggers fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, WorkerStatusTriggers.class);
}
/**
* Convert an instance of WorkerStatusTriggers to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}