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

com.finbourne.workflow.model.TaskSummary 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.ResourceId;
import com.finbourne.workflow.model.TaskDefinitionVersion;
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 java.util.UUID;

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;

/**
 * Summary of a Task created based on a Task Definition
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class TaskSummary {
  public static final String SERIALIZED_NAME_ID = "id";
  @SerializedName(SERIALIZED_NAME_ID)
  private UUID id;

  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_VERSION = "taskDefinitionVersion";
  @SerializedName(SERIALIZED_NAME_TASK_DEFINITION_VERSION)
  private TaskDefinitionVersion taskDefinitionVersion;

  public static final String SERIALIZED_NAME_TASK_DEFINITION_DISPLAY_NAME = "taskDefinitionDisplayName";
  @SerializedName(SERIALIZED_NAME_TASK_DEFINITION_DISPLAY_NAME)
  private String taskDefinitionDisplayName;

  public static final String SERIALIZED_NAME_STATE = "state";
  @SerializedName(SERIALIZED_NAME_STATE)
  private String state;

  public TaskSummary() {
  }

  public TaskSummary id(UUID id) {
    
    this.id = id;
    return this;
  }

   /**
   * The unique id for this Task
   * @return id
  **/
  @jakarta.annotation.Nonnull
  public UUID getId() {
    return id;
  }


  public void setId(UUID id) {
    this.id = id;
  }


  public TaskSummary 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 TaskSummary taskDefinitionVersion(TaskDefinitionVersion taskDefinitionVersion) {
    
    this.taskDefinitionVersion = taskDefinitionVersion;
    return this;
  }

   /**
   * Get taskDefinitionVersion
   * @return taskDefinitionVersion
  **/
  @jakarta.annotation.Nonnull
  public TaskDefinitionVersion getTaskDefinitionVersion() {
    return taskDefinitionVersion;
  }


  public void setTaskDefinitionVersion(TaskDefinitionVersion taskDefinitionVersion) {
    this.taskDefinitionVersion = taskDefinitionVersion;
  }


  public TaskSummary taskDefinitionDisplayName(String taskDefinitionDisplayName) {
    
    this.taskDefinitionDisplayName = taskDefinitionDisplayName;
    return this;
  }

   /**
   * The display name of the Task Definition used by this Task
   * @return taskDefinitionDisplayName
  **/
  @jakarta.annotation.Nonnull
  public String getTaskDefinitionDisplayName() {
    return taskDefinitionDisplayName;
  }


  public void setTaskDefinitionDisplayName(String taskDefinitionDisplayName) {
    this.taskDefinitionDisplayName = taskDefinitionDisplayName;
  }


  public TaskSummary state(String state) {
    
    this.state = state;
    return this;
  }

   /**
   * Current State
   * @return state
  **/
  @jakarta.annotation.Nonnull
  public String getState() {
    return state;
  }


  public void setState(String state) {
    this.state = state;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    TaskSummary taskSummary = (TaskSummary) o;
    return Objects.equals(this.id, taskSummary.id) &&
        Objects.equals(this.taskDefinitionId, taskSummary.taskDefinitionId) &&
        Objects.equals(this.taskDefinitionVersion, taskSummary.taskDefinitionVersion) &&
        Objects.equals(this.taskDefinitionDisplayName, taskSummary.taskDefinitionDisplayName) &&
        Objects.equals(this.state, taskSummary.state);
  }

  @Override
  public int hashCode() {
    return Objects.hash(id, taskDefinitionId, taskDefinitionVersion, taskDefinitionDisplayName, state);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class TaskSummary {\n");
    sb.append("    id: ").append(toIndentedString(id)).append("\n");
    sb.append("    taskDefinitionId: ").append(toIndentedString(taskDefinitionId)).append("\n");
    sb.append("    taskDefinitionVersion: ").append(toIndentedString(taskDefinitionVersion)).append("\n");
    sb.append("    taskDefinitionDisplayName: ").append(toIndentedString(taskDefinitionDisplayName)).append("\n");
    sb.append("    state: ").append(toIndentedString(state)).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("id");
    openapiFields.add("taskDefinitionId");
    openapiFields.add("taskDefinitionVersion");
    openapiFields.add("taskDefinitionDisplayName");
    openapiFields.add("state");

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

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

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

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

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

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

       }.nullSafe();
    }
  }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy