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

io.thestencil.iam.api.ImmutableUser Maven / Gradle / Ivy

There is a newer version: 1.148.40
Show newest version
package io.thestencil.iam.api;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.Var;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import javax.annotation.CheckReturnValue;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
import org.immutables.value.Generated;

/**
 * Immutable implementation of {@link IAMClient.User}.
 * 

* Use the builder to create immutable instances: * {@code ImmutableUser.builder()}. */ @Generated(from = "IAMClient.User", generator = "Immutables") @SuppressWarnings({"all"}) @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableUser implements IAMClient.User { private final String id; private final String ssn; private final String username; private final String firstName; private final String lastName; private final IAMClient.Contact contact; private final Boolean protectionOrder; private final @Nullable IAMClient.RepresentedPerson representedPerson; private final @Nullable IAMClient.RepresentedCompany representedCompany; private ImmutableUser( String id, String ssn, String username, String firstName, String lastName, IAMClient.Contact contact, Boolean protectionOrder, @Nullable IAMClient.RepresentedPerson representedPerson, @Nullable IAMClient.RepresentedCompany representedCompany) { this.id = id; this.ssn = ssn; this.username = username; this.firstName = firstName; this.lastName = lastName; this.contact = contact; this.protectionOrder = protectionOrder; this.representedPerson = representedPerson; this.representedCompany = representedCompany; } /** * @return The value of the {@code id} attribute */ @JsonProperty("id") @Override public String getId() { return id; } /** * @return The value of the {@code ssn} attribute */ @JsonProperty("ssn") @Override public String getSsn() { return ssn; } /** * @return The value of the {@code username} attribute */ @JsonProperty("username") @Override public String getUsername() { return username; } /** * @return The value of the {@code firstName} attribute */ @JsonProperty("firstName") @Override public String getFirstName() { return firstName; } /** * @return The value of the {@code lastName} attribute */ @JsonProperty("lastName") @Override public String getLastName() { return lastName; } /** * @return The value of the {@code contact} attribute */ @JsonProperty("contact") @Override public IAMClient.Contact getContact() { return contact; } /** * @return The value of the {@code protectionOrder} attribute */ @JsonProperty("protectionOrder") @Override public Boolean getProtectionOrder() { return protectionOrder; } /** * @return The value of the {@code representedPerson} attribute */ @JsonProperty("representedPerson") @Override public @Nullable IAMClient.RepresentedPerson getRepresentedPerson() { return representedPerson; } /** * @return The value of the {@code representedCompany} attribute */ @JsonProperty("representedCompany") @Override public @Nullable IAMClient.RepresentedCompany getRepresentedCompany() { return representedCompany; } /** * Copy the current immutable object by setting a value for the {@link IAMClient.User#getId() id} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for id * @return A modified copy of the {@code this} object */ public final ImmutableUser withId(String value) { String newValue = Objects.requireNonNull(value, "id"); if (this.id.equals(newValue)) return this; return new ImmutableUser( newValue, this.ssn, this.username, this.firstName, this.lastName, this.contact, this.protectionOrder, this.representedPerson, this.representedCompany); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.User#getSsn() ssn} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for ssn * @return A modified copy of the {@code this} object */ public final ImmutableUser withSsn(String value) { String newValue = Objects.requireNonNull(value, "ssn"); if (this.ssn.equals(newValue)) return this; return new ImmutableUser( this.id, newValue, this.username, this.firstName, this.lastName, this.contact, this.protectionOrder, this.representedPerson, this.representedCompany); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.User#getUsername() username} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for username * @return A modified copy of the {@code this} object */ public final ImmutableUser withUsername(String value) { String newValue = Objects.requireNonNull(value, "username"); if (this.username.equals(newValue)) return this; return new ImmutableUser( this.id, this.ssn, newValue, this.firstName, this.lastName, this.contact, this.protectionOrder, this.representedPerson, this.representedCompany); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.User#getFirstName() firstName} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for firstName * @return A modified copy of the {@code this} object */ public final ImmutableUser withFirstName(String value) { String newValue = Objects.requireNonNull(value, "firstName"); if (this.firstName.equals(newValue)) return this; return new ImmutableUser( this.id, this.ssn, this.username, newValue, this.lastName, this.contact, this.protectionOrder, this.representedPerson, this.representedCompany); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.User#getLastName() lastName} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for lastName * @return A modified copy of the {@code this} object */ public final ImmutableUser withLastName(String value) { String newValue = Objects.requireNonNull(value, "lastName"); if (this.lastName.equals(newValue)) return this; return new ImmutableUser( this.id, this.ssn, this.username, this.firstName, newValue, this.contact, this.protectionOrder, this.representedPerson, this.representedCompany); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.User#getContact() contact} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for contact * @return A modified copy of the {@code this} object */ public final ImmutableUser withContact(IAMClient.Contact value) { if (this.contact == value) return this; IAMClient.Contact newValue = Objects.requireNonNull(value, "contact"); return new ImmutableUser( this.id, this.ssn, this.username, this.firstName, this.lastName, newValue, this.protectionOrder, this.representedPerson, this.representedCompany); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.User#getProtectionOrder() protectionOrder} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for protectionOrder * @return A modified copy of the {@code this} object */ public final ImmutableUser withProtectionOrder(Boolean value) { Boolean newValue = Objects.requireNonNull(value, "protectionOrder"); if (this.protectionOrder.equals(newValue)) return this; return new ImmutableUser( this.id, this.ssn, this.username, this.firstName, this.lastName, this.contact, newValue, this.representedPerson, this.representedCompany); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.User#getRepresentedPerson() representedPerson} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for representedPerson (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableUser withRepresentedPerson(@Nullable IAMClient.RepresentedPerson value) { if (this.representedPerson == value) return this; return new ImmutableUser( this.id, this.ssn, this.username, this.firstName, this.lastName, this.contact, this.protectionOrder, value, this.representedCompany); } /** * Copy the current immutable object by setting a value for the {@link IAMClient.User#getRepresentedCompany() representedCompany} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for representedCompany (can be {@code null}) * @return A modified copy of the {@code this} object */ public final ImmutableUser withRepresentedCompany(@Nullable IAMClient.RepresentedCompany value) { if (this.representedCompany == value) return this; return new ImmutableUser( this.id, this.ssn, this.username, this.firstName, this.lastName, this.contact, this.protectionOrder, this.representedPerson, value); } /** * This instance is equal to all instances of {@code ImmutableUser} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(@Nullable Object another) { if (this == another) return true; return another instanceof ImmutableUser && equalTo((ImmutableUser) another); } private boolean equalTo(ImmutableUser another) { return id.equals(another.id) && ssn.equals(another.ssn) && username.equals(another.username) && firstName.equals(another.firstName) && lastName.equals(another.lastName) && contact.equals(another.contact) && protectionOrder.equals(another.protectionOrder) && Objects.equals(representedPerson, another.representedPerson) && Objects.equals(representedCompany, another.representedCompany); } /** * Computes a hash code from attributes: {@code id}, {@code ssn}, {@code username}, {@code firstName}, {@code lastName}, {@code contact}, {@code protectionOrder}, {@code representedPerson}, {@code representedCompany}. * @return hashCode value */ @Override public int hashCode() { @Var int h = 5381; h += (h << 5) + id.hashCode(); h += (h << 5) + ssn.hashCode(); h += (h << 5) + username.hashCode(); h += (h << 5) + firstName.hashCode(); h += (h << 5) + lastName.hashCode(); h += (h << 5) + contact.hashCode(); h += (h << 5) + protectionOrder.hashCode(); h += (h << 5) + Objects.hashCode(representedPerson); h += (h << 5) + Objects.hashCode(representedCompany); return h; } /** * Prints the immutable value {@code User} with attribute values. * @return A string representation of the value */ @Override public String toString() { return MoreObjects.toStringHelper("User") .omitNullValues() .add("id", id) .add("ssn", ssn) .add("username", username) .add("firstName", firstName) .add("lastName", lastName) .add("contact", contact) .add("protectionOrder", protectionOrder) .add("representedPerson", representedPerson) .add("representedCompany", representedCompany) .toString(); } /** * 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 = "IAMClient.User", generator = "Immutables") @Deprecated @SuppressWarnings("Immutable") @JsonDeserialize @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements IAMClient.User { @Nullable String id; @Nullable String ssn; @Nullable String username; @Nullable String firstName; @Nullable String lastName; @Nullable IAMClient.Contact contact; @Nullable Boolean protectionOrder; @Nullable IAMClient.RepresentedPerson representedPerson; @Nullable IAMClient.RepresentedCompany representedCompany; @JsonProperty("id") public void setId(String id) { this.id = id; } @JsonProperty("ssn") public void setSsn(String ssn) { this.ssn = ssn; } @JsonProperty("username") public void setUsername(String username) { this.username = username; } @JsonProperty("firstName") public void setFirstName(String firstName) { this.firstName = firstName; } @JsonProperty("lastName") public void setLastName(String lastName) { this.lastName = lastName; } @JsonProperty("contact") public void setContact(IAMClient.Contact contact) { this.contact = contact; } @JsonProperty("protectionOrder") public void setProtectionOrder(Boolean protectionOrder) { this.protectionOrder = protectionOrder; } @JsonProperty("representedPerson") public void setRepresentedPerson(@Nullable IAMClient.RepresentedPerson representedPerson) { this.representedPerson = representedPerson; } @JsonProperty("representedCompany") public void setRepresentedCompany(@Nullable IAMClient.RepresentedCompany representedCompany) { this.representedCompany = representedCompany; } @Override public String getId() { throw new UnsupportedOperationException(); } @Override public String getSsn() { throw new UnsupportedOperationException(); } @Override public String getUsername() { throw new UnsupportedOperationException(); } @Override public String getFirstName() { throw new UnsupportedOperationException(); } @Override public String getLastName() { throw new UnsupportedOperationException(); } @Override public IAMClient.Contact getContact() { throw new UnsupportedOperationException(); } @Override public Boolean getProtectionOrder() { throw new UnsupportedOperationException(); } @Override public IAMClient.RepresentedPerson getRepresentedPerson() { throw new UnsupportedOperationException(); } @Override public IAMClient.RepresentedCompany getRepresentedCompany() { 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 ImmutableUser fromJson(Json json) { ImmutableUser.Builder builder = ImmutableUser.builder(); if (json.id != null) { builder.id(json.id); } if (json.ssn != null) { builder.ssn(json.ssn); } if (json.username != null) { builder.username(json.username); } if (json.firstName != null) { builder.firstName(json.firstName); } if (json.lastName != null) { builder.lastName(json.lastName); } if (json.contact != null) { builder.contact(json.contact); } if (json.protectionOrder != null) { builder.protectionOrder(json.protectionOrder); } if (json.representedPerson != null) { builder.representedPerson(json.representedPerson); } if (json.representedCompany != null) { builder.representedCompany(json.representedCompany); } return builder.build(); } /** * Creates an immutable copy of a {@link IAMClient.User} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable User instance */ public static ImmutableUser copyOf(IAMClient.User instance) { if (instance instanceof ImmutableUser) { return (ImmutableUser) instance; } return ImmutableUser.builder() .from(instance) .build(); } /** * Creates a builder for {@link ImmutableUser ImmutableUser}. *

   * ImmutableUser.builder()
   *    .id(String) // required {@link IAMClient.User#getId() id}
   *    .ssn(String) // required {@link IAMClient.User#getSsn() ssn}
   *    .username(String) // required {@link IAMClient.User#getUsername() username}
   *    .firstName(String) // required {@link IAMClient.User#getFirstName() firstName}
   *    .lastName(String) // required {@link IAMClient.User#getLastName() lastName}
   *    .contact(io.thestencil.iam.api.IAMClient.Contact) // required {@link IAMClient.User#getContact() contact}
   *    .protectionOrder(Boolean) // required {@link IAMClient.User#getProtectionOrder() protectionOrder}
   *    .representedPerson(io.thestencil.iam.api.IAMClient.RepresentedPerson | null) // nullable {@link IAMClient.User#getRepresentedPerson() representedPerson}
   *    .representedCompany(io.thestencil.iam.api.IAMClient.RepresentedCompany | null) // nullable {@link IAMClient.User#getRepresentedCompany() representedCompany}
   *    .build();
   * 
* @return A new ImmutableUser builder */ public static ImmutableUser.Builder builder() { return new ImmutableUser.Builder(); } /** * Builds instances of type {@link ImmutableUser ImmutableUser}. * 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 = "IAMClient.User", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_ID = 0x1L; private static final long INIT_BIT_SSN = 0x2L; private static final long INIT_BIT_USERNAME = 0x4L; private static final long INIT_BIT_FIRST_NAME = 0x8L; private static final long INIT_BIT_LAST_NAME = 0x10L; private static final long INIT_BIT_CONTACT = 0x20L; private static final long INIT_BIT_PROTECTION_ORDER = 0x40L; private long initBits = 0x7fL; private @Nullable String id; private @Nullable String ssn; private @Nullable String username; private @Nullable String firstName; private @Nullable String lastName; private @Nullable IAMClient.Contact contact; private @Nullable Boolean protectionOrder; private @Nullable IAMClient.RepresentedPerson representedPerson; private @Nullable IAMClient.RepresentedCompany representedCompany; private Builder() { } /** * Fill a builder with attribute values from the provided {@code User} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue public final Builder from(IAMClient.User instance) { Objects.requireNonNull(instance, "instance"); id(instance.getId()); ssn(instance.getSsn()); username(instance.getUsername()); firstName(instance.getFirstName()); lastName(instance.getLastName()); contact(instance.getContact()); protectionOrder(instance.getProtectionOrder()); @Nullable IAMClient.RepresentedPerson representedPersonValue = instance.getRepresentedPerson(); if (representedPersonValue != null) { representedPerson(representedPersonValue); } @Nullable IAMClient.RepresentedCompany representedCompanyValue = instance.getRepresentedCompany(); if (representedCompanyValue != null) { representedCompany(representedCompanyValue); } return this; } /** * Initializes the value for the {@link IAMClient.User#getId() id} attribute. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("id") public final Builder id(String id) { this.id = Objects.requireNonNull(id, "id"); initBits &= ~INIT_BIT_ID; return this; } /** * Initializes the value for the {@link IAMClient.User#getSsn() ssn} attribute. * @param ssn The value for ssn * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("ssn") public final Builder ssn(String ssn) { this.ssn = Objects.requireNonNull(ssn, "ssn"); initBits &= ~INIT_BIT_SSN; return this; } /** * Initializes the value for the {@link IAMClient.User#getUsername() username} attribute. * @param username The value for username * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("username") public final Builder username(String username) { this.username = Objects.requireNonNull(username, "username"); initBits &= ~INIT_BIT_USERNAME; return this; } /** * Initializes the value for the {@link IAMClient.User#getFirstName() firstName} attribute. * @param firstName The value for firstName * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("firstName") public final Builder firstName(String firstName) { this.firstName = Objects.requireNonNull(firstName, "firstName"); initBits &= ~INIT_BIT_FIRST_NAME; return this; } /** * Initializes the value for the {@link IAMClient.User#getLastName() lastName} attribute. * @param lastName The value for lastName * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("lastName") public final Builder lastName(String lastName) { this.lastName = Objects.requireNonNull(lastName, "lastName"); initBits &= ~INIT_BIT_LAST_NAME; return this; } /** * Initializes the value for the {@link IAMClient.User#getContact() contact} attribute. * @param contact The value for contact * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("contact") public final Builder contact(IAMClient.Contact contact) { this.contact = Objects.requireNonNull(contact, "contact"); initBits &= ~INIT_BIT_CONTACT; return this; } /** * Initializes the value for the {@link IAMClient.User#getProtectionOrder() protectionOrder} attribute. * @param protectionOrder The value for protectionOrder * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("protectionOrder") public final Builder protectionOrder(Boolean protectionOrder) { this.protectionOrder = Objects.requireNonNull(protectionOrder, "protectionOrder"); initBits &= ~INIT_BIT_PROTECTION_ORDER; return this; } /** * Initializes the value for the {@link IAMClient.User#getRepresentedPerson() representedPerson} attribute. * @param representedPerson The value for representedPerson (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("representedPerson") public final Builder representedPerson(@Nullable IAMClient.RepresentedPerson representedPerson) { this.representedPerson = representedPerson; return this; } /** * Initializes the value for the {@link IAMClient.User#getRepresentedCompany() representedCompany} attribute. * @param representedCompany The value for representedCompany (can be {@code null}) * @return {@code this} builder for use in a chained invocation */ @CanIgnoreReturnValue @JsonProperty("representedCompany") public final Builder representedCompany(@Nullable IAMClient.RepresentedCompany representedCompany) { this.representedCompany = representedCompany; return this; } /** * Builds a new {@link ImmutableUser ImmutableUser}. * @return An immutable instance of User * @throws java.lang.IllegalStateException if any required attributes are missing */ public ImmutableUser build() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableUser( id, ssn, username, firstName, lastName, contact, protectionOrder, representedPerson, representedCompany); } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if ((initBits & INIT_BIT_ID) != 0) attributes.add("id"); if ((initBits & INIT_BIT_SSN) != 0) attributes.add("ssn"); if ((initBits & INIT_BIT_USERNAME) != 0) attributes.add("username"); if ((initBits & INIT_BIT_FIRST_NAME) != 0) attributes.add("firstName"); if ((initBits & INIT_BIT_LAST_NAME) != 0) attributes.add("lastName"); if ((initBits & INIT_BIT_CONTACT) != 0) attributes.add("contact"); if ((initBits & INIT_BIT_PROTECTION_ORDER) != 0) attributes.add("protectionOrder"); return "Cannot build User, some of required attributes are not set " + attributes; } } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy