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

software.tnb.jira.validation.generated.model.ChangelogHistoryMetadata Maven / Gradle / Ivy

The newest version!
/*
 * The Jira Cloud platform REST API
 * Jira Cloud platform REST API documentation
 *
 * The version of the OpenAPI document: 1001.0.0-SNAPSHOT
 * 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 software.tnb.jira.validation.generated.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.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import software.tnb.jira.validation.generated.model.HistoryMetadataParticipant;

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 software.tnb.jira.validation.generated.JSON;

/**
 * The history metadata associated with the changed.
 */
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-11-09T10:37:50.591249290Z[Etc/UTC]")
public class ChangelogHistoryMetadata {
  public static final String SERIALIZED_NAME_TYPE = "type";
  @SerializedName(SERIALIZED_NAME_TYPE)
  private String type;

  public static final String SERIALIZED_NAME_DESCRIPTION = "description";
  @SerializedName(SERIALIZED_NAME_DESCRIPTION)
  private String description;

  public static final String SERIALIZED_NAME_DESCRIPTION_KEY = "descriptionKey";
  @SerializedName(SERIALIZED_NAME_DESCRIPTION_KEY)
  private String descriptionKey;

  public static final String SERIALIZED_NAME_ACTIVITY_DESCRIPTION = "activityDescription";
  @SerializedName(SERIALIZED_NAME_ACTIVITY_DESCRIPTION)
  private String activityDescription;

  public static final String SERIALIZED_NAME_ACTIVITY_DESCRIPTION_KEY = "activityDescriptionKey";
  @SerializedName(SERIALIZED_NAME_ACTIVITY_DESCRIPTION_KEY)
  private String activityDescriptionKey;

  public static final String SERIALIZED_NAME_EMAIL_DESCRIPTION = "emailDescription";
  @SerializedName(SERIALIZED_NAME_EMAIL_DESCRIPTION)
  private String emailDescription;

  public static final String SERIALIZED_NAME_EMAIL_DESCRIPTION_KEY = "emailDescriptionKey";
  @SerializedName(SERIALIZED_NAME_EMAIL_DESCRIPTION_KEY)
  private String emailDescriptionKey;

  public static final String SERIALIZED_NAME_ACTOR = "actor";
  @SerializedName(SERIALIZED_NAME_ACTOR)
  private HistoryMetadataParticipant actor;

  public static final String SERIALIZED_NAME_GENERATOR = "generator";
  @SerializedName(SERIALIZED_NAME_GENERATOR)
  private HistoryMetadataParticipant generator;

  public static final String SERIALIZED_NAME_CAUSE = "cause";
  @SerializedName(SERIALIZED_NAME_CAUSE)
  private HistoryMetadataParticipant cause;

  public static final String SERIALIZED_NAME_EXTRA_DATA = "extraData";
  @SerializedName(SERIALIZED_NAME_EXTRA_DATA)
  private Map extraData = new HashMap<>();

  public ChangelogHistoryMetadata() {
  }

  public ChangelogHistoryMetadata type(String type) {
    
    this.type = type;
    return this;
  }

   /**
   * The type of the history record.
   * @return type
  **/
  @jakarta.annotation.Nullable
  public String getType() {
    return type;
  }


  public void setType(String type) {
    this.type = type;
  }


  public ChangelogHistoryMetadata description(String description) {
    
    this.description = description;
    return this;
  }

   /**
   * The description of the history record.
   * @return description
  **/
  @jakarta.annotation.Nullable
  public String getDescription() {
    return description;
  }


  public void setDescription(String description) {
    this.description = description;
  }


  public ChangelogHistoryMetadata descriptionKey(String descriptionKey) {
    
    this.descriptionKey = descriptionKey;
    return this;
  }

   /**
   * The description key of the history record.
   * @return descriptionKey
  **/
  @jakarta.annotation.Nullable
  public String getDescriptionKey() {
    return descriptionKey;
  }


  public void setDescriptionKey(String descriptionKey) {
    this.descriptionKey = descriptionKey;
  }


  public ChangelogHistoryMetadata activityDescription(String activityDescription) {
    
    this.activityDescription = activityDescription;
    return this;
  }

   /**
   * The activity described in the history record.
   * @return activityDescription
  **/
  @jakarta.annotation.Nullable
  public String getActivityDescription() {
    return activityDescription;
  }


  public void setActivityDescription(String activityDescription) {
    this.activityDescription = activityDescription;
  }


  public ChangelogHistoryMetadata activityDescriptionKey(String activityDescriptionKey) {
    
    this.activityDescriptionKey = activityDescriptionKey;
    return this;
  }

   /**
   * The key of the activity described in the history record.
   * @return activityDescriptionKey
  **/
  @jakarta.annotation.Nullable
  public String getActivityDescriptionKey() {
    return activityDescriptionKey;
  }


  public void setActivityDescriptionKey(String activityDescriptionKey) {
    this.activityDescriptionKey = activityDescriptionKey;
  }


  public ChangelogHistoryMetadata emailDescription(String emailDescription) {
    
    this.emailDescription = emailDescription;
    return this;
  }

   /**
   * The description of the email address associated the history record.
   * @return emailDescription
  **/
  @jakarta.annotation.Nullable
  public String getEmailDescription() {
    return emailDescription;
  }


  public void setEmailDescription(String emailDescription) {
    this.emailDescription = emailDescription;
  }


  public ChangelogHistoryMetadata emailDescriptionKey(String emailDescriptionKey) {
    
    this.emailDescriptionKey = emailDescriptionKey;
    return this;
  }

   /**
   * The description key of the email address associated the history record.
   * @return emailDescriptionKey
  **/
  @jakarta.annotation.Nullable
  public String getEmailDescriptionKey() {
    return emailDescriptionKey;
  }


  public void setEmailDescriptionKey(String emailDescriptionKey) {
    this.emailDescriptionKey = emailDescriptionKey;
  }


  public ChangelogHistoryMetadata actor(HistoryMetadataParticipant actor) {
    
    this.actor = actor;
    return this;
  }

   /**
   * Get actor
   * @return actor
  **/
  @jakarta.annotation.Nullable
  public HistoryMetadataParticipant getActor() {
    return actor;
  }


  public void setActor(HistoryMetadataParticipant actor) {
    this.actor = actor;
  }


  public ChangelogHistoryMetadata generator(HistoryMetadataParticipant generator) {
    
    this.generator = generator;
    return this;
  }

   /**
   * Get generator
   * @return generator
  **/
  @jakarta.annotation.Nullable
  public HistoryMetadataParticipant getGenerator() {
    return generator;
  }


  public void setGenerator(HistoryMetadataParticipant generator) {
    this.generator = generator;
  }


  public ChangelogHistoryMetadata cause(HistoryMetadataParticipant cause) {
    
    this.cause = cause;
    return this;
  }

   /**
   * Get cause
   * @return cause
  **/
  @jakarta.annotation.Nullable
  public HistoryMetadataParticipant getCause() {
    return cause;
  }


  public void setCause(HistoryMetadataParticipant cause) {
    this.cause = cause;
  }


  public ChangelogHistoryMetadata extraData(Map extraData) {
    
    this.extraData = extraData;
    return this;
  }

  public ChangelogHistoryMetadata putExtraDataItem(String key, String extraDataItem) {
    if (this.extraData == null) {
      this.extraData = new HashMap<>();
    }
    this.extraData.put(key, extraDataItem);
    return this;
  }

   /**
   * Additional arbitrary information about the history record.
   * @return extraData
  **/
  @jakarta.annotation.Nullable
  public Map getExtraData() {
    return extraData;
  }


  public void setExtraData(Map extraData) {
    this.extraData = extraData;
  }



  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (o == null || getClass() != o.getClass()) {
      return false;
    }
    ChangelogHistoryMetadata changelogHistoryMetadata = (ChangelogHistoryMetadata) o;
    return Objects.equals(this.type, changelogHistoryMetadata.type) &&
        Objects.equals(this.description, changelogHistoryMetadata.description) &&
        Objects.equals(this.descriptionKey, changelogHistoryMetadata.descriptionKey) &&
        Objects.equals(this.activityDescription, changelogHistoryMetadata.activityDescription) &&
        Objects.equals(this.activityDescriptionKey, changelogHistoryMetadata.activityDescriptionKey) &&
        Objects.equals(this.emailDescription, changelogHistoryMetadata.emailDescription) &&
        Objects.equals(this.emailDescriptionKey, changelogHistoryMetadata.emailDescriptionKey) &&
        Objects.equals(this.actor, changelogHistoryMetadata.actor) &&
        Objects.equals(this.generator, changelogHistoryMetadata.generator) &&
        Objects.equals(this.cause, changelogHistoryMetadata.cause) &&
        Objects.equals(this.extraData, changelogHistoryMetadata.extraData);
  }

  @Override
  public int hashCode() {
    return Objects.hash(type, description, descriptionKey, activityDescription, activityDescriptionKey, emailDescription, emailDescriptionKey, actor, generator, cause, extraData);
  }

  @Override
  public String toString() {
    StringBuilder sb = new StringBuilder();
    sb.append("class ChangelogHistoryMetadata {\n");
    sb.append("    type: ").append(toIndentedString(type)).append("\n");
    sb.append("    description: ").append(toIndentedString(description)).append("\n");
    sb.append("    descriptionKey: ").append(toIndentedString(descriptionKey)).append("\n");
    sb.append("    activityDescription: ").append(toIndentedString(activityDescription)).append("\n");
    sb.append("    activityDescriptionKey: ").append(toIndentedString(activityDescriptionKey)).append("\n");
    sb.append("    emailDescription: ").append(toIndentedString(emailDescription)).append("\n");
    sb.append("    emailDescriptionKey: ").append(toIndentedString(emailDescriptionKey)).append("\n");
    sb.append("    actor: ").append(toIndentedString(actor)).append("\n");
    sb.append("    generator: ").append(toIndentedString(generator)).append("\n");
    sb.append("    cause: ").append(toIndentedString(cause)).append("\n");
    sb.append("    extraData: ").append(toIndentedString(extraData)).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("type");
    openapiFields.add("description");
    openapiFields.add("descriptionKey");
    openapiFields.add("activityDescription");
    openapiFields.add("activityDescriptionKey");
    openapiFields.add("emailDescription");
    openapiFields.add("emailDescriptionKey");
    openapiFields.add("actor");
    openapiFields.add("generator");
    openapiFields.add("cause");
    openapiFields.add("extraData");

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

      Set> entries = jsonElement.getAsJsonObject().entrySet();
      // check to see if the JSON string contains additional fields
      for (Entry entry : entries) {
        if (!ChangelogHistoryMetadata.openapiFields.contains(entry.getKey())) {
          throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ChangelogHistoryMetadata` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
        }
      }
        JsonObject jsonObj = jsonElement.getAsJsonObject();
      if ((jsonObj.get("type") != null && !jsonObj.get("type").isJsonNull()) && !jsonObj.get("type").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString()));
      }
      if ((jsonObj.get("description") != null && !jsonObj.get("description").isJsonNull()) && !jsonObj.get("description").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString()));
      }
      if ((jsonObj.get("descriptionKey") != null && !jsonObj.get("descriptionKey").isJsonNull()) && !jsonObj.get("descriptionKey").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `descriptionKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("descriptionKey").toString()));
      }
      if ((jsonObj.get("activityDescription") != null && !jsonObj.get("activityDescription").isJsonNull()) && !jsonObj.get("activityDescription").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `activityDescription` to be a primitive type in the JSON string but got `%s`", jsonObj.get("activityDescription").toString()));
      }
      if ((jsonObj.get("activityDescriptionKey") != null && !jsonObj.get("activityDescriptionKey").isJsonNull()) && !jsonObj.get("activityDescriptionKey").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `activityDescriptionKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("activityDescriptionKey").toString()));
      }
      if ((jsonObj.get("emailDescription") != null && !jsonObj.get("emailDescription").isJsonNull()) && !jsonObj.get("emailDescription").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `emailDescription` to be a primitive type in the JSON string but got `%s`", jsonObj.get("emailDescription").toString()));
      }
      if ((jsonObj.get("emailDescriptionKey") != null && !jsonObj.get("emailDescriptionKey").isJsonNull()) && !jsonObj.get("emailDescriptionKey").isJsonPrimitive()) {
        throw new IllegalArgumentException(String.format("Expected the field `emailDescriptionKey` to be a primitive type in the JSON string but got `%s`", jsonObj.get("emailDescriptionKey").toString()));
      }
  }

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

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

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

       }.nullSafe();
    }
  }

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

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





© 2015 - 2024 Weber Informatics LLC | Privacy Policy