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

com.finbourne.workflow.model.VersionInfo 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.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;

/**
 * The version metadata.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
public class VersionInfo {
  public static final String SERIALIZED_NAME_AS_AT_CREATED = "asAtCreated";
  @SerializedName(SERIALIZED_NAME_AS_AT_CREATED)
  private OffsetDateTime asAtCreated;

  public static final String SERIALIZED_NAME_USER_ID_CREATED = "userIdCreated";
  @SerializedName(SERIALIZED_NAME_USER_ID_CREATED)
  private String userIdCreated;

  public static final String SERIALIZED_NAME_REQUEST_ID_CREATED = "requestIdCreated";
  @SerializedName(SERIALIZED_NAME_REQUEST_ID_CREATED)
  private String requestIdCreated;

  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 VersionInfo() {
  }

  public VersionInfo asAtCreated(OffsetDateTime asAtCreated) {
    
    this.asAtCreated = asAtCreated;
    return this;
  }

   /**
   * The asAt datetime at which this entity was first created.
   * @return asAtCreated
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getAsAtCreated() {
    return asAtCreated;
  }


  public void setAsAtCreated(OffsetDateTime asAtCreated) {
    this.asAtCreated = asAtCreated;
  }


  public VersionInfo userIdCreated(String userIdCreated) {
    
    this.userIdCreated = userIdCreated;
    return this;
  }

   /**
   * The unique id of the user who created this entity.
   * @return userIdCreated
  **/
  @jakarta.annotation.Nullable
  public String getUserIdCreated() {
    return userIdCreated;
  }


  public void setUserIdCreated(String userIdCreated) {
    this.userIdCreated = userIdCreated;
  }


  public VersionInfo requestIdCreated(String requestIdCreated) {
    
    this.requestIdCreated = requestIdCreated;
    return this;
  }

   /**
   * The request id of the request that created this entity.
   * @return requestIdCreated
  **/
  @jakarta.annotation.Nullable
  public String getRequestIdCreated() {
    return requestIdCreated;
  }


  public void setRequestIdCreated(String requestIdCreated) {
    this.requestIdCreated = requestIdCreated;
  }


  public VersionInfo asAtModified(OffsetDateTime asAtModified) {
    
    this.asAtModified = asAtModified;
    return this;
  }

   /**
   * The asAt datetime at which this entity was last updated.
   * @return asAtModified
  **/
  @jakarta.annotation.Nullable
  public OffsetDateTime getAsAtModified() {
    return asAtModified;
  }


  public void setAsAtModified(OffsetDateTime asAtModified) {
    this.asAtModified = asAtModified;
  }


  public VersionInfo userIdModified(String userIdModified) {
    
    this.userIdModified = userIdModified;
    return this;
  }

   /**
   * The unique id of the user who last updated this entity.
   * @return userIdModified
  **/
  @jakarta.annotation.Nullable
  public String getUserIdModified() {
    return userIdModified;
  }


  public void setUserIdModified(String userIdModified) {
    this.userIdModified = userIdModified;
  }


  public VersionInfo requestIdModified(String requestIdModified) {
    
    this.requestIdModified = requestIdModified;
    return this;
  }

   /**
   * The request id of the request that last updated this entity.
   * @return requestIdModified
  **/
  @jakarta.annotation.Nullable
  public String getRequestIdModified() {
    return requestIdModified;
  }


  public void setRequestIdModified(String requestIdModified) {
    this.requestIdModified = requestIdModified;
  }


  public VersionInfo asAtVersionNumber(Integer asAtVersionNumber) {
    
    this.asAtVersionNumber = asAtVersionNumber;
    return this;
  }

   /**
   * The integer version number for this entity (the entity was created at version 1).
   * @return asAtVersionNumber
  **/
  @jakarta.annotation.Nullable
  public Integer getAsAtVersionNumber() {
    return asAtVersionNumber;
  }


  public void setAsAtVersionNumber(Integer asAtVersionNumber) {
    this.asAtVersionNumber = asAtVersionNumber;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    VersionInfo versionInfo = (VersionInfo) o;
    return Objects.equals(this.asAtCreated, versionInfo.asAtCreated) &&
        Objects.equals(this.userIdCreated, versionInfo.userIdCreated) &&
        Objects.equals(this.requestIdCreated, versionInfo.requestIdCreated) &&
        Objects.equals(this.asAtModified, versionInfo.asAtModified) &&
        Objects.equals(this.userIdModified, versionInfo.userIdModified) &&
        Objects.equals(this.requestIdModified, versionInfo.requestIdModified) &&
        Objects.equals(this.asAtVersionNumber, versionInfo.asAtVersionNumber);
  }

  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(asAtCreated, userIdCreated, requestIdCreated, asAtModified, userIdModified, requestIdModified, asAtVersionNumber);
  }

  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 VersionInfo {\n");
    sb.append("    asAtCreated: ").append(toIndentedString(asAtCreated)).append("\n");
    sb.append("    userIdCreated: ").append(toIndentedString(userIdCreated)).append("\n");
    sb.append("    requestIdCreated: ").append(toIndentedString(requestIdCreated)).append("\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("}");
    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("asAtCreated");
    openapiFields.add("userIdCreated");
    openapiFields.add("requestIdCreated");
    openapiFields.add("asAtModified");
    openapiFields.add("userIdModified");
    openapiFields.add("requestIdModified");
    openapiFields.add("asAtVersionNumber");

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

 /**
  * 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 VersionInfo
  */
  public static void validateJsonElement(JsonElement jsonElement) throws IOException {
      if (jsonElement == null) {
        if (!VersionInfo.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
          throw new IllegalArgumentException(String.format("The required field(s) %s in VersionInfo is not found in the empty JSON string", VersionInfo.openapiRequiredFields.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("userIdCreated") != null && !jsonObj.get("userIdCreated").isJsonNull()) && !jsonObj.get("userIdCreated").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `userIdCreated` to be a primitive type in the JSON string but got `%s`", jsonObj.get("userIdCreated").toString()));
      }
      if ((jsonObj.get("requestIdCreated") != null && !jsonObj.get("requestIdCreated").isJsonNull()) && !jsonObj.get("requestIdCreated").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `requestIdCreated` to be a primitive type in the JSON string but got `%s`", jsonObj.get("requestIdCreated").toString()));
      }
      if ((jsonObj.get("userIdModified") != null && !jsonObj.get("userIdModified").isJsonNull()) && !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") != null && !jsonObj.get("requestIdModified").isJsonNull()) && !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()));
      }
  }

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

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

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

       }.nullSafe();
    }
  }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy