org.cloudfoundry.uaa.groups.ExternalGroupResource 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.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import org.immutables.value.Generated;
/**
* The resource in the list external group mappings response
*/
@Generated(from = "_ExternalGroupResource", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class ExternalGroupResource extends org.cloudfoundry.uaa.groups._ExternalGroupResource {
private final String displayName;
private final String externalGroup;
private final String groupId;
private final String origin;
private ExternalGroupResource(ExternalGroupResource.Builder builder) {
this.displayName = builder.displayName;
this.externalGroup = builder.externalGroup;
this.groupId = builder.groupId;
this.origin = builder.origin;
}
/**
* The group's displayed name
*/
@JsonProperty("displayName")
@Override
public String getDisplayName() {
return displayName;
}
/**
* The identifier for the group in external identity provider that needs to be mapped to internal UAA groups
*/
@JsonProperty("externalGroup")
@Override
public String getExternalGroup() {
return externalGroup;
}
/**
* The group unique ID
*/
@JsonProperty("groupId")
@Override
public String getGroupId() {
return groupId;
}
/**
* Unique alias of the identity provider
*/
@JsonProperty("origin")
@Override
public String getOrigin() {
return origin;
}
/**
* This instance is equal to all instances of {@code ExternalGroupResource} 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 ExternalGroupResource
&& equalTo(0, (ExternalGroupResource) another);
}
private boolean equalTo(int synthetic, ExternalGroupResource another) {
return displayName.equals(another.displayName)
&& externalGroup.equals(another.externalGroup)
&& groupId.equals(another.groupId)
&& origin.equals(another.origin);
}
/**
* Computes a hash code from attributes: {@code displayName}, {@code externalGroup}, {@code groupId}, {@code origin}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + displayName.hashCode();
h += (h << 5) + externalGroup.hashCode();
h += (h << 5) + groupId.hashCode();
h += (h << 5) + origin.hashCode();
return h;
}
/**
* Prints the immutable value {@code ExternalGroupResource} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "ExternalGroupResource{"
+ "displayName=" + displayName
+ ", externalGroup=" + externalGroup
+ ", groupId=" + groupId
+ ", origin=" + origin
+ "}";
}
/**
* 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 = "_ExternalGroupResource", generator = "Immutables")
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json extends org.cloudfoundry.uaa.groups._ExternalGroupResource {
String displayName;
String externalGroup;
String groupId;
String origin;
@JsonProperty("displayName")
public void setDisplayName(String displayName) {
this.displayName = displayName;
}
@JsonProperty("externalGroup")
public void setExternalGroup(String externalGroup) {
this.externalGroup = externalGroup;
}
@JsonProperty("groupId")
public void setGroupId(String groupId) {
this.groupId = groupId;
}
@JsonProperty("origin")
public void setOrigin(String origin) {
this.origin = origin;
}
@Override
public String getDisplayName() { throw new UnsupportedOperationException(); }
@Override
public String getExternalGroup() { throw new UnsupportedOperationException(); }
@Override
public String getGroupId() { throw new UnsupportedOperationException(); }
@Override
public String getOrigin() { 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 ExternalGroupResource fromJson(Json json) {
ExternalGroupResource.Builder builder = ExternalGroupResource.builder();
if (json.displayName != null) {
builder.displayName(json.displayName);
}
if (json.externalGroup != null) {
builder.externalGroup(json.externalGroup);
}
if (json.groupId != null) {
builder.groupId(json.groupId);
}
if (json.origin != null) {
builder.origin(json.origin);
}
return builder.build();
}
/**
* Creates a builder for {@link ExternalGroupResource ExternalGroupResource}.
*
* ExternalGroupResource.builder()
* .displayName(String) // required {@link ExternalGroupResource#getDisplayName() displayName}
* .externalGroup(String) // required {@link ExternalGroupResource#getExternalGroup() externalGroup}
* .groupId(String) // required {@link ExternalGroupResource#getGroupId() groupId}
* .origin(String) // required {@link ExternalGroupResource#getOrigin() origin}
* .build();
*
* @return A new ExternalGroupResource builder
*/
public static ExternalGroupResource.Builder builder() {
return new ExternalGroupResource.Builder();
}
/**
* Builds instances of type {@link ExternalGroupResource ExternalGroupResource}.
* 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 = "_ExternalGroupResource", generator = "Immutables")
public static final class Builder {
private static final long INIT_BIT_DISPLAY_NAME = 0x1L;
private static final long INIT_BIT_EXTERNAL_GROUP = 0x2L;
private static final long INIT_BIT_GROUP_ID = 0x4L;
private static final long INIT_BIT_ORIGIN = 0x8L;
private long initBits = 0xfL;
private String displayName;
private String externalGroup;
private String groupId;
private String origin;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code org.cloudfoundry.uaa.groups.AbstractExternalGroupResource} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(AbstractExternalGroupResource instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code ExternalGroupResource} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(ExternalGroupResource instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Copy abstract value type {@code _ExternalGroupResource} 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(_ExternalGroupResource instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
private void from(short _unused, Object object) {
if (object instanceof AbstractExternalGroupResource) {
AbstractExternalGroupResource instance = (AbstractExternalGroupResource) object;
displayName(instance.getDisplayName());
externalGroup(instance.getExternalGroup());
groupId(instance.getGroupId());
origin(instance.getOrigin());
}
}
/**
* Initializes the value for the {@link ExternalGroupResource#getDisplayName() displayName} attribute.
* @param displayName The value for displayName
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("displayName")
public final Builder displayName(String displayName) {
this.displayName = Objects.requireNonNull(displayName, "displayName");
initBits &= ~INIT_BIT_DISPLAY_NAME;
return this;
}
/**
* Initializes the value for the {@link ExternalGroupResource#getExternalGroup() externalGroup} attribute.
* @param externalGroup The value for externalGroup
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("externalGroup")
public final Builder externalGroup(String externalGroup) {
this.externalGroup = Objects.requireNonNull(externalGroup, "externalGroup");
initBits &= ~INIT_BIT_EXTERNAL_GROUP;
return this;
}
/**
* Initializes the value for the {@link ExternalGroupResource#getGroupId() groupId} attribute.
* @param groupId The value for groupId
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("groupId")
public final Builder groupId(String groupId) {
this.groupId = Objects.requireNonNull(groupId, "groupId");
initBits &= ~INIT_BIT_GROUP_ID;
return this;
}
/**
* Initializes the value for the {@link ExternalGroupResource#getOrigin() origin} attribute.
* @param origin The value for origin
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("origin")
public final Builder origin(String origin) {
this.origin = Objects.requireNonNull(origin, "origin");
initBits &= ~INIT_BIT_ORIGIN;
return this;
}
/**
* Builds a new {@link ExternalGroupResource ExternalGroupResource}.
* @return An immutable instance of ExternalGroupResource
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ExternalGroupResource build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new ExternalGroupResource(this);
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if ((initBits & INIT_BIT_DISPLAY_NAME) != 0) attributes.add("displayName");
if ((initBits & INIT_BIT_EXTERNAL_GROUP) != 0) attributes.add("externalGroup");
if ((initBits & INIT_BIT_GROUP_ID) != 0) attributes.add("groupId");
if ((initBits & INIT_BIT_ORIGIN) != 0) attributes.add("origin");
return "Cannot build ExternalGroupResource, some of required attributes are not set " + attributes;
}
}
}