com.finbourne.workflow.model.UpdateTaskDefinitionRequest 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.finbourne.workflow.model.ActionDefinition;
import com.finbourne.workflow.model.InitialState;
import com.finbourne.workflow.model.TaskFieldDefinition;
import com.finbourne.workflow.model.TaskStateDefinition;
import com.finbourne.workflow.model.TaskTransitionDefinition;
import com.finbourne.workflow.model.TransitionTriggerDefinition;
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.ArrayList;
import java.util.Arrays;
import java.util.List;
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;
/**
* Contains required info to update a Task Definition
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class UpdateTaskDefinitionRequest {
public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName";
@SerializedName(SERIALIZED_NAME_DISPLAY_NAME)
private String displayName;
public static final String SERIALIZED_NAME_DESCRIPTION = "description";
@SerializedName(SERIALIZED_NAME_DESCRIPTION)
private String description;
public static final String SERIALIZED_NAME_STATES = "states";
@SerializedName(SERIALIZED_NAME_STATES)
private List states = new ArrayList<>();
public static final String SERIALIZED_NAME_FIELD_SCHEMA = "fieldSchema";
@SerializedName(SERIALIZED_NAME_FIELD_SCHEMA)
private List fieldSchema;
public static final String SERIALIZED_NAME_INITIAL_STATE = "initialState";
@SerializedName(SERIALIZED_NAME_INITIAL_STATE)
private InitialState initialState;
public static final String SERIALIZED_NAME_TRIGGERS = "triggers";
@SerializedName(SERIALIZED_NAME_TRIGGERS)
private List triggers;
public static final String SERIALIZED_NAME_TRANSITIONS = "transitions";
@SerializedName(SERIALIZED_NAME_TRANSITIONS)
private List transitions;
public static final String SERIALIZED_NAME_ACTIONS = "actions";
@SerializedName(SERIALIZED_NAME_ACTIONS)
private List actions;
public UpdateTaskDefinitionRequest() {
}
public UpdateTaskDefinitionRequest displayName(String displayName) {
this.displayName = displayName;
return this;
}
/**
* Human readable name
* @return displayName
**/
@jakarta.annotation.Nonnull
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public UpdateTaskDefinitionRequest description(String description) {
this.description = description;
return this;
}
/**
* Human readable description
* @return description
**/
@jakarta.annotation.Nullable
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public UpdateTaskDefinitionRequest states(List states) {
this.states = states;
return this;
}
public UpdateTaskDefinitionRequest addStatesItem(TaskStateDefinition statesItem) {
if (this.states == null) {
this.states = new ArrayList<>();
}
this.states.add(statesItem);
return this;
}
/**
* The states this Task Definition operates over
* @return states
**/
@jakarta.annotation.Nonnull
public List getStates() {
return states;
}
public void setStates(List states) {
this.states = states;
}
public UpdateTaskDefinitionRequest fieldSchema(List fieldSchema) {
this.fieldSchema = fieldSchema;
return this;
}
public UpdateTaskDefinitionRequest addFieldSchemaItem(TaskFieldDefinition fieldSchemaItem) {
if (this.fieldSchema == null) {
this.fieldSchema = new ArrayList<>();
}
this.fieldSchema.add(fieldSchemaItem);
return this;
}
/**
* Defines the fields associated with this Task
* @return fieldSchema
**/
@jakarta.annotation.Nullable
public List getFieldSchema() {
return fieldSchema;
}
public void setFieldSchema(List fieldSchema) {
this.fieldSchema = fieldSchema;
}
public UpdateTaskDefinitionRequest initialState(InitialState initialState) {
this.initialState = initialState;
return this;
}
/**
* Get initialState
* @return initialState
**/
@jakarta.annotation.Nonnull
public InitialState getInitialState() {
return initialState;
}
public void setInitialState(InitialState initialState) {
this.initialState = initialState;
}
public UpdateTaskDefinitionRequest triggers(List triggers) {
this.triggers = triggers;
return this;
}
public UpdateTaskDefinitionRequest addTriggersItem(TransitionTriggerDefinition triggersItem) {
if (this.triggers == null) {
this.triggers = new ArrayList<>();
}
this.triggers.add(triggersItem);
return this;
}
/**
* Triggers
* @return triggers
**/
@jakarta.annotation.Nullable
public List getTriggers() {
return triggers;
}
public void setTriggers(List triggers) {
this.triggers = triggers;
}
public UpdateTaskDefinitionRequest transitions(List transitions) {
this.transitions = transitions;
return this;
}
public UpdateTaskDefinitionRequest addTransitionsItem(TaskTransitionDefinition transitionsItem) {
if (this.transitions == null) {
this.transitions = new ArrayList<>();
}
this.transitions.add(transitionsItem);
return this;
}
/**
* Transitions
* @return transitions
**/
@jakarta.annotation.Nullable
public List getTransitions() {
return transitions;
}
public void setTransitions(List transitions) {
this.transitions = transitions;
}
public UpdateTaskDefinitionRequest actions(List actions) {
this.actions = actions;
return this;
}
public UpdateTaskDefinitionRequest addActionsItem(ActionDefinition actionsItem) {
if (this.actions == null) {
this.actions = new ArrayList<>();
}
this.actions.add(actionsItem);
return this;
}
/**
* Actions
* @return actions
**/
@jakarta.annotation.Nullable
public List getActions() {
return actions;
}
public void setActions(List actions) {
this.actions = actions;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
UpdateTaskDefinitionRequest updateTaskDefinitionRequest = (UpdateTaskDefinitionRequest) o;
return Objects.equals(this.displayName, updateTaskDefinitionRequest.displayName) &&
Objects.equals(this.description, updateTaskDefinitionRequest.description) &&
Objects.equals(this.states, updateTaskDefinitionRequest.states) &&
Objects.equals(this.fieldSchema, updateTaskDefinitionRequest.fieldSchema) &&
Objects.equals(this.initialState, updateTaskDefinitionRequest.initialState) &&
Objects.equals(this.triggers, updateTaskDefinitionRequest.triggers) &&
Objects.equals(this.transitions, updateTaskDefinitionRequest.transitions) &&
Objects.equals(this.actions, updateTaskDefinitionRequest.actions);
}
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(displayName, description, states, fieldSchema, initialState, triggers, transitions, actions);
}
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 UpdateTaskDefinitionRequest {\n");
sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n");
sb.append(" description: ").append(toIndentedString(description)).append("\n");
sb.append(" states: ").append(toIndentedString(states)).append("\n");
sb.append(" fieldSchema: ").append(toIndentedString(fieldSchema)).append("\n");
sb.append(" initialState: ").append(toIndentedString(initialState)).append("\n");
sb.append(" triggers: ").append(toIndentedString(triggers)).append("\n");
sb.append(" transitions: ").append(toIndentedString(transitions)).append("\n");
sb.append(" actions: ").append(toIndentedString(actions)).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("displayName");
openapiFields.add("description");
openapiFields.add("states");
openapiFields.add("fieldSchema");
openapiFields.add("initialState");
openapiFields.add("triggers");
openapiFields.add("transitions");
openapiFields.add("actions");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("displayName");
openapiRequiredFields.add("states");
openapiRequiredFields.add("initialState");
}
/**
* 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 UpdateTaskDefinitionRequest
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!UpdateTaskDefinitionRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateTaskDefinitionRequest is not found in the empty JSON string", UpdateTaskDefinitionRequest.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : UpdateTaskDefinitionRequest.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("displayName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("displayName").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()));
}
// ensure the json data is an array
if (!jsonObj.get("states").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `states` to be an array in the JSON string but got `%s`", jsonObj.get("states").toString()));
}
JsonArray jsonArraystates = jsonObj.getAsJsonArray("states");
// validate the required field `states` (array)
for (int i = 0; i < jsonArraystates.size(); i++) {
TaskStateDefinition.validateJsonElement(jsonArraystates.get(i));
};
if (jsonObj.get("fieldSchema") != null && !jsonObj.get("fieldSchema").isJsonNull()) {
JsonArray jsonArrayfieldSchema = jsonObj.getAsJsonArray("fieldSchema");
if (jsonArrayfieldSchema != null) {
// ensure the json data is an array
if (!jsonObj.get("fieldSchema").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `fieldSchema` to be an array in the JSON string but got `%s`", jsonObj.get("fieldSchema").toString()));
}
// validate the optional field `fieldSchema` (array)
for (int i = 0; i < jsonArrayfieldSchema.size(); i++) {
TaskFieldDefinition.validateJsonElement(jsonArrayfieldSchema.get(i));
};
}
}
// validate the required field `initialState`
InitialState.validateJsonElement(jsonObj.get("initialState"));
if (jsonObj.get("triggers") != null && !jsonObj.get("triggers").isJsonNull()) {
JsonArray jsonArraytriggers = jsonObj.getAsJsonArray("triggers");
if (jsonArraytriggers != null) {
// ensure the json data is an array
if (!jsonObj.get("triggers").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `triggers` to be an array in the JSON string but got `%s`", jsonObj.get("triggers").toString()));
}
// validate the optional field `triggers` (array)
for (int i = 0; i < jsonArraytriggers.size(); i++) {
TransitionTriggerDefinition.validateJsonElement(jsonArraytriggers.get(i));
};
}
}
if (jsonObj.get("transitions") != null && !jsonObj.get("transitions").isJsonNull()) {
JsonArray jsonArraytransitions = jsonObj.getAsJsonArray("transitions");
if (jsonArraytransitions != null) {
// ensure the json data is an array
if (!jsonObj.get("transitions").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `transitions` to be an array in the JSON string but got `%s`", jsonObj.get("transitions").toString()));
}
// validate the optional field `transitions` (array)
for (int i = 0; i < jsonArraytransitions.size(); i++) {
TaskTransitionDefinition.validateJsonElement(jsonArraytransitions.get(i));
};
}
}
if (jsonObj.get("actions") != null && !jsonObj.get("actions").isJsonNull()) {
JsonArray jsonArrayactions = jsonObj.getAsJsonArray("actions");
if (jsonArrayactions != null) {
// ensure the json data is an array
if (!jsonObj.get("actions").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `actions` to be an array in the JSON string but got `%s`", jsonObj.get("actions").toString()));
}
// validate the optional field `actions` (array)
for (int i = 0; i < jsonArrayactions.size(); i++) {
ActionDefinition.validateJsonElement(jsonArrayactions.get(i));
};
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!UpdateTaskDefinitionRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'UpdateTaskDefinitionRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(UpdateTaskDefinitionRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, UpdateTaskDefinitionRequest value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public UpdateTaskDefinitionRequest read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of UpdateTaskDefinitionRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of UpdateTaskDefinitionRequest
* @throws IOException if the JSON string is invalid with respect to UpdateTaskDefinitionRequest
*/
public static UpdateTaskDefinitionRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, UpdateTaskDefinitionRequest.class);
}
/**
* Convert an instance of UpdateTaskDefinitionRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy