com.finbourne.workflow.model.UpdateMatchingTasksActivityResponse 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.EventHandlerMapping;
import com.finbourne.workflow.model.FieldMapping;
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.HashMap;
import java.util.List;
import java.util.Map;
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;
/**
* Readonly TaskActivity response
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class UpdateMatchingTasksActivityResponse {
/**
* The type of task activity
*/
@JsonAdapter(TypeEnum.Adapter.class)
public enum TypeEnum {
UPDATEMATCHINGTASKS("UpdateMatchingTasks");
private String value;
TypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static TypeEnum fromValue(String value) {
for (TypeEnum b : TypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
return null;
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final TypeEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public TypeEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return TypeEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_TYPE = "type";
@SerializedName(SERIALIZED_NAME_TYPE)
private TypeEnum type;
public static final String SERIALIZED_NAME_FILTER = "filter";
@SerializedName(SERIALIZED_NAME_FILTER)
private String filter;
public static final String SERIALIZED_NAME_TRIGGER = "trigger";
@SerializedName(SERIALIZED_NAME_TRIGGER)
private String trigger;
public static final String SERIALIZED_NAME_CORRELATION_IDS = "correlationIds";
@SerializedName(SERIALIZED_NAME_CORRELATION_IDS)
private List correlationIds;
public static final String SERIALIZED_NAME_TASK_FIELDS = "taskFields";
@SerializedName(SERIALIZED_NAME_TASK_FIELDS)
private Map taskFields;
public UpdateMatchingTasksActivityResponse() {
}
public UpdateMatchingTasksActivityResponse type(TypeEnum type) {
this.type = type;
return this;
}
/**
* The type of task activity
* @return type
**/
@jakarta.annotation.Nullable
public TypeEnum getType() {
return type;
}
public void setType(TypeEnum type) {
this.type = type;
}
public UpdateMatchingTasksActivityResponse filter(String filter) {
this.filter = filter;
return this;
}
/**
* The filter that matches on existing tasks
* @return filter
**/
@jakarta.annotation.Nullable
public String getFilter() {
return filter;
}
public void setFilter(String filter) {
this.filter = filter;
}
public UpdateMatchingTasksActivityResponse trigger(String trigger) {
this.trigger = trigger;
return this;
}
/**
* Trigger to supply to all tasks that have been matched
* @return trigger
**/
@jakarta.annotation.Nullable
public String getTrigger() {
return trigger;
}
public void setTrigger(String trigger) {
this.trigger = trigger;
}
public UpdateMatchingTasksActivityResponse correlationIds(List correlationIds) {
this.correlationIds = correlationIds;
return this;
}
public UpdateMatchingTasksActivityResponse addCorrelationIdsItem(EventHandlerMapping correlationIdsItem) {
if (this.correlationIds == null) {
this.correlationIds = new ArrayList<>();
}
this.correlationIds.add(correlationIdsItem);
return this;
}
/**
* The event to correlation ID mappings
* @return correlationIds
**/
@jakarta.annotation.Nullable
public List getCorrelationIds() {
return correlationIds;
}
public void setCorrelationIds(List correlationIds) {
this.correlationIds = correlationIds;
}
public UpdateMatchingTasksActivityResponse taskFields(Map taskFields) {
this.taskFields = taskFields;
return this;
}
public UpdateMatchingTasksActivityResponse putTaskFieldsItem(String key, FieldMapping taskFieldsItem) {
if (this.taskFields == null) {
this.taskFields = new HashMap<>();
}
this.taskFields.put(key, taskFieldsItem);
return this;
}
/**
* The event to task field mappings
* @return taskFields
**/
@jakarta.annotation.Nullable
public Map getTaskFields() {
return taskFields;
}
public void setTaskFields(Map taskFields) {
this.taskFields = taskFields;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
UpdateMatchingTasksActivityResponse updateMatchingTasksActivityResponse = (UpdateMatchingTasksActivityResponse) o;
return Objects.equals(this.type, updateMatchingTasksActivityResponse.type) &&
Objects.equals(this.filter, updateMatchingTasksActivityResponse.filter) &&
Objects.equals(this.trigger, updateMatchingTasksActivityResponse.trigger) &&
Objects.equals(this.correlationIds, updateMatchingTasksActivityResponse.correlationIds) &&
Objects.equals(this.taskFields, updateMatchingTasksActivityResponse.taskFields);
}
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(type, filter, trigger, correlationIds, taskFields);
}
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 UpdateMatchingTasksActivityResponse {\n");
sb.append(" type: ").append(toIndentedString(type)).append("\n");
sb.append(" filter: ").append(toIndentedString(filter)).append("\n");
sb.append(" trigger: ").append(toIndentedString(trigger)).append("\n");
sb.append(" correlationIds: ").append(toIndentedString(correlationIds)).append("\n");
sb.append(" taskFields: ").append(toIndentedString(taskFields)).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("type");
openapiFields.add("filter");
openapiFields.add("trigger");
openapiFields.add("correlationIds");
openapiFields.add("taskFields");
// 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 UpdateMatchingTasksActivityResponse
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!UpdateMatchingTasksActivityResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in UpdateMatchingTasksActivityResponse is not found in the empty JSON string", UpdateMatchingTasksActivityResponse.openapiRequiredFields.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString()));
}
if ((jsonObj.get("filter") != null && !jsonObj.get("filter").isJsonNull()) && !jsonObj.get("filter").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `filter` to be a primitive type in the JSON string but got `%s`", jsonObj.get("filter").toString()));
}
if ((jsonObj.get("trigger") != null && !jsonObj.get("trigger").isJsonNull()) && !jsonObj.get("trigger").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `trigger` to be a primitive type in the JSON string but got `%s`", jsonObj.get("trigger").toString()));
}
if (jsonObj.get("correlationIds") != null && !jsonObj.get("correlationIds").isJsonNull()) {
JsonArray jsonArraycorrelationIds = jsonObj.getAsJsonArray("correlationIds");
if (jsonArraycorrelationIds != null) {
// ensure the json data is an array
if (!jsonObj.get("correlationIds").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `correlationIds` to be an array in the JSON string but got `%s`", jsonObj.get("correlationIds").toString()));
}
// validate the optional field `correlationIds` (array)
for (int i = 0; i < jsonArraycorrelationIds.size(); i++) {
EventHandlerMapping.validateJsonElement(jsonArraycorrelationIds.get(i));
};
}
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!UpdateMatchingTasksActivityResponse.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'UpdateMatchingTasksActivityResponse' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(UpdateMatchingTasksActivityResponse.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, UpdateMatchingTasksActivityResponse value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public UpdateMatchingTasksActivityResponse read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of UpdateMatchingTasksActivityResponse given an JSON string
*
* @param jsonString JSON string
* @return An instance of UpdateMatchingTasksActivityResponse
* @throws IOException if the JSON string is invalid with respect to UpdateMatchingTasksActivityResponse
*/
public static UpdateMatchingTasksActivityResponse fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, UpdateMatchingTasksActivityResponse.class);
}
/**
* Convert an instance of UpdateMatchingTasksActivityResponse to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}