com.finbourne.horizon.model.AuditUpdateRequest Maven / Gradle / Ivy
The newest version!
/*
* FINBOURNE Horizon 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.horizon.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.horizon.JSON;
/**
* An incoming request for a Horizon Update Event
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class AuditUpdateRequest {
public static final String SERIALIZED_NAME_ID = "id";
@SerializedName(SERIALIZED_NAME_ID)
private String id;
public static final String SERIALIZED_NAME_USER_ID = "userId";
@SerializedName(SERIALIZED_NAME_USER_ID)
private String userId;
public static final String SERIALIZED_NAME_SCHEDULER_RUN_ID = "schedulerRunId";
@SerializedName(SERIALIZED_NAME_SCHEDULER_RUN_ID)
private String schedulerRunId;
public static final String SERIALIZED_NAME_START_TIME = "startTime";
@SerializedName(SERIALIZED_NAME_START_TIME)
private OffsetDateTime startTime;
public static final String SERIALIZED_NAME_MESSAGE = "message";
@SerializedName(SERIALIZED_NAME_MESSAGE)
private String message;
public static final String SERIALIZED_NAME_PROCESS_NAME_OVERRIDE = "processNameOverride";
@SerializedName(SERIALIZED_NAME_PROCESS_NAME_OVERRIDE)
private String processNameOverride;
public AuditUpdateRequest() {
}
public AuditUpdateRequest id(String id) {
this.id = id;
return this;
}
/**
* A unique ID identifiying the source of the event
* @return id
**/
@jakarta.annotation.Nonnull
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public AuditUpdateRequest userId(String userId) {
this.userId = userId;
return this;
}
/**
* A unique ID identifiying who owns the schedule
* @return userId
**/
@jakarta.annotation.Nonnull
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public AuditUpdateRequest schedulerRunId(String schedulerRunId) {
this.schedulerRunId = schedulerRunId;
return this;
}
/**
* The GUID of the schedule run
* @return schedulerRunId
**/
@jakarta.annotation.Nonnull
public String getSchedulerRunId() {
return schedulerRunId;
}
public void setSchedulerRunId(String schedulerRunId) {
this.schedulerRunId = schedulerRunId;
}
public AuditUpdateRequest startTime(OffsetDateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* When the run was started in UTC
* @return startTime
**/
@jakarta.annotation.Nonnull
public OffsetDateTime getStartTime() {
return startTime;
}
public void setStartTime(OffsetDateTime startTime) {
this.startTime = startTime;
}
public AuditUpdateRequest message(String message) {
this.message = message;
return this;
}
/**
* A descriptive message to accompany the status
* @return message
**/
@jakarta.annotation.Nonnull
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public AuditUpdateRequest processNameOverride(String processNameOverride) {
this.processNameOverride = processNameOverride;
return this;
}
/**
* Optional Name for how the process appears in Data Feed Monitoring
* @return processNameOverride
**/
@jakarta.annotation.Nullable
public String getProcessNameOverride() {
return processNameOverride;
}
public void setProcessNameOverride(String processNameOverride) {
this.processNameOverride = processNameOverride;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
AuditUpdateRequest auditUpdateRequest = (AuditUpdateRequest) o;
return Objects.equals(this.id, auditUpdateRequest.id) &&
Objects.equals(this.userId, auditUpdateRequest.userId) &&
Objects.equals(this.schedulerRunId, auditUpdateRequest.schedulerRunId) &&
Objects.equals(this.startTime, auditUpdateRequest.startTime) &&
Objects.equals(this.message, auditUpdateRequest.message) &&
Objects.equals(this.processNameOverride, auditUpdateRequest.processNameOverride);
}
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, userId, schedulerRunId, startTime, message, processNameOverride);
}
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 AuditUpdateRequest {\n");
sb.append(" id: ").append(toIndentedString(id)).append("\n");
sb.append(" userId: ").append(toIndentedString(userId)).append("\n");
sb.append(" schedulerRunId: ").append(toIndentedString(schedulerRunId)).append("\n");
sb.append(" startTime: ").append(toIndentedString(startTime)).append("\n");
sb.append(" message: ").append(toIndentedString(message)).append("\n");
sb.append(" processNameOverride: ").append(toIndentedString(processNameOverride)).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("userId");
openapiFields.add("schedulerRunId");
openapiFields.add("startTime");
openapiFields.add("message");
openapiFields.add("processNameOverride");
// a set of required properties/fields (JSON key names)
openapiRequiredFields = new HashSet();
openapiRequiredFields.add("id");
openapiRequiredFields.add("userId");
openapiRequiredFields.add("schedulerRunId");
openapiRequiredFields.add("startTime");
openapiRequiredFields.add("message");
}
/**
* 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 AuditUpdateRequest
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!AuditUpdateRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in AuditUpdateRequest is not found in the empty JSON string", AuditUpdateRequest.openapiRequiredFields.toString()));
}
}
// check to make sure all required properties/fields are present in the JSON string
for (String requiredField : AuditUpdateRequest.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()));
}
if (!jsonObj.get("userId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `userId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("userId").toString()));
}
if (!jsonObj.get("schedulerRunId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `schedulerRunId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("schedulerRunId").toString()));
}
if (!jsonObj.get("message").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `message` to be a primitive type in the JSON string but got `%s`", jsonObj.get("message").toString()));
}
if ((jsonObj.get("processNameOverride") != null && !jsonObj.get("processNameOverride").isJsonNull()) && !jsonObj.get("processNameOverride").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `processNameOverride` to be a primitive type in the JSON string but got `%s`", jsonObj.get("processNameOverride").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!AuditUpdateRequest.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'AuditUpdateRequest' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(AuditUpdateRequest.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, AuditUpdateRequest value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public AuditUpdateRequest read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of AuditUpdateRequest given an JSON string
*
* @param jsonString JSON string
* @return An instance of AuditUpdateRequest
* @throws IOException if the JSON string is invalid with respect to AuditUpdateRequest
*/
public static AuditUpdateRequest fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, AuditUpdateRequest.class);
}
/**
* Convert an instance of AuditUpdateRequest to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}