org.cloudfoundry.uaa.groups.MapExternalGroupResponse 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.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import org.cloudfoundry.uaa.Metadata;
import org.immutables.value.Generated;
/**
* The response payload for the map external group request
*/
@Generated(from = "_MapExternalGroupResponse", generator = "Immutables")
@SuppressWarnings({"all"})
@javax.annotation.Generated("org.immutables.processor.ProxyProcessor")
public final class MapExternalGroupResponse extends org.cloudfoundry.uaa.groups._MapExternalGroupResponse {
private final String displayName;
private final String externalGroup;
private final String groupId;
private final String origin;
private final Metadata metadata;
private final List schemas;
private MapExternalGroupResponse(MapExternalGroupResponse.Builder builder) {
this.displayName = builder.displayName;
this.externalGroup = builder.externalGroup;
this.groupId = builder.groupId;
this.origin = builder.origin;
this.metadata = builder.metadata;
this.schemas = createUnmodifiableList(true, builder.schemas);
}
/**
* 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;
}
/**
* The group's metadata
*/
@JsonProperty("meta")
@Override
public Metadata getMetadata() {
return metadata;
}
/**
* The group's schemas
*/
@JsonProperty("schemas")
@Override
public List getSchemas() {
return schemas;
}
/**
* This instance is equal to all instances of {@code MapExternalGroupResponse} 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 MapExternalGroupResponse
&& equalTo(0, (MapExternalGroupResponse) another);
}
private boolean equalTo(int synthetic, MapExternalGroupResponse another) {
return displayName.equals(another.displayName)
&& externalGroup.equals(another.externalGroup)
&& groupId.equals(another.groupId)
&& origin.equals(another.origin)
&& metadata.equals(another.metadata)
&& schemas.equals(another.schemas);
}
/**
* Computes a hash code from attributes: {@code displayName}, {@code externalGroup}, {@code groupId}, {@code origin}, {@code metadata}, {@code schemas}.
* @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();
h += (h << 5) + metadata.hashCode();
h += (h << 5) + schemas.hashCode();
return h;
}
/**
* Prints the immutable value {@code MapExternalGroupResponse} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return "MapExternalGroupResponse{"
+ "displayName=" + displayName
+ ", externalGroup=" + externalGroup
+ ", groupId=" + groupId
+ ", origin=" + origin
+ ", metadata=" + metadata
+ ", schemas=" + schemas
+ "}";
}
/**
* 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 = "_MapExternalGroupResponse", generator = "Immutables")
@Deprecated
@JsonDeserialize
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json extends org.cloudfoundry.uaa.groups._MapExternalGroupResponse {
String displayName;
String externalGroup;
String groupId;
String origin;
Metadata metadata;
List schemas = Collections.emptyList();
@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;
}
@JsonProperty("meta")
public void setMetadata(Metadata metadata) {
this.metadata = metadata;
}
@JsonProperty("schemas")
public void setSchemas(List schemas) {
this.schemas = schemas;
}
@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(); }
@Override
public Metadata getMetadata() { throw new UnsupportedOperationException(); }
@Override
public List getSchemas() { 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 MapExternalGroupResponse fromJson(Json json) {
MapExternalGroupResponse.Builder builder = MapExternalGroupResponse.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);
}
if (json.metadata != null) {
builder.metadata(json.metadata);
}
if (json.schemas != null) {
builder.addAllSchemas(json.schemas);
}
return builder.build();
}
/**
* Creates a builder for {@link MapExternalGroupResponse MapExternalGroupResponse}.
*
* MapExternalGroupResponse.builder()
* .displayName(String) // required {@link MapExternalGroupResponse#getDisplayName() displayName}
* .externalGroup(String) // required {@link MapExternalGroupResponse#getExternalGroup() externalGroup}
* .groupId(String) // required {@link MapExternalGroupResponse#getGroupId() groupId}
* .origin(String) // required {@link MapExternalGroupResponse#getOrigin() origin}
* .metadata(org.cloudfoundry.uaa.Metadata) // required {@link MapExternalGroupResponse#getMetadata() metadata}
* .schema|addAllSchemas(String) // {@link MapExternalGroupResponse#getSchemas() schemas} elements
* .build();
*
* @return A new MapExternalGroupResponse builder
*/
public static MapExternalGroupResponse.Builder builder() {
return new MapExternalGroupResponse.Builder();
}
/**
* Builds instances of type {@link MapExternalGroupResponse MapExternalGroupResponse}.
* 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 = "_MapExternalGroupResponse", 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 static final long INIT_BIT_METADATA = 0x10L;
private long initBits = 0x1fL;
private String displayName;
private String externalGroup;
private String groupId;
private String origin;
private Metadata metadata;
private List schemas = new ArrayList();
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code MapExternalGroupResponse} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(MapExternalGroupResponse instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Copy abstract value type {@code _MapExternalGroupResponse} 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(_MapExternalGroupResponse 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.groups.AbstractExternalGroupMapping} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(AbstractExternalGroupMapping 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.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;
}
private void from(short _unused, Object object) {
long bits = 0;
if (object instanceof org.cloudfoundry.uaa.groups._MapExternalGroupResponse) {
org.cloudfoundry.uaa.groups._MapExternalGroupResponse instance = (org.cloudfoundry.uaa.groups._MapExternalGroupResponse) object;
if ((bits & 0x1L) == 0) {
metadata(instance.getMetadata());
bits |= 0x1L;
}
if ((bits & 0x20L) == 0) {
addAllSchemas(instance.getSchemas());
bits |= 0x20L;
}
}
if (object instanceof AbstractExternalGroupMapping) {
AbstractExternalGroupMapping instance = (AbstractExternalGroupMapping) object;
if ((bits & 0x1L) == 0) {
metadata(instance.getMetadata());
bits |= 0x1L;
}
if ((bits & 0x2L) == 0) {
displayName(instance.getDisplayName());
bits |= 0x2L;
}
if ((bits & 0x4L) == 0) {
externalGroup(instance.getExternalGroup());
bits |= 0x4L;
}
if ((bits & 0x8L) == 0) {
groupId(instance.getGroupId());
bits |= 0x8L;
}
if ((bits & 0x10L) == 0) {
origin(instance.getOrigin());
bits |= 0x10L;
}
if ((bits & 0x20L) == 0) {
addAllSchemas(instance.getSchemas());
bits |= 0x20L;
}
}
if (object instanceof AbstractExternalGroupResource) {
AbstractExternalGroupResource instance = (AbstractExternalGroupResource) object;
if ((bits & 0x2L) == 0) {
displayName(instance.getDisplayName());
bits |= 0x2L;
}
if ((bits & 0x4L) == 0) {
externalGroup(instance.getExternalGroup());
bits |= 0x4L;
}
if ((bits & 0x8L) == 0) {
groupId(instance.getGroupId());
bits |= 0x8L;
}
if ((bits & 0x10L) == 0) {
origin(instance.getOrigin());
bits |= 0x10L;
}
}
}
/**
* Initializes the value for the {@link MapExternalGroupResponse#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 MapExternalGroupResponse#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 MapExternalGroupResponse#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 MapExternalGroupResponse#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;
}
/**
* Initializes the value for the {@link MapExternalGroupResponse#getMetadata() metadata} attribute.
* @param metadata The value for metadata
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("meta")
public final Builder metadata(Metadata metadata) {
this.metadata = Objects.requireNonNull(metadata, "metadata");
initBits &= ~INIT_BIT_METADATA;
return this;
}
/**
* Adds one element to {@link MapExternalGroupResponse#getSchemas() schemas} list.
* @param element A schemas element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder schema(String element) {
this.schemas.add(Objects.requireNonNull(element, "schemas element"));
return this;
}
/**
* Adds elements to {@link MapExternalGroupResponse#getSchemas() schemas} list.
* @param elements An array of schemas elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder schemas(String... elements) {
for (String element : elements) {
this.schemas.add(Objects.requireNonNull(element, "schemas element"));
}
return this;
}
/**
* Sets or replaces all elements for {@link MapExternalGroupResponse#getSchemas() schemas} list.
* @param elements An iterable of schemas elements
* @return {@code this} builder for use in a chained invocation
*/
@JsonProperty("schemas")
public final Builder schemas(Iterable elements) {
this.schemas.clear();
return addAllSchemas(elements);
}
/**
* Adds elements to {@link MapExternalGroupResponse#getSchemas() schemas} list.
* @param elements An iterable of schemas elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllSchemas(Iterable elements) {
for (String element : elements) {
this.schemas.add(Objects.requireNonNull(element, "schemas element"));
}
return this;
}
/**
* Builds a new {@link MapExternalGroupResponse MapExternalGroupResponse}.
* @return An immutable instance of MapExternalGroupResponse
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public MapExternalGroupResponse build() {
if (initBits != 0) {
throw new IllegalStateException(formatRequiredAttributesMessage());
}
return new MapExternalGroupResponse(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");
if ((initBits & INIT_BIT_METADATA) != 0) attributes.add("metadata");
return "Cannot build MapExternalGroupResponse, 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);
}
}
}
}