software.tnb.jira.validation.generated.model.ProjectDeletedBy 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.net.URI;
import java.util.Arrays;
import software.tnb.jira.validation.generated.model.UserApplicationRoles;
import software.tnb.jira.validation.generated.model.UserAvatarUrls;
import software.tnb.jira.validation.generated.model.UserGroups;
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 user who marked the project as deleted.
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-11-09T10:37:50.591249290Z[Etc/UTC]")
public class ProjectDeletedBy {
public static final String SERIALIZED_NAME_SELF = "self";
@SerializedName(SERIALIZED_NAME_SELF)
private URI self;
public static final String SERIALIZED_NAME_KEY = "key";
@SerializedName(SERIALIZED_NAME_KEY)
private String key;
public static final String SERIALIZED_NAME_ACCOUNT_ID = "accountId";
@SerializedName(SERIALIZED_NAME_ACCOUNT_ID)
private String accountId;
/**
* The user account type. Can take the following values: * `atlassian` regular Atlassian user account * `app` system account used for Connect applications and OAuth to represent external systems * `customer` Jira Service Desk account representing an external service desk
*/
@JsonAdapter(AccountTypeEnum.Adapter.class)
public enum AccountTypeEnum {
ATLASSIAN("atlassian"),
APP("app"),
CUSTOMER("customer"),
UNKNOWN("unknown");
private String value;
AccountTypeEnum(String value) {
this.value = value;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return String.valueOf(value);
}
public static AccountTypeEnum fromValue(String value) {
for (AccountTypeEnum b : AccountTypeEnum.values()) {
if (b.value.equals(value)) {
return b;
}
}
throw new IllegalArgumentException("Unexpected value '" + value + "'");
}
public static class Adapter extends TypeAdapter {
@Override
public void write(final JsonWriter jsonWriter, final AccountTypeEnum enumeration) throws IOException {
jsonWriter.value(enumeration.getValue());
}
@Override
public AccountTypeEnum read(final JsonReader jsonReader) throws IOException {
String value = jsonReader.nextString();
return AccountTypeEnum.fromValue(value);
}
}
}
public static final String SERIALIZED_NAME_ACCOUNT_TYPE = "accountType";
@SerializedName(SERIALIZED_NAME_ACCOUNT_TYPE)
private AccountTypeEnum accountType;
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_EMAIL_ADDRESS = "emailAddress";
@SerializedName(SERIALIZED_NAME_EMAIL_ADDRESS)
private String emailAddress;
public static final String SERIALIZED_NAME_AVATAR_URLS = "avatarUrls";
@SerializedName(SERIALIZED_NAME_AVATAR_URLS)
private UserAvatarUrls avatarUrls;
public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName";
@SerializedName(SERIALIZED_NAME_DISPLAY_NAME)
private String displayName;
public static final String SERIALIZED_NAME_ACTIVE = "active";
@SerializedName(SERIALIZED_NAME_ACTIVE)
private Boolean active;
public static final String SERIALIZED_NAME_TIME_ZONE = "timeZone";
@SerializedName(SERIALIZED_NAME_TIME_ZONE)
private String timeZone;
public static final String SERIALIZED_NAME_LOCALE = "locale";
@SerializedName(SERIALIZED_NAME_LOCALE)
private String locale;
public static final String SERIALIZED_NAME_GROUPS = "groups";
@SerializedName(SERIALIZED_NAME_GROUPS)
private UserGroups groups;
public static final String SERIALIZED_NAME_APPLICATION_ROLES = "applicationRoles";
@SerializedName(SERIALIZED_NAME_APPLICATION_ROLES)
private UserApplicationRoles applicationRoles;
public static final String SERIALIZED_NAME_EXPAND = "expand";
@SerializedName(SERIALIZED_NAME_EXPAND)
private String expand;
public ProjectDeletedBy() {
}
public ProjectDeletedBy(
URI self,
AccountTypeEnum accountType,
String emailAddress,
String displayName,
Boolean active,
String timeZone,
String locale,
String expand
) {
this();
this.self = self;
this.accountType = accountType;
this.emailAddress = emailAddress;
this.displayName = displayName;
this.active = active;
this.timeZone = timeZone;
this.locale = locale;
this.expand = expand;
}
/**
* The URL of the user.
* @return self
**/
@jakarta.annotation.Nullable
public URI getSelf() {
return self;
}
public ProjectDeletedBy key(String key) {
this.key = key;
return this;
}
/**
* This property is no longer available and will be removed from the documentation soon. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
* @return key
**/
@jakarta.annotation.Nullable
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public ProjectDeletedBy accountId(String accountId) {
this.accountId = accountId;
return this;
}
/**
* The account ID of the user, which uniquely identifies the user across all Atlassian products. For example, *5b10ac8d82e05b22cc7d4ef5*. Required in requests.
* @return accountId
**/
@jakarta.annotation.Nullable
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
/**
* The user account type. Can take the following values: * `atlassian` regular Atlassian user account * `app` system account used for Connect applications and OAuth to represent external systems * `customer` Jira Service Desk account representing an external service desk
* @return accountType
**/
@jakarta.annotation.Nullable
public AccountTypeEnum getAccountType() {
return accountType;
}
public ProjectDeletedBy name(String name) {
this.name = name;
return this;
}
/**
* This property is no longer available and will be removed from the documentation soon. See the [deprecation notice](https://developer.atlassian.com/cloud/jira/platform/deprecation-notice-user-privacy-api-migration-guide/) for details.
* @return name
**/
@jakarta.annotation.Nullable
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
/**
* The email address of the user. Depending on the user’s privacy setting, this may be returned as null.
* @return emailAddress
**/
@jakarta.annotation.Nullable
public String getEmailAddress() {
return emailAddress;
}
public ProjectDeletedBy avatarUrls(UserAvatarUrls avatarUrls) {
this.avatarUrls = avatarUrls;
return this;
}
/**
* Get avatarUrls
* @return avatarUrls
**/
@jakarta.annotation.Nullable
public UserAvatarUrls getAvatarUrls() {
return avatarUrls;
}
public void setAvatarUrls(UserAvatarUrls avatarUrls) {
this.avatarUrls = avatarUrls;
}
/**
* The display name of the user. Depending on the user’s privacy setting, this may return an alternative value.
* @return displayName
**/
@jakarta.annotation.Nullable
public String getDisplayName() {
return displayName;
}
/**
* Whether the user is active.
* @return active
**/
@jakarta.annotation.Nullable
public Boolean getActive() {
return active;
}
/**
* The time zone specified in the user's profile. Depending on the user’s privacy setting, this may be returned as null.
* @return timeZone
**/
@jakarta.annotation.Nullable
public String getTimeZone() {
return timeZone;
}
/**
* The locale of the user. Depending on the user’s privacy setting, this may be returned as null.
* @return locale
**/
@jakarta.annotation.Nullable
public String getLocale() {
return locale;
}
public ProjectDeletedBy groups(UserGroups groups) {
this.groups = groups;
return this;
}
/**
* Get groups
* @return groups
**/
@jakarta.annotation.Nullable
public UserGroups getGroups() {
return groups;
}
public void setGroups(UserGroups groups) {
this.groups = groups;
}
public ProjectDeletedBy applicationRoles(UserApplicationRoles applicationRoles) {
this.applicationRoles = applicationRoles;
return this;
}
/**
* Get applicationRoles
* @return applicationRoles
**/
@jakarta.annotation.Nullable
public UserApplicationRoles getApplicationRoles() {
return applicationRoles;
}
public void setApplicationRoles(UserApplicationRoles applicationRoles) {
this.applicationRoles = applicationRoles;
}
/**
* Expand options that include additional user details in the response.
* @return expand
**/
@jakarta.annotation.Nullable
public String getExpand() {
return expand;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
ProjectDeletedBy projectDeletedBy = (ProjectDeletedBy) o;
return Objects.equals(this.self, projectDeletedBy.self) &&
Objects.equals(this.key, projectDeletedBy.key) &&
Objects.equals(this.accountId, projectDeletedBy.accountId) &&
Objects.equals(this.accountType, projectDeletedBy.accountType) &&
Objects.equals(this.name, projectDeletedBy.name) &&
Objects.equals(this.emailAddress, projectDeletedBy.emailAddress) &&
Objects.equals(this.avatarUrls, projectDeletedBy.avatarUrls) &&
Objects.equals(this.displayName, projectDeletedBy.displayName) &&
Objects.equals(this.active, projectDeletedBy.active) &&
Objects.equals(this.timeZone, projectDeletedBy.timeZone) &&
Objects.equals(this.locale, projectDeletedBy.locale) &&
Objects.equals(this.groups, projectDeletedBy.groups) &&
Objects.equals(this.applicationRoles, projectDeletedBy.applicationRoles) &&
Objects.equals(this.expand, projectDeletedBy.expand);
}
@Override
public int hashCode() {
return Objects.hash(self, key, accountId, accountType, name, emailAddress, avatarUrls, displayName, active, timeZone, locale, groups, applicationRoles, expand);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class ProjectDeletedBy {\n");
sb.append(" self: ").append(toIndentedString(self)).append("\n");
sb.append(" key: ").append(toIndentedString(key)).append("\n");
sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n");
sb.append(" accountType: ").append(toIndentedString(accountType)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" emailAddress: ").append(toIndentedString(emailAddress)).append("\n");
sb.append(" avatarUrls: ").append(toIndentedString(avatarUrls)).append("\n");
sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n");
sb.append(" active: ").append(toIndentedString(active)).append("\n");
sb.append(" timeZone: ").append(toIndentedString(timeZone)).append("\n");
sb.append(" locale: ").append(toIndentedString(locale)).append("\n");
sb.append(" groups: ").append(toIndentedString(groups)).append("\n");
sb.append(" applicationRoles: ").append(toIndentedString(applicationRoles)).append("\n");
sb.append(" expand: ").append(toIndentedString(expand)).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("self");
openapiFields.add("key");
openapiFields.add("accountId");
openapiFields.add("accountType");
openapiFields.add("name");
openapiFields.add("emailAddress");
openapiFields.add("avatarUrls");
openapiFields.add("displayName");
openapiFields.add("active");
openapiFields.add("timeZone");
openapiFields.add("locale");
openapiFields.add("groups");
openapiFields.add("applicationRoles");
openapiFields.add("expand");
// 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 ProjectDeletedBy
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!ProjectDeletedBy.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in ProjectDeletedBy is not found in the empty JSON string", ProjectDeletedBy.openapiRequiredFields.toString()));
}
}
Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!ProjectDeletedBy.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `ProjectDeletedBy` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
if ((jsonObj.get("self") != null && !jsonObj.get("self").isJsonNull()) && !jsonObj.get("self").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `self` to be a primitive type in the JSON string but got `%s`", jsonObj.get("self").toString()));
}
if ((jsonObj.get("key") != null && !jsonObj.get("key").isJsonNull()) && !jsonObj.get("key").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `key` to be a primitive type in the JSON string but got `%s`", jsonObj.get("key").toString()));
}
if ((jsonObj.get("accountId") != null && !jsonObj.get("accountId").isJsonNull()) && !jsonObj.get("accountId").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `accountId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountId").toString()));
}
if ((jsonObj.get("accountType") != null && !jsonObj.get("accountType").isJsonNull()) && !jsonObj.get("accountType").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `accountType` to be a primitive type in the JSON string but got `%s`", jsonObj.get("accountType").toString()));
}
if ((jsonObj.get("name") != null && !jsonObj.get("name").isJsonNull()) && !jsonObj.get("name").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `name` to be a primitive type in the JSON string but got `%s`", jsonObj.get("name").toString()));
}
if ((jsonObj.get("emailAddress") != null && !jsonObj.get("emailAddress").isJsonNull()) && !jsonObj.get("emailAddress").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `emailAddress` to be a primitive type in the JSON string but got `%s`", jsonObj.get("emailAddress").toString()));
}
// validate the optional field `avatarUrls`
if (jsonObj.get("avatarUrls") != null && !jsonObj.get("avatarUrls").isJsonNull()) {
UserAvatarUrls.validateJsonElement(jsonObj.get("avatarUrls"));
}
if ((jsonObj.get("displayName") != null && !jsonObj.get("displayName").isJsonNull()) && !jsonObj.get("displayName").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `displayName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("displayName").toString()));
}
if ((jsonObj.get("timeZone") != null && !jsonObj.get("timeZone").isJsonNull()) && !jsonObj.get("timeZone").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `timeZone` to be a primitive type in the JSON string but got `%s`", jsonObj.get("timeZone").toString()));
}
if ((jsonObj.get("locale") != null && !jsonObj.get("locale").isJsonNull()) && !jsonObj.get("locale").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `locale` to be a primitive type in the JSON string but got `%s`", jsonObj.get("locale").toString()));
}
// validate the optional field `groups`
if (jsonObj.get("groups") != null && !jsonObj.get("groups").isJsonNull()) {
UserGroups.validateJsonElement(jsonObj.get("groups"));
}
// validate the optional field `applicationRoles`
if (jsonObj.get("applicationRoles") != null && !jsonObj.get("applicationRoles").isJsonNull()) {
UserApplicationRoles.validateJsonElement(jsonObj.get("applicationRoles"));
}
if ((jsonObj.get("expand") != null && !jsonObj.get("expand").isJsonNull()) && !jsonObj.get("expand").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `expand` to be a primitive type in the JSON string but got `%s`", jsonObj.get("expand").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!ProjectDeletedBy.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'ProjectDeletedBy' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(ProjectDeletedBy.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, ProjectDeletedBy value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public ProjectDeletedBy read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of ProjectDeletedBy given an JSON string
*
* @param jsonString JSON string
* @return An instance of ProjectDeletedBy
* @throws IOException if the JSON string is invalid with respect to ProjectDeletedBy
*/
public static ProjectDeletedBy fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, ProjectDeletedBy.class);
}
/**
* Convert an instance of ProjectDeletedBy to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}