com.finbourne.workflow.model.ActionLog 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.ActionLogItem;
import com.finbourne.workflow.model.ActionLogOrigin;
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 java.util.UUID;
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;
/**
* An Action Log contains the processing history of an Action
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ActionLog {
public static final String SERIALIZED_NAME_ID = "id";
@SerializedName(SERIALIZED_NAME_ID)
private UUID id;
public static final String SERIALIZED_NAME_ORIGIN = "origin";
@SerializedName(SERIALIZED_NAME_ORIGIN)
private ActionLogOrigin origin;
public static final String SERIALIZED_NAME_ACTION_TYPE = "actionType";
@SerializedName(SERIALIZED_NAME_ACTION_TYPE)
private String actionType;
public static final String SERIALIZED_NAME_RUN_AS_USER_ID = "runAsUserId";
@SerializedName(SERIALIZED_NAME_RUN_AS_USER_ID)
private String runAsUserId;
public static final String SERIALIZED_NAME_LOGGED_ITEMS = "loggedItems";
@SerializedName(SERIALIZED_NAME_LOGGED_ITEMS)
private List loggedItems = new ArrayList<>();
public ActionLog() {
}
public ActionLog id(UUID id) {
this.id = id;
return this;
}
/**
* Unique identifier of the Action
* @return id
**/
@jakarta.annotation.Nonnull
public UUID getId() {
return id;
}
public void setId(UUID id) {
this.id = id;
}
public ActionLog origin(ActionLogOrigin origin) {
this.origin = origin;
return this;
}
/**
* Get origin
* @return origin
**/
@jakarta.annotation.Nonnull
public ActionLogOrigin getOrigin() {
return origin;
}
public void setOrigin(ActionLogOrigin origin) {
this.origin = origin;
}
public ActionLog actionType(String actionType) {
this.actionType = actionType;
return this;
}
/**
* The type of the Action
* @return actionType
**/
@jakarta.annotation.Nonnull
public String getActionType() {
return actionType;
}
public void setActionType(String actionType) {
this.actionType = actionType;
}
public ActionLog runAsUserId(String runAsUserId) {
this.runAsUserId = runAsUserId;
return this;
}
/**
* The ID of the user that the Action was performed by. If not specified, the actions were performed by the \"current user\".
* @return runAsUserId
**/
@jakarta.annotation.Nullable
public String getRunAsUserId() {
return runAsUserId;
}
public void setRunAsUserId(String runAsUserId) {
this.runAsUserId = runAsUserId;
}
public ActionLog loggedItems(List loggedItems) {
this.loggedItems = loggedItems;
return this;
}
public ActionLog addLoggedItemsItem(ActionLogItem loggedItemsItem) {
if (this.loggedItems == null) {
this.loggedItems = new ArrayList<>();
}
this.loggedItems.add(loggedItemsItem);
return this;
}
/**
* The logged items for this Action
* @return loggedItems
**/
@jakarta.annotation.Nonnull
public List getLoggedItems() {
return loggedItems;
}
public void setLoggedItems(List loggedItems) {
this.loggedItems = loggedItems;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ActionLog actionLog = (ActionLog) o;
return Objects.equals(this.id, actionLog.id) &&
Objects.equals(this.origin, actionLog.origin) &&
Objects.equals(this.actionType, actionLog.actionType) &&
Objects.equals(this.runAsUserId, actionLog.runAsUserId) &&
Objects.equals(this.loggedItems, actionLog.loggedItems);
}
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(id, origin, actionType, runAsUserId, loggedItems);
}
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 ActionLog {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" origin: ").append(toIndentedString(origin)).append("\n");
sb.append(" actionType: ").append(toIndentedString(actionType)).append("\n");
sb.append(" runAsUserId: ").append(toIndentedString(runAsUserId)).append("\n");
sb.append(" loggedItems: ").append(toIndentedString(loggedItems)).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("origin");
openapiFields.add("actionType");
openapiFields.add("runAsUserId");
openapiFields.add("loggedItems");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("id");
openapiRequiredFields.add("origin");
openapiRequiredFields.add("actionType");
openapiRequiredFields.add("loggedItems");
}
/**
* 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 ActionLog
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!ActionLog.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ActionLog is not found in the empty JSON string", ActionLog.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : ActionLog.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 `origin`
ActionLogOrigin.validateJsonElement(jsonObj.get("origin"));
if (!jsonObj.get("actionType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `actionType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("actionType").toString()));
}
if ((jsonObj.get("runAsUserId") != null && !jsonObj.get("runAsUserId").isJsonNull()) && !jsonObj.get("runAsUserId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `runAsUserId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("runAsUserId").toString()));
}
// ensure the json data is an array
if (!jsonObj.get("loggedItems").isJsonArray()) {
throw new IllegalArgumentException(String.format("Expected the field `loggedItems` to be an array in the JSON string but got `%s`", jsonObj.get("loggedItems").toString()));
}
JsonArray jsonArrayloggedItems = jsonObj.getAsJsonArray("loggedItems");
// validate the required field `loggedItems` (array)
for (int i = 0; i < jsonArrayloggedItems.size(); i++) {
ActionLogItem.validateJsonElement(jsonArrayloggedItems.get(i));
};
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!ActionLog.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'ActionLog' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(ActionLog.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, ActionLog value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public ActionLog read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of ActionLog given an JSON string
*
* @param jsonString JSON string
* @return An instance of ActionLog
* @throws IOException if the JSON string is invalid with respect to ActionLog
*/
public static ActionLog fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, ActionLog.class);
}
/**
* Convert an instance of ActionLog to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy