org.cloudfoundry.uaa.users.UpdateUserRequest Maven / Gradle / Ivy
package org.cloudfoundry.uaa.users;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.Nullable;
import org.cloudfoundry.uaa.IdentityZoned;
import org.cloudfoundry.uaa.Versioned;
import org.immutables.value.Generated;
/**
* The request payload for the update user operation
*/
@Generated(from = "_UpdateUserRequest", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class UpdateUserRequest extends org.cloudfoundry.uaa.users._UpdateUserRequest {
private final @Nullable String identityZoneId;
private final @Nullable String identityZoneSubdomain;
private final String version;
private final @Nullable Boolean active;
private final List emails;
private final @Nullable String externalId;
private final String id;
private final Name name;
private final @Nullable String origin;
private final List phoneNumbers;
private final String userName;
private final @Nullable Boolean verified;
private UpdateUserRequest(UpdateUserRequest.Builder builder) {
this.identityZoneId = builder.identityZoneId;
this.identityZoneSubdomain = builder.identityZoneSubdomain;
this.version = builder.version;
this.active = builder.active;
this.emails = createUnmodifiableList(true, builder.emails);
this.externalId = builder.externalId;
this.id = builder.id;
this.name = builder.name;
this.origin = builder.origin;
this.phoneNumbers = createUnmodifiableList(true, builder.phoneNumbers);
this.userName = builder.userName;
this.verified = builder.verified;
}
/**
* Returns the identity zone id
* @return the identity zone id
*/
@JsonProperty("identityZoneId")
@JsonIgnore
@Override
public @Nullable String getIdentityZoneId() {
return identityZoneId;
}
/**
* Returns the identity zone subdomain
* @return the identity zone subdomain
*/
@JsonProperty("identityZoneSubdomain")
@JsonIgnore
@Override
public @Nullable String getIdentityZoneSubdomain() {
return identityZoneSubdomain;
}
/**
* The version
*/
@JsonProperty("version")
@JsonIgnore
@Override
public String getVersion() {
return version;
}
/**
* Whether the user is active
*/
@JsonProperty("active")
@Override
public @Nullable Boolean getActive() {
return active;
}
/**
* The emails for the user
*/
@JsonProperty("emails")
@Override
public List getEmails() {
return emails;
}
/**
* The external id
*/
@JsonProperty("externalId")
@Override
public @Nullable String getExternalId() {
return externalId;
}
/**
* The id
*/
@JsonProperty("id")
@JsonIgnore
@Override
public String getId() {
return id;
}
/**
* The user's name
*/
@JsonProperty("name")
@Override
public Name getName() {
return name;
}
/**
* The identity provider that authenticated this user
*/
@JsonProperty("origin")
@Override
public @Nullable String getOrigin() {
return origin;
}
/**
* The phone numbers for the user
*/
@JsonProperty("phoneNumbers")
@Override
public List getPhoneNumbers() {
return phoneNumbers;
}
/**
* The user name
*/
@JsonProperty("userName")
@Override
public String getUserName() {
return userName;
}
/**
* Whether the user's email is verified
*/
@JsonProperty("verified")
@Override
public @Nullable Boolean getVerified() {
return verified;
}
/**
* This instance is equal to all instances of {@code UpdateUserRequest} that have equal attribute values.
* @return {@code true} if {@code this} is equal to {@code another} instance
*/
@Override
public boolean equals(Object another) {
if (this == another) return true;
return another instanceof UpdateUserRequest
&& equalTo(0, (UpdateUserRequest) another);
}
private boolean equalTo(int synthetic, UpdateUserRequest another) {
return Objects.equals(identityZoneId, another.identityZoneId)
&& Objects.equals(identityZoneSubdomain, another.identityZoneSubdomain)
&& version.equals(another.version)
&& Objects.equals(active, another.active)
&& emails.equals(another.emails)
&& Objects.equals(externalId, another.externalId)
&& id.equals(another.id)
&& name.equals(another.name)
&& Objects.equals(origin, another.origin)
&& phoneNumbers.equals(another.phoneNumbers)
&& userName.equals(another.userName)
&& Objects.equals(verified, another.verified);
}
/**
* Computes a hash code from attributes: {@code identityZoneId}, {@code identityZoneSubdomain}, {@code version}, {@code active}, {@code emails}, {@code externalId}, {@code id}, {@code name}, {@code origin}, {@code phoneNumbers}, {@code userName}, {@code verified}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(identityZoneId);
h += (h << 5) + Objects.hashCode(identityZoneSubdomain);
h += (h << 5) + version.hashCode();
h += (h << 5) + Objects.hashCode(active);
h += (h << 5) + emails.hashCode();
h += (h << 5) + Objects.hashCode(externalId);
h += (h << 5) + id.hashCode();
h += (h << 5) + name.hashCode();
h += (h << 5) + Objects.hashCode(origin);
h += (h << 5) + phoneNumbers.hashCode();
h += (h << 5) + userName.hashCode();
h += (h << 5) + Objects.hashCode(verified);
return h;
}
/**
* Prints the immutable value {@code UpdateUserRequest} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "UpdateUserRequest{"
+ "identityZoneId=" + identityZoneId
+ ", identityZoneSubdomain=" + identityZoneSubdomain
+ ", version=" + version
+ ", active=" + active
+ ", emails=" + emails
+ ", externalId=" + externalId
+ ", id=" + id
+ ", name=" + name
+ ", origin=" + origin
+ ", phoneNumbers=" + phoneNumbers
+ ", userName=" + userName
+ ", verified=" + verified
+ "}";
}
/**
* Utility type used to correctly read immutable object from JSON representation.
* @deprecated Do not use this type directly, it exists only for the Jackson-binding infrastructure
*/
@Generated(from = "_UpdateUserRequest", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json extends org.cloudfoundry.uaa.users._UpdateUserRequest {
String identityZoneId;
String identityZoneSubdomain;
String version;
Boolean active;
List emails = Collections.emptyList();
String externalId;
String id;
Name name;
String origin;
List phoneNumbers = Collections.emptyList();
String userName;
Boolean verified;
@JsonProperty("identityZoneId")
@JsonIgnore
public void setIdentityZoneId(@Nullable String identityZoneId) {
this.identityZoneId = identityZoneId;
}
@JsonProperty("identityZoneSubdomain")
@JsonIgnore
public void setIdentityZoneSubdomain(@Nullable String identityZoneSubdomain) {
this.identityZoneSubdomain = identityZoneSubdomain;
}
@JsonProperty("version")
@JsonIgnore
public void setVersion(String version) {
this.version = version;
}
@JsonProperty("active")
public void setActive(@Nullable Boolean active) {
this.active = active;
}
@JsonProperty("emails")
public void setEmails(List emails) {
this.emails = emails;
}
@JsonProperty("externalId")
public void setExternalId(@Nullable String externalId) {
this.externalId = externalId;
}
@JsonProperty("id")
@JsonIgnore
public void setId(String id) {
this.id = id;
}
@JsonProperty("name")
public void setName(Name name) {
this.name = name;
}
@JsonProperty("origin")
public void setOrigin(@Nullable String origin) {
this.origin = origin;
}
@JsonProperty("phoneNumbers")
public void setPhoneNumbers(List phoneNumbers) {
this.phoneNumbers = phoneNumbers;
}
@JsonProperty("userName")
public void setUserName(String userName) {
this.userName = userName;
}
@JsonProperty("verified")
public void setVerified(@Nullable Boolean verified) {
this.verified = verified;
}
@Override
public String getIdentityZoneId() { throw new UnsupportedOperationException(); }
@Override
public String getIdentityZoneSubdomain() { throw new UnsupportedOperationException(); }
@Override
public String getVersion() { throw new UnsupportedOperationException(); }
@Override
public Boolean getActive() { throw new UnsupportedOperationException(); }
@Override
public List getEmails() { throw new UnsupportedOperationException(); }
@Override
public String getExternalId() { throw new UnsupportedOperationException(); }
@Override
public String getId() { throw new UnsupportedOperationException(); }
@Override
public Name getName() { throw new UnsupportedOperationException(); }
@Override
public String getOrigin() { throw new UnsupportedOperationException(); }
@Override
public List getPhoneNumbers() { throw new UnsupportedOperationException(); }
@Override
public String getUserName() { throw new UnsupportedOperationException(); }
@Override
public Boolean getVerified() { throw new UnsupportedOperationException(); }
}
/**
* @param json A JSON-bindable data structure
* @return An immutable value type
* @deprecated Do not use this method directly, it exists only for the Jackson-binding infrastructure
*/
@Deprecated
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
static UpdateUserRequest fromJson(Json json) {
UpdateUserRequest.Builder builder = UpdateUserRequest.builder();
if (json.identityZoneId != null) {
builder.identityZoneId(json.identityZoneId);
}
if (json.identityZoneSubdomain != null) {
builder.identityZoneSubdomain(json.identityZoneSubdomain);
}
if (json.version != null) {
builder.version(json.version);
}
if (json.active != null) {
builder.active(json.active);
}
if (json.emails != null) {
builder.addAllEmails(json.emails);
}
if (json.externalId != null) {
builder.externalId(json.externalId);
}
if (json.id != null) {
builder.id(json.id);
}
if (json.name != null) {
builder.name(json.name);
}
if (json.origin != null) {
builder.origin(json.origin);
}
if (json.phoneNumbers != null) {
builder.addAllPhoneNumbers(json.phoneNumbers);
}
if (json.userName != null) {
builder.userName(json.userName);
}
if (json.verified != null) {
builder.verified(json.verified);
}
return builder.build();
}
private static UpdateUserRequest validate(UpdateUserRequest instance) {
instance.check();
return instance;
}
/**
* Creates a builder for {@link UpdateUserRequest UpdateUserRequest}.
*
* UpdateUserRequest.builder()
* .identityZoneId(String | null) // nullable {@link UpdateUserRequest#getIdentityZoneId() identityZoneId}
* .identityZoneSubdomain(String | null) // nullable {@link UpdateUserRequest#getIdentityZoneSubdomain() identityZoneSubdomain}
* .version(String) // required {@link UpdateUserRequest#getVersion() version}
* .active(Boolean | null) // nullable {@link UpdateUserRequest#getActive() active}
* .email|addAllEmails(Email) // {@link UpdateUserRequest#getEmails() emails} elements
* .externalId(String | null) // nullable {@link UpdateUserRequest#getExternalId() externalId}
* .id(String) // required {@link UpdateUserRequest#getId() id}
* .name(org.cloudfoundry.uaa.users.Name) // required {@link UpdateUserRequest#getName() name}
* .origin(String | null) // nullable {@link UpdateUserRequest#getOrigin() origin}
* .phoneNumber|addAllPhoneNumbers(PhoneNumber) // {@link UpdateUserRequest#getPhoneNumbers() phoneNumbers} elements
* .userName(String) // required {@link UpdateUserRequest#getUserName() userName}
* .verified(Boolean | null) // nullable {@link UpdateUserRequest#getVerified() verified}
* .build();
*
* @return A new UpdateUserRequest builder
*/
public static UpdateUserRequest.Builder builder() {
return new UpdateUserRequest.Builder();
}
/**
* Builds instances of type {@link UpdateUserRequest UpdateUserRequest}.
* Initialize attributes and then invoke the {@link #build()} method to create an
* immutable instance.
* {@code Builder} is not thread-safe and generally should not be stored in a field or collection,
* but instead used immediately to create instances.
*/
@Generated(from = "_UpdateUserRequest", generator = "Immutables")
public static final class Builder {
private static final long INIT_BIT_VERSION = 0x1L;
private static final long INIT_BIT_ID = 0x2L;
private static final long INIT_BIT_NAME = 0x4L;
private static final long INIT_BIT_USER_NAME = 0x8L;
private long initBits = 0xfL;
private String identityZoneId;
private String identityZoneSubdomain;
private String version;
private Boolean active;
private List emails = new ArrayList();
private String externalId;
private String id;
private Name name;
private String origin;
private List phoneNumbers = new ArrayList();
private String userName;
private Boolean verified;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code org.cloudfoundry.uaa.Versioned} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(Versioned instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code UpdateUserRequest} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(UpdateUserRequest instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Copy abstract value type {@code _UpdateUserRequest} instance into builder.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(_UpdateUserRequest instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code org.cloudfoundry.uaa.IdentityZoned} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(IdentityZoned instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
private void from(short _unused, Object object) {
long bits = 0;
if (object instanceof Versioned) {
Versioned instance = (Versioned) object;
if ((bits & 0x1L) == 0) {
String versionValue = instance.getVersion();
if (versionValue != null) {
version(versionValue);
}
bits |= 0x1L;
}
}
if (object instanceof org.cloudfoundry.uaa.users._UpdateUserRequest) {
org.cloudfoundry.uaa.users._UpdateUserRequest instance = (org.cloudfoundry.uaa.users._UpdateUserRequest) object;
addAllEmails(instance.getEmails());
if ((bits & 0x2L) == 0) {
String identityZoneSubdomainValue = instance.getIdentityZoneSubdomain();
if (identityZoneSubdomainValue != null) {
identityZoneSubdomain(identityZoneSubdomainValue);
}
bits |= 0x2L;
}
String originValue = instance.getOrigin();
if (originValue != null) {
origin(originValue);
}
Boolean verifiedValue = instance.getVerified();
if (verifiedValue != null) {
verified(verifiedValue);
}
name(instance.getName());
Boolean activeValue = instance.getActive();
if (activeValue != null) {
active(activeValue);
}
String externalIdValue = instance.getExternalId();
if (externalIdValue != null) {
externalId(externalIdValue);
}
id(instance.getId());
userName(instance.getUserName());
if ((bits & 0x1L) == 0) {
String versionValue = instance.getVersion();
if (versionValue != null) {
version(versionValue);
}
bits |= 0x1L;
}
if ((bits & 0x4L) == 0) {
String identityZoneIdValue = instance.getIdentityZoneId();
if (identityZoneIdValue != null) {
identityZoneId(identityZoneIdValue);
}
bits |= 0x4L;
}
addAllPhoneNumbers(instance.getPhoneNumbers());
}
if (object instanceof IdentityZoned) {
IdentityZoned instance = (IdentityZoned) object;
if ((bits & 0x2L) == 0) {
String identityZoneSubdomainValue = instance.getIdentityZoneSubdomain();
if (identityZoneSubdomainValue != null) {
identityZoneSubdomain(identityZoneSubdomainValue);
}
bits |= 0x2L;
}
if ((bits & 0x4L) == 0) {
String identityZoneIdValue = instance.getIdentityZoneId();
if (identityZoneIdValue != null) {
identityZoneId(identityZoneIdValue);
}
bits |= 0x4L;
}
}
}
/**
* Initializes the value for the {@link UpdateUserRequest#getIdentityZoneId() identityZoneId} attribute.
* @param identityZoneId The value for identityZoneId (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder identityZoneId(@Nullable String identityZoneId) {
this.identityZoneId = identityZoneId;
return this;
}
/**
* Initializes the value for the {@link UpdateUserRequest#getIdentityZoneSubdomain() identityZoneSubdomain} attribute.
* @param identityZoneSubdomain The value for identityZoneSubdomain (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder identityZoneSubdomain(@Nullable String identityZoneSubdomain) {
this.identityZoneSubdomain = identityZoneSubdomain;
return this;
}
/**
* Initializes the value for the {@link UpdateUserRequest#getVersion() version} attribute.
* @param version The value for version
* @return {@code this} builder for use in a chained invocation
*/
public final Builder version(String version) {
this.version = Objects.requireNonNull(version, "version");
initBits &= ~INIT_BIT_VERSION;
return this;
}
/**
* Initializes the value for the {@link UpdateUserRequest#getActive() active} attribute.
* @param active The value for active (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder active(@Nullable Boolean active) {
this.active = active;
return this;
}
/**
* Adds one element to {@link UpdateUserRequest#getEmails() emails} list.
* @param element A emails element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder email(Email element) {
this.emails.add(Objects.requireNonNull(element, "emails element"));
return this;
}
/**
* Adds elements to {@link UpdateUserRequest#getEmails() emails} list.
* @param elements An array of emails elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder emails(Email... elements) {
for (Email element : elements) {
this.emails.add(Objects.requireNonNull(element, "emails element"));
}
return this;
}
/**
* Sets or replaces all elements for {@link UpdateUserRequest#getEmails() emails} list.
* @param elements An iterable of emails elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder emails(Iterable extends Email> elements) {
this.emails.clear();
return addAllEmails(elements);
}
/**
* Adds elements to {@link UpdateUserRequest#getEmails() emails} list.
* @param elements An iterable of emails elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllEmails(Iterable extends Email> elements) {
for (Email element : elements) {
this.emails.add(Objects.requireNonNull(element, "emails element"));
}
return this;
}
/**
* Initializes the value for the {@link UpdateUserRequest#getExternalId() externalId} attribute.
* @param externalId The value for externalId (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder externalId(@Nullable String externalId) {
this.externalId = externalId;
return this;
}
/**
* Initializes the value for the {@link UpdateUserRequest#getId() id} attribute.
* @param id The value for id
* @return {@code this} builder for use in a chained invocation
*/
public final Builder id(String id) {
this.id = Objects.requireNonNull(id, "id");
initBits &= ~INIT_BIT_ID;
return this;
}
/**
* Initializes the value for the {@link UpdateUserRequest#getName() name} attribute.
* @param name The value for name
* @return {@code this} builder for use in a chained invocation
*/
public final Builder name(Name name) {
this.name = Objects.requireNonNull(name, "name");
initBits &= ~INIT_BIT_NAME;
return this;
}
/**
* Initializes the value for the {@link UpdateUserRequest#getOrigin() origin} attribute.
* @param origin The value for origin (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder origin(@Nullable String origin) {
this.origin = origin;
return this;
}
/**
* Adds one element to {@link UpdateUserRequest#getPhoneNumbers() phoneNumbers} list.
* @param element A phoneNumbers element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder phoneNumber(PhoneNumber element) {
this.phoneNumbers.add(Objects.requireNonNull(element, "phoneNumbers element"));
return this;
}
/**
* Adds elements to {@link UpdateUserRequest#getPhoneNumbers() phoneNumbers} list.
* @param elements An array of phoneNumbers elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder phoneNumbers(PhoneNumber... elements) {
for (PhoneNumber element : elements) {
this.phoneNumbers.add(Objects.requireNonNull(element, "phoneNumbers element"));
}
return this;
}
/**
* Sets or replaces all elements for {@link UpdateUserRequest#getPhoneNumbers() phoneNumbers} list.
* @param elements An iterable of phoneNumbers elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder phoneNumbers(Iterable extends PhoneNumber> elements) {
this.phoneNumbers.clear();
return addAllPhoneNumbers(elements);
}
/**
* Adds elements to {@link UpdateUserRequest#getPhoneNumbers() phoneNumbers} list.
* @param elements An iterable of phoneNumbers elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllPhoneNumbers(Iterable extends PhoneNumber> elements) {
for (PhoneNumber element : elements) {
this.phoneNumbers.add(Objects.requireNonNull(element, "phoneNumbers element"));
}
return this;
}
/**
* Initializes the value for the {@link UpdateUserRequest#getUserName() userName} attribute.
* @param userName The value for userName
* @return {@code this} builder for use in a chained invocation
*/
public final Builder userName(String userName) {
this.userName = Objects.requireNonNull(userName, "userName");
initBits &= ~INIT_BIT_USER_NAME;
return this;
}
/**
* Initializes the value for the {@link UpdateUserRequest#getVerified() verified} attribute.
* @param verified The value for verified (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
public final Builder verified(@Nullable Boolean verified) {
this.verified = verified;
return this;
}
/**
* Builds a new {@link UpdateUserRequest UpdateUserRequest}.
* @return An immutable instance of UpdateUserRequest
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public UpdateUserRequest build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return UpdateUserRequest.validate(new UpdateUserRequest(this));
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_VERSION) != 0) attributes.add("version");
if ((initBits & INIT_BIT_ID) != 0) attributes.add("id");
if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name");
if ((initBits & INIT_BIT_USER_NAME) != 0) attributes.add("userName");
return "Cannot build UpdateUserRequest, some of required attributes are not set " + attributes;
}
}
private static List createSafeList(Iterable extends T> iterable, boolean checkNulls, boolean skipNulls) {
ArrayList list;
if (iterable instanceof Collection>) {
int size = ((Collection>) iterable).size();
if (size == 0) return Collections.emptyList();
list = new ArrayList<>(size);
} else {
list = new ArrayList<>();
}
for (T element : iterable) {
if (skipNulls && element == null) continue;
if (checkNulls) Objects.requireNonNull(element, "element");
list.add(element);
}
return list;
}
private static List createUnmodifiableList(boolean clone, List list) {
switch(list.size()) {
case 0: return Collections.emptyList();
case 1: return Collections.singletonList(list.get(0));
default:
if (clone) {
return Collections.unmodifiableList(new ArrayList<>(list));
} else {
if (list instanceof ArrayList>) {
((ArrayList>) list).trimToSize();
}
return Collections.unmodifiableList(list);
}
}
}
}