All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.finbourne.workflow.model.CreateChildTaskConfiguration Maven / Gradle / Ivy

There is a newer version: 2.0.166
Show newest version
/*
 * 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.FieldMapping;
import com.finbourne.workflow.model.ResourceId;
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.time.OffsetDateTime;
import java.util.Arrays;
import java.util.HashMap;
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;

/**
 * Create Child Task Configuration
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class CreateChildTaskConfiguration {
  public static final String SERIALIZED_NAME_TASK_DEFINITION_ID = "taskDefinitionId";
  @SerializedName(SERIALIZED_NAME_TASK_DEFINITION_ID)
  private ResourceId taskDefinitionId;

  public static final String SERIALIZED_NAME_TASK_DEFINITION_AS_AT = "taskDefinitionAsAt";
  @SerializedName(SERIALIZED_NAME_TASK_DEFINITION_AS_AT)
  private OffsetDateTime taskDefinitionAsAt;

  public static final String SERIALIZED_NAME_INITIAL_TRIGGER = "initialTrigger";
  @SerializedName(SERIALIZED_NAME_INITIAL_TRIGGER)
  private String initialTrigger;

  public static final String SERIALIZED_NAME_CHILD_TASK_FIELDS = "childTaskFields";
  @SerializedName(SERIALIZED_NAME_CHILD_TASK_FIELDS)
  private Map childTaskFields;

  public static final String SERIALIZED_NAME_MAP_STACKING_KEY_FROM = "mapStackingKeyFrom";
  @SerializedName(SERIALIZED_NAME_MAP_STACKING_KEY_FROM)
  private String mapStackingKeyFrom;

  public CreateChildTaskConfiguration() {
  }

  public CreateChildTaskConfiguration taskDefinitionId(ResourceId taskDefinitionId) {
    
    this.taskDefinitionId = taskDefinitionId;
    return this;
  }

   /**
   * Get taskDefinitionId
   * @return taskDefinitionId
  **/
  @jakarta.annotation.Nonnull
  public ResourceId getTaskDefinitionId() {
    return taskDefinitionId;
  }


  public void setTaskDefinitionId(ResourceId taskDefinitionId) {
    this.taskDefinitionId = taskDefinitionId;
  }


  public CreateChildTaskConfiguration taskDefinitionAsAt(OffsetDateTime taskDefinitionAsAt) {
    
    this.taskDefinitionAsAt = taskDefinitionAsAt;
    return this;
  }

   /**
   * TaskDefinition AsAt timestamp
   * @return taskDefinitionAsAt
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getTaskDefinitionAsAt() {
    return taskDefinitionAsAt;
  }


  public void setTaskDefinitionAsAt(OffsetDateTime taskDefinitionAsAt) {
    this.taskDefinitionAsAt = taskDefinitionAsAt;
  }


  public CreateChildTaskConfiguration initialTrigger(String initialTrigger) {
    
    this.initialTrigger = initialTrigger;
    return this;
  }

   /**
   * The Initial Trigger for automatic start
   * @return initialTrigger
  **/
  @jakarta.annotation.Nullable
  public String getInitialTrigger() {
    return initialTrigger;
  }


  public void setInitialTrigger(String initialTrigger) {
    this.initialTrigger = initialTrigger;
  }


  public CreateChildTaskConfiguration childTaskFields(Map childTaskFields) {
    
    this.childTaskFields = childTaskFields;
    return this;
  }

  public CreateChildTaskConfiguration putChildTaskFieldsItem(String key, FieldMapping childTaskFieldsItem) {
    if (this.childTaskFields == null) {
      this.childTaskFields = new HashMap<>();
    }
    this.childTaskFields.put(key, childTaskFieldsItem);
    return this;
  }

   /**
   * Field Mappings
   * @return childTaskFields
  **/
  @jakarta.annotation.Nullable
  public Map getChildTaskFields() {
    return childTaskFields;
  }


  public void setChildTaskFields(Map childTaskFields) {
    this.childTaskFields = childTaskFields;
  }


  public CreateChildTaskConfiguration mapStackingKeyFrom(String mapStackingKeyFrom) {
    
    this.mapStackingKeyFrom = mapStackingKeyFrom;
    return this;
  }

   /**
   * If present, the value of this field on the parent task will be the Stacking Key on any created child tasks
   * @return mapStackingKeyFrom
  **/
  @jakarta.annotation.Nullable
  public String getMapStackingKeyFrom() {
    return mapStackingKeyFrom;
  }


  public void setMapStackingKeyFrom(String mapStackingKeyFrom) {
    this.mapStackingKeyFrom = mapStackingKeyFrom;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    CreateChildTaskConfiguration createChildTaskConfiguration = (CreateChildTaskConfiguration) o;
    return Objects.equals(this.taskDefinitionId, createChildTaskConfiguration.taskDefinitionId) &&
        Objects.equals(this.taskDefinitionAsAt, createChildTaskConfiguration.taskDefinitionAsAt) &&
        Objects.equals(this.initialTrigger, createChildTaskConfiguration.initialTrigger) &&
        Objects.equals(this.childTaskFields, createChildTaskConfiguration.childTaskFields) &&
        Objects.equals(this.mapStackingKeyFrom, createChildTaskConfiguration.mapStackingKeyFrom);
  }

  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(taskDefinitionId, taskDefinitionAsAt, initialTrigger, childTaskFields, mapStackingKeyFrom);
  }

  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 CreateChildTaskConfiguration {\n");
    sb.append("    taskDefinitionId: ").append(toIndentedString(taskDefinitionId)).append("\n");
    sb.append("    taskDefinitionAsAt: ").append(toIndentedString(taskDefinitionAsAt)).append("\n");
    sb.append("    initialTrigger: ").append(toIndentedString(initialTrigger)).append("\n");
    sb.append("    childTaskFields: ").append(toIndentedString(childTaskFields)).append("\n");
    sb.append("    mapStackingKeyFrom: ").append(toIndentedString(mapStackingKeyFrom)).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("taskDefinitionId");
    openapiFields.add("taskDefinitionAsAt");
    openapiFields.add("initialTrigger");
    openapiFields.add("childTaskFields");
    openapiFields.add("mapStackingKeyFrom");

    // a set of required properties/fields (JSON key names)
    openapiRequiredFields = new HashSet();
    openapiRequiredFields.add("taskDefinitionId");
  }

 /**
  * 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 CreateChildTaskConfiguration
  */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!CreateChildTaskConfiguration.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in CreateChildTaskConfiguration is not found in the empty JSON string", CreateChildTaskConfiguration.openapiRequiredFields.toString()));
        }
      }

      // check to make sure all required properties/fields are present in the JSON string
      for (String requiredField : CreateChildTaskConfiguration.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();
      // validate the required field `taskDefinitionId`
      ResourceId.validateJsonElement(jsonObj.get("taskDefinitionId"));
      if ((jsonObj.get("initialTrigger") != null && !jsonObj.get("initialTrigger").isJsonNull()) && !jsonObj.get("initialTrigger").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `initialTrigger` to be a primitive type in the JSON string but got `%s`", jsonObj.get("initialTrigger").toString()));
      }
      if ((jsonObj.get("mapStackingKeyFrom") != null && !jsonObj.get("mapStackingKeyFrom").isJsonNull()) && !jsonObj.get("mapStackingKeyFrom").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `mapStackingKeyFrom` to be a primitive type in the JSON string but got `%s`", jsonObj.get("mapStackingKeyFrom").toString()));
      }
  }

  public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
    @SuppressWarnings("unchecked")
    @Override
    public  TypeAdapter create(Gson gson, TypeToken type) {
       if (!CreateChildTaskConfiguration.class.isAssignableFrom(type.getRawType())) {
         return null; // this class only serializes 'CreateChildTaskConfiguration' and its subtypes
       }
       final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
       final TypeAdapter thisAdapter
                        = gson.getDelegateAdapter(this, TypeToken.get(CreateChildTaskConfiguration.class));

       return (TypeAdapter) new TypeAdapter() {
           @Override
           public void write(JsonWriter out, CreateChildTaskConfiguration value) throws IOException {
             JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
             elementAdapter.write(out, obj);
           }

           @Override
           public CreateChildTaskConfiguration read(JsonReader in) throws IOException {
             JsonElement jsonElement = elementAdapter.read(in);
             validateJsonElement(jsonElement);
             return thisAdapter.fromJsonTree(jsonElement);
           }

       }.nullSafe();
    }
  }

 /**
  * Create an instance of CreateChildTaskConfiguration given an JSON string
  *
  * @param jsonString JSON string
  * @return An instance of CreateChildTaskConfiguration
  * @throws IOException if the JSON string is invalid with respect to CreateChildTaskConfiguration
  */
  public static CreateChildTaskConfiguration fromJson(String jsonString) throws IOException {
    return JSON.getGson().fromJson(jsonString, CreateChildTaskConfiguration.class);
  }

 /**
  * Convert an instance of CreateChildTaskConfiguration to an JSON string
  *
  * @return JSON string
  */
  public String toJson() {
    return JSON.getGson().toJson(this);
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy