software.tnb.jira.validation.generated.model.UserPickerUser 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 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;
/**
* A user found in a search.
*/
@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2023-11-09T10:37:50.591249290Z[Etc/UTC]")
public class UserPickerUser {
public static final String SERIALIZED_NAME_ACCOUNT_ID = "accountId";
@SerializedName(SERIALIZED_NAME_ACCOUNT_ID)
private String accountId;
public static final String SERIALIZED_NAME_NAME = "name";
@SerializedName(SERIALIZED_NAME_NAME)
private String name;
public static final String SERIALIZED_NAME_KEY = "key";
@SerializedName(SERIALIZED_NAME_KEY)
private String key;
public static final String SERIALIZED_NAME_HTML = "html";
@SerializedName(SERIALIZED_NAME_HTML)
private String html;
public static final String SERIALIZED_NAME_DISPLAY_NAME = "displayName";
@SerializedName(SERIALIZED_NAME_DISPLAY_NAME)
private String displayName;
public static final String SERIALIZED_NAME_AVATAR_URL = "avatarUrl";
@SerializedName(SERIALIZED_NAME_AVATAR_URL)
private URI avatarUrl;
public UserPickerUser() {
}
public UserPickerUser 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*.
* @return accountId
**/
@jakarta.annotation.Nullable
public String getAccountId() {
return accountId;
}
public void setAccountId(String accountId) {
this.accountId = accountId;
}
public UserPickerUser name(String name) {
this.name = name;
return this;
}
/**
* This property is no longer available . 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;
}
public UserPickerUser key(String key) {
this.key = key;
return this;
}
/**
* This property is no longer available. 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 UserPickerUser html(String html) {
this.html = html;
return this;
}
/**
* The display name, email address, and key of the user with the matched query string highlighted with the HTML bold tag.
* @return html
**/
@jakarta.annotation.Nullable
public String getHtml() {
return html;
}
public void setHtml(String html) {
this.html = html;
}
public UserPickerUser displayName(String displayName) {
this.displayName = displayName;
return this;
}
/**
* The display name of the user. Depending on the user’s privacy setting, this may be returned as null.
* @return displayName
**/
@jakarta.annotation.Nullable
public String getDisplayName() {
return displayName;
}
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
public UserPickerUser avatarUrl(URI avatarUrl) {
this.avatarUrl = avatarUrl;
return this;
}
/**
* The avatar URL of the user.
* @return avatarUrl
**/
@jakarta.annotation.Nullable
public URI getAvatarUrl() {
return avatarUrl;
}
public void setAvatarUrl(URI avatarUrl) {
this.avatarUrl = avatarUrl;
}
@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}
UserPickerUser userPickerUser = (UserPickerUser) o;
return Objects.equals(this.accountId, userPickerUser.accountId) &&
Objects.equals(this.name, userPickerUser.name) &&
Objects.equals(this.key, userPickerUser.key) &&
Objects.equals(this.html, userPickerUser.html) &&
Objects.equals(this.displayName, userPickerUser.displayName) &&
Objects.equals(this.avatarUrl, userPickerUser.avatarUrl);
}
@Override
public int hashCode() {
return Objects.hash(accountId, name, key, html, displayName, avatarUrl);
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("class UserPickerUser {\n");
sb.append(" accountId: ").append(toIndentedString(accountId)).append("\n");
sb.append(" name: ").append(toIndentedString(name)).append("\n");
sb.append(" key: ").append(toIndentedString(key)).append("\n");
sb.append(" html: ").append(toIndentedString(html)).append("\n");
sb.append(" displayName: ").append(toIndentedString(displayName)).append("\n");
sb.append(" avatarUrl: ").append(toIndentedString(avatarUrl)).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("accountId");
openapiFields.add("name");
openapiFields.add("key");
openapiFields.add("html");
openapiFields.add("displayName");
openapiFields.add("avatarUrl");
// 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 UserPickerUser
*/
public static void validateJsonElement(JsonElement jsonElement) throws IOException {
if (jsonElement == null) {
if (!UserPickerUser.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null
throw new IllegalArgumentException(String.format("The required field(s) %s in UserPickerUser is not found in the empty JSON string", UserPickerUser.openapiRequiredFields.toString()));
}
}
Set> entries = jsonElement.getAsJsonObject().entrySet();
// check to see if the JSON string contains additional fields
for (Entry entry : entries) {
if (!UserPickerUser.openapiFields.contains(entry.getKey())) {
throw new IllegalArgumentException(String.format("The field `%s` in the JSON string is not defined in the `UserPickerUser` properties. JSON: %s", entry.getKey(), jsonElement.toString()));
}
}
JsonObject jsonObj = jsonElement.getAsJsonObject();
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("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("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("html") != null && !jsonObj.get("html").isJsonNull()) && !jsonObj.get("html").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `html` to be a primitive type in the JSON string but got `%s`", jsonObj.get("html").toString()));
}
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("avatarUrl") != null && !jsonObj.get("avatarUrl").isJsonNull()) && !jsonObj.get("avatarUrl").isJsonPrimitive()) {
throw new IllegalArgumentException(String.format("Expected the field `avatarUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("avatarUrl").toString()));
}
}
public static class CustomTypeAdapterFactory implements TypeAdapterFactory {
@SuppressWarnings("unchecked")
@Override
public TypeAdapter create(Gson gson, TypeToken type) {
if (!UserPickerUser.class.isAssignableFrom(type.getRawType())) {
return null; // this class only serializes 'UserPickerUser' and its subtypes
}
final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class);
final TypeAdapter thisAdapter
= gson.getDelegateAdapter(this, TypeToken.get(UserPickerUser.class));
return (TypeAdapter) new TypeAdapter() {
@Override
public void write(JsonWriter out, UserPickerUser value) throws IOException {
JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject();
elementAdapter.write(out, obj);
}
@Override
public UserPickerUser read(JsonReader in) throws IOException {
JsonElement jsonElement = elementAdapter.read(in);
validateJsonElement(jsonElement);
return thisAdapter.fromJsonTree(jsonElement);
}
}.nullSafe();
}
}
/**
* Create an instance of UserPickerUser given an JSON string
*
* @param jsonString JSON string
* @return An instance of UserPickerUser
* @throws IOException if the JSON string is invalid with respect to UserPickerUser
*/
public static UserPickerUser fromJson(String jsonString) throws IOException {
return JSON.getGson().fromJson(jsonString, UserPickerUser.class);
}
/**
* Convert an instance of UserPickerUser to an JSON string
*
* @return JSON string
*/
public String toJson() {
return JSON.getGson().toJson(this);
}
}