org.cloudfoundry.uaa.groups.MemberSummary Maven / Gradle / Ivy
package org.cloudfoundry.uaa.groups;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.immutables.value.Generated;
/**
* The payload for members in response
*/
@Generated(from = "_MemberSummary", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class MemberSummary extends org.cloudfoundry.uaa.groups._MemberSummary {
private final String memberId;
private final String origin;
private final MemberType type;
private MemberSummary(MemberSummary.Builder builder) {
this.memberId = builder.memberId;
this.origin = builder.origin;
this.type = builder.type;
}
/**
* Globally unique identifier of the member, either a user ID or another group ID
*/
@JsonProperty("value")
@Override
public String getMemberId() {
return memberId;
}
/**
* The alias of the identity provider that authenticated this user. "uaa" is an internal UAA user.
*/
@JsonProperty("origin")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
@Override
public Optional getOrigin() {
return Optional.ofNullable(origin);
}
/**
* The member type
*/
@JsonProperty("type")
@Override
public Optional getType() {
return Optional.ofNullable(type);
}
/**
* This instance is equal to all instances of {@code MemberSummary} 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 MemberSummary
&& equalTo(0, (MemberSummary) another);
}
private boolean equalTo(int synthetic, MemberSummary another) {
return memberId.equals(another.memberId)
&& Objects.equals(origin, another.origin)
&& Objects.equals(type, another.type);
}
/**
* Computes a hash code from attributes: {@code memberId}, {@code origin}, {@code type}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + memberId.hashCode();
h += (h << 5) + Objects.hashCode(origin);
h += (h << 5) + Objects.hashCode(type);
return h;
}
/**
* Prints the immutable value {@code MemberSummary} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("MemberSummary{");
builder.append("memberId=").append(memberId);
if (origin != null) {
builder.append(", ");
builder.append("origin=").append(origin);
}
if (type != null) {
builder.append(", ");
builder.append("type=").append(type);
}
return builder.append("}").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 = "_MemberSummary", generator = "Immutables")
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json extends org.cloudfoundry.uaa.groups._MemberSummary {
String memberId;
Optional origin = Optional.empty();
Optional type = Optional.empty();
@JsonProperty("value")
public void setMemberId(String memberId) {
this.memberId = memberId;
}
@JsonProperty("origin")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public void setOrigin(Optional origin) {
this.origin = origin;
}
@JsonProperty("type")
public void setType(Optional type) {
this.type = type;
}
@Override
public String getMemberId() { throw new UnsupportedOperationException(); }
@Override
public Optional getOrigin() { throw new UnsupportedOperationException(); }
@Override
public Optional getType() { 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 MemberSummary fromJson(Json json) {
MemberSummary.Builder builder = MemberSummary.builder();
if (json.memberId != null) {
builder.memberId(json.memberId);
}
if (json.origin != null) {
builder.origin(json.origin);
}
if (json.type != null) {
builder.type(json.type);
}
return builder.build();
}
/**
* Creates a builder for {@link MemberSummary MemberSummary}.
*
* MemberSummary.builder()
* .memberId(String) // required {@link MemberSummary#getMemberId() memberId}
* .origin(String) // optional {@link MemberSummary#getOrigin() origin}
* .type(org.cloudfoundry.uaa.groups.MemberType) // optional {@link MemberSummary#getType() type}
* .build();
*
* @return A new MemberSummary builder
*/
public static MemberSummary.Builder builder() {
return new MemberSummary.Builder();
}
/**
* Builds instances of type {@link MemberSummary MemberSummary}.
* 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 = "_MemberSummary", generator = "Immutables")
public static final class Builder {
private static final long INIT_BIT_MEMBER_ID = 0x1L;
private long initBits = 0x1L;
private String memberId;
private String origin;
private MemberType type;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code org.cloudfoundry.uaa.groups.AbstractMember} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(AbstractMember instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code MemberSummary} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(MemberSummary instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Copy abstract value type {@code _MemberSummary} 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(_MemberSummary instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
private void from(short _unused, Object object) {
if (object instanceof AbstractMember) {
AbstractMember instance = (AbstractMember) object;
Optional typeOptional = instance.getType();
if (typeOptional.isPresent()) {
type(typeOptional);
}
Optional originOptional = instance.getOrigin();
if (originOptional.isPresent()) {
origin(originOptional);
}
memberId(instance.getMemberId());
}
}
/**
* Initializes the value for the {@link MemberSummary#getMemberId() memberId} attribute.
* @param memberId The value for memberId
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("value")
public final Builder memberId(String memberId) {
this.memberId = Objects.requireNonNull(memberId, "memberId");
initBits &= ~INIT_BIT_MEMBER_ID;
return this;
}
/**
* Initializes the optional value {@link MemberSummary#getOrigin() origin} to origin.
* @param origin The value for origin
* @return {@code this} builder for chained invocation
*/
public final Builder origin(String origin) {
this.origin = Objects.requireNonNull(origin, "origin");
return this;
}
/**
* Initializes the optional value {@link MemberSummary#getOrigin() origin} to origin.
* @param origin The value for origin
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("origin")
@JsonInclude(JsonInclude.Include.NON_EMPTY)
public final Builder origin(Optional origin) {
this.origin = origin.orElse(null);
return this;
}
/**
* Initializes the optional value {@link MemberSummary#getType() type} to type.
* @param type The value for type
* @return {@code this} builder for chained invocation
*/
public final Builder type(MemberType type) {
this.type = Objects.requireNonNull(type, "type");
return this;
}
/**
* Initializes the optional value {@link MemberSummary#getType() type} to type.
* @param type The value for type
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("type")
public final Builder type(Optional extends MemberType> type) {
this.type = type.orElse(null);
return this;
}
/**
* Builds a new {@link MemberSummary MemberSummary}.
* @return An immutable instance of MemberSummary
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public MemberSummary build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new MemberSummary(this);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_MEMBER_ID) != 0) attributes.add("memberId");
return "Cannot build MemberSummary, some of required attributes are not set " + attributes;
}
}
}