Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* 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.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 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;
/**
* Defines a change that occured to a Task
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class ChangeItem {
public static final String SERIALIZED_NAME_AS_AT_MODIFIED = "asAtModified";
@SerializedName(SERIALIZED_NAME_AS_AT_MODIFIED)
private OffsetDateTime asAtModified;
public static final String SERIALIZED_NAME_USER_ID_MODIFIED = "userIdModified";
@SerializedName(SERIALIZED_NAME_USER_ID_MODIFIED)
private String userIdModified;
public static final String SERIALIZED_NAME_REQUEST_ID_MODIFIED = "requestIdModified";
@SerializedName(SERIALIZED_NAME_REQUEST_ID_MODIFIED)
private String requestIdModified;
public static final String SERIALIZED_NAME_AS_AT_VERSION_NUMBER = "asAtVersionNumber";
@SerializedName(SERIALIZED_NAME_AS_AT_VERSION_NUMBER)
private Integer asAtVersionNumber;
public static final String SERIALIZED_NAME_ACTION = "action";
@SerializedName(SERIALIZED_NAME_ACTION)
private String action;
public static final String SERIALIZED_NAME_ATTRIBUTE_NAME = "attributeName";
@SerializedName(SERIALIZED_NAME_ATTRIBUTE_NAME)
private String attributeName;
public static final String SERIALIZED_NAME_PREVIOUS_VALUE = "previousValue";
@SerializedName(SERIALIZED_NAME_PREVIOUS_VALUE)
private Object previousValue = null;
public static final String SERIALIZED_NAME_NEW_VALUE = "newValue";
@SerializedName(SERIALIZED_NAME_NEW_VALUE)
private Object newValue = null;
public ChangeItem() {
}
public ChangeItem asAtModified(OffsetDateTime asAtModified) {
this.asAtModified = asAtModified;
return this;
}
/**
* The AsAt time of the change
* @return asAtModified
**/
@jakarta.annotation.Nonnull
public OffsetDateTime getAsAtModified() {
return asAtModified;
}
public void setAsAtModified(OffsetDateTime asAtModified) {
this.asAtModified = asAtModified;
}
public ChangeItem userIdModified(String userIdModified) {
this.userIdModified = userIdModified;
return this;
}
/**
* The User ID that performed the change
* @return userIdModified
**/
@jakarta.annotation.Nonnull
public String getUserIdModified() {
return userIdModified;
}
public void setUserIdModified(String userIdModified) {
this.userIdModified = userIdModified;
}
public ChangeItem requestIdModified(String requestIdModified) {
this.requestIdModified = requestIdModified;
return this;
}
/**
* The Request ID of the request that caused the change
* @return requestIdModified
**/
@jakarta.annotation.Nonnull
public String getRequestIdModified() {
return requestIdModified;
}
public void setRequestIdModified(String requestIdModified) {
this.requestIdModified = requestIdModified;
}
public ChangeItem asAtVersionNumber(Integer asAtVersionNumber) {
this.asAtVersionNumber = asAtVersionNumber;
return this;
}
/**
* The AsAt Version number
* @return asAtVersionNumber
**/
@jakarta.annotation.Nonnull
public Integer getAsAtVersionNumber() {
return asAtVersionNumber;
}
public void setAsAtVersionNumber(Integer asAtVersionNumber) {
this.asAtVersionNumber = asAtVersionNumber;
}
public ChangeItem action(String action) {
this.action = action;
return this;
}
/**
* The Action that resulted in the change
* @return action
**/
@jakarta.annotation.Nonnull
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public ChangeItem attributeName(String attributeName) {
this.attributeName = attributeName;
return this;
}
/**
* The name of the attribute that has been change
* @return attributeName
**/
@jakarta.annotation.Nonnull
public String getAttributeName() {
return attributeName;
}
public void setAttributeName(String attributeName) {
this.attributeName = attributeName;
}
public ChangeItem previousValue(Object previousValue) {
this.previousValue = previousValue;
return this;
}
/**
* The value of the attribute prior to the change
* @return previousValue
**/
@jakarta.annotation.Nullable
public Object getPreviousValue() {
return previousValue;
}
public void setPreviousValue(Object previousValue) {
this.previousValue = previousValue;
}
public ChangeItem newValue(Object newValue) {
this.newValue = newValue;
return this;
}
/**
* The value of the attribute following the change
* @return newValue
**/
@jakarta.annotation.Nullable
public Object getNewValue() {
return newValue;
}
public void setNewValue(Object newValue) {
this.newValue = newValue;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ChangeItem changeItem = (ChangeItem) o;
return Objects.equals(this.asAtModified, changeItem.asAtModified) &&
Objects.equals(this.userIdModified, changeItem.userIdModified) &&
Objects.equals(this.requestIdModified, changeItem.requestIdModified) &&
Objects.equals(this.asAtVersionNumber, changeItem.asAtVersionNumber) &&
Objects.equals(this.action, changeItem.action) &&
Objects.equals(this.attributeName, changeItem.attributeName) &&
Objects.equals(this.previousValue, changeItem.previousValue) &&
Objects.equals(this.newValue, changeItem.newValue);
}
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(asAtModified, userIdModified, requestIdModified, asAtVersionNumber, action, attributeName, previousValue, newValue);
}
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 ChangeItem {\n");
sb.append(" asAtModified: ").append(toIndentedString(asAtModified)).append("\n");
sb.append(" userIdModified: ").append(toIndentedString(userIdModified)).append("\n");
sb.append(" requestIdModified: ").append(toIndentedString(requestIdModified)).append("\n");
sb.append(" asAtVersionNumber: ").append(toIndentedString(asAtVersionNumber)).append("\n");
sb.append(" action: ").append(toIndentedString(action)).append("\n");
sb.append(" attributeName: ").append(toIndentedString(attributeName)).append("\n");
sb.append(" previousValue: ").append(toIndentedString(previousValue)).append("\n");
sb.append(" newValue: ").append(toIndentedString(newValue)).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("asAtModified");
openapiFields.add("userIdModified");
openapiFields.add("requestIdModified");
openapiFields.add("asAtVersionNumber");
openapiFields.add("action");
openapiFields.add("attributeName");
openapiFields.add("previousValue");
openapiFields.add("newValue");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("asAtModified");
openapiRequiredFields.add("userIdModified");
openapiRequiredFields.add("requestIdModified");
openapiRequiredFields.add("asAtVersionNumber");
openapiRequiredFields.add("action");
openapiRequiredFields.add("attributeName");
openapiRequiredFields.add("newValue");
}
/**
* 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 ChangeItem
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!ChangeItem.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ChangeItem is not found in the empty JSON string", ChangeItem.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : ChangeItem.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("userIdModified").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `userIdModified` to be a primitive type in the JSON string but got `%s`", jsonObj.get("userIdModified").toString()));
}
if (!jsonObj.get("requestIdModified").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `requestIdModified` to be a primitive type in the JSON string but got `%s`", jsonObj.get("requestIdModified").toString()));
}
if (!jsonObj.get("action").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `action` to be a primitive type in the JSON string but got `%s`", jsonObj.get("action").toString()));
}
if (!jsonObj.get("attributeName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `attributeName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("attributeName").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!ChangeItem.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'ChangeItem' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(ChangeItem.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, ChangeItem value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public ChangeItem read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of ChangeItem given an JSON string
*
* @param jsonString JSON string
* @return An instance of ChangeItem
* @throws IOException if the JSON string is invalid with respect to ChangeItem
*/
public static ChangeItem fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, ChangeItem.class);
}
/**
* Convert an instance of ChangeItem to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}