
com.hubspot.slack.client.methods.params.usergroups.UsergroupUpdateParams Maven / Gradle / Ivy
package com.hubspot.slack.client.methods.params.usergroups;
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 com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.methods.interceptor.HasCommaSeperatedChannelIds;
import com.hubspot.slack.client.methods.interceptor.HasUsergroup;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
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 AbstractUsergroupUpdateParams}.
*
* Use the builder to create immutable instances:
* {@code UsergroupUpdateParams.builder()}.
*/
@Generated(from = "AbstractUsergroupUpdateParams", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class UsergroupUpdateParams
extends AbstractUsergroupUpdateParams {
private final List rawChannelIds;
private transient final Optional encodedChannels;
private final String usergroupId;
private final @Nullable String name;
private final @Nullable String description;
private final @Nullable String handle;
private final @Nullable Boolean includeCount;
private UsergroupUpdateParams(
List rawChannelIds,
String usergroupId,
@Nullable String name,
@Nullable String description,
@Nullable String handle,
@Nullable Boolean includeCount) {
this.rawChannelIds = rawChannelIds;
this.usergroupId = usergroupId;
this.name = name;
this.description = description;
this.handle = handle;
this.includeCount = includeCount;
this.encodedChannels = Objects.requireNonNull(super.getEncodedChannels(), "encodedChannels");
}
/**
* @return The value of the {@code rawChannelIds} attribute
*/
@JsonProperty
@JsonIgnore
@Override
public List getRawChannelIds() {
return rawChannelIds;
}
/**
* @return The computed-at-construction value of the {@code encodedChannels} attribute
*/
@JsonProperty("channels")
@Override
public Optional getEncodedChannels() {
return encodedChannels;
}
/**
* @return The value of the {@code usergroupId} attribute
*/
@JsonProperty("usergroup")
@Override
public String getUsergroupId() {
return usergroupId;
}
/**
* @return The value of the {@code name} attribute
*/
@JsonProperty
@Override
public Optional getName() {
return Optional.ofNullable(name);
}
/**
* @return The value of the {@code description} attribute
*/
@JsonProperty
@Override
public Optional getDescription() {
return Optional.ofNullable(description);
}
/**
* @return The value of the {@code handle} attribute
*/
@JsonProperty
@Override
public Optional getHandle() {
return Optional.ofNullable(handle);
}
/**
* @return The value of the {@code includeCount} attribute
*/
@JsonProperty
@Override
public Optional getIncludeCount() {
return Optional.ofNullable(includeCount);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AbstractUsergroupUpdateParams#getRawChannelIds() rawChannelIds}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withRawChannelIds(String... elements) {
List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false));
return new UsergroupUpdateParams(newValue, this.usergroupId, this.name, this.description, this.handle, this.includeCount);
}
/**
* Copy the current immutable object with elements that replace the content of {@link AbstractUsergroupUpdateParams#getRawChannelIds() rawChannelIds}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of rawChannelIds elements to set
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withRawChannelIds(Iterable elements) {
if (this.rawChannelIds == elements) return this;
List newValue = createUnmodifiableList(false, createSafeList(elements, true, false));
return new UsergroupUpdateParams(newValue, this.usergroupId, this.name, this.description, this.handle, this.includeCount);
}
/**
* Copy the current immutable object by setting a value for the {@link AbstractUsergroupUpdateParams#getUsergroupId() usergroupId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for usergroupId
* @return A modified copy of the {@code this} object
*/
public final UsergroupUpdateParams withUsergroupId(String value) {
String newValue = Objects.requireNonNull(value, "usergroupId");
if (this.usergroupId.equals(newValue)) return this;
return new UsergroupUpdateParams(this.rawChannelIds, newValue, this.name, this.description, this.handle, this.includeCount);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractUsergroupUpdateParams#getName() name} attribute.
* @param value The value for name, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withName(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.name, newValue)) return this;
return new UsergroupUpdateParams(
this.rawChannelIds,
this.usergroupId,
newValue,
this.description,
this.handle,
this.includeCount);
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractUsergroupUpdateParams#getName() name} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for name
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withName(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.name, value)) return this;
return new UsergroupUpdateParams(this.rawChannelIds, this.usergroupId, value, this.description, this.handle, this.includeCount);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractUsergroupUpdateParams#getDescription() description} attribute.
* @param value The value for description, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withDescription(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.description, newValue)) return this;
return new UsergroupUpdateParams(this.rawChannelIds, this.usergroupId, this.name, newValue, this.handle, this.includeCount);
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractUsergroupUpdateParams#getDescription() description} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for description
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withDescription(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return new UsergroupUpdateParams(this.rawChannelIds, this.usergroupId, this.name, value, this.handle, this.includeCount);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractUsergroupUpdateParams#getHandle() handle} attribute.
* @param value The value for handle, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withHandle(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.handle, newValue)) return this;
return new UsergroupUpdateParams(this.rawChannelIds, this.usergroupId, this.name, this.description, newValue, this.includeCount);
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractUsergroupUpdateParams#getHandle() handle} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for handle
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withHandle(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.handle, value)) return this;
return new UsergroupUpdateParams(this.rawChannelIds, this.usergroupId, this.name, this.description, value, this.includeCount);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link AbstractUsergroupUpdateParams#getIncludeCount() includeCount} attribute.
* @param value The value for includeCount, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withIncludeCount(@Nullable Boolean value) {
@Nullable Boolean newValue = value;
if (Objects.equals(this.includeCount, newValue)) return this;
return new UsergroupUpdateParams(this.rawChannelIds, this.usergroupId, this.name, this.description, this.handle, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link AbstractUsergroupUpdateParams#getIncludeCount() includeCount} attribute.
* An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
* @param optional A value for includeCount
* @return A modified copy of {@code this} object
*/
public final UsergroupUpdateParams withIncludeCount(Optional optional) {
@Nullable Boolean value = optional.orElse(null);
if (Objects.equals(this.includeCount, value)) return this;
return new UsergroupUpdateParams(this.rawChannelIds, this.usergroupId, this.name, this.description, this.handle, value);
}
/**
* This instance is equal to all instances of {@code UsergroupUpdateParams} 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 UsergroupUpdateParams
&& equalTo(0, (UsergroupUpdateParams) another);
}
private boolean equalTo(int synthetic, UsergroupUpdateParams another) {
return rawChannelIds.equals(another.rawChannelIds)
&& encodedChannels.equals(another.encodedChannels)
&& usergroupId.equals(another.usergroupId)
&& Objects.equals(name, another.name)
&& Objects.equals(description, another.description)
&& Objects.equals(handle, another.handle)
&& Objects.equals(includeCount, another.includeCount);
}
/**
* Computes a hash code from attributes: {@code rawChannelIds}, {@code encodedChannels}, {@code usergroupId}, {@code name}, {@code description}, {@code handle}, {@code includeCount}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + rawChannelIds.hashCode();
h += (h << 5) + encodedChannels.hashCode();
h += (h << 5) + usergroupId.hashCode();
h += (h << 5) + Objects.hashCode(name);
h += (h << 5) + Objects.hashCode(description);
h += (h << 5) + Objects.hashCode(handle);
h += (h << 5) + Objects.hashCode(includeCount);
return h;
}
/**
* Prints the immutable value {@code UsergroupUpdateParams} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("UsergroupUpdateParams{");
builder.append("rawChannelIds=").append(rawChannelIds);
builder.append(", ");
builder.append("encodedChannels=").append(encodedChannels);
builder.append(", ");
builder.append("usergroupId=").append(usergroupId);
if (name != null) {
builder.append(", ");
builder.append("name=").append(name);
}
if (description != null) {
builder.append(", ");
builder.append("description=").append(description);
}
if (handle != null) {
builder.append(", ");
builder.append("handle=").append(handle);
}
if (includeCount != null) {
builder.append(", ");
builder.append("includeCount=").append(includeCount);
}
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 = "AbstractUsergroupUpdateParams", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json
extends AbstractUsergroupUpdateParams {
@Nullable List rawChannelIds = Collections.emptyList();
@Nullable String usergroupId;
@Nullable Optional name = Optional.empty();
@Nullable Optional description = Optional.empty();
@Nullable Optional handle = Optional.empty();
@Nullable Optional includeCount = Optional.empty();
@JsonProperty
@JsonIgnore
public void setRawChannelIds(List rawChannelIds) {
this.rawChannelIds = rawChannelIds;
}
@JsonProperty("usergroup")
public void setUsergroupId(String usergroupId) {
this.usergroupId = usergroupId;
}
@JsonProperty
public void setName(Optional name) {
this.name = name;
}
@JsonProperty
public void setDescription(Optional description) {
this.description = description;
}
@JsonProperty
public void setHandle(Optional handle) {
this.handle = handle;
}
@JsonProperty
public void setIncludeCount(Optional includeCount) {
this.includeCount = includeCount;
}
@Override
public List getRawChannelIds() { throw new UnsupportedOperationException(); }
@JsonIgnore
@Override
public Optional getEncodedChannels() { throw new UnsupportedOperationException(); }
@Override
public String getUsergroupId() { throw new UnsupportedOperationException(); }
@Override
public Optional getName() { throw new UnsupportedOperationException(); }
@Override
public Optional getDescription() { throw new UnsupportedOperationException(); }
@Override
public Optional getHandle() { throw new UnsupportedOperationException(); }
@Override
public Optional getIncludeCount() { 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 UsergroupUpdateParams fromJson(Json json) {
UsergroupUpdateParams.Builder builder = UsergroupUpdateParams.builder();
if (json.rawChannelIds != null) {
builder.addAllRawChannelIds(json.rawChannelIds);
}
if (json.usergroupId != null) {
builder.setUsergroupId(json.usergroupId);
}
if (json.name != null) {
builder.setName(json.name);
}
if (json.description != null) {
builder.setDescription(json.description);
}
if (json.handle != null) {
builder.setHandle(json.handle);
}
if (json.includeCount != null) {
builder.setIncludeCount(json.includeCount);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link AbstractUsergroupUpdateParams} 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 UsergroupUpdateParams instance
*/
public static UsergroupUpdateParams copyOf(AbstractUsergroupUpdateParams instance) {
if (instance instanceof UsergroupUpdateParams) {
return (UsergroupUpdateParams) instance;
}
return UsergroupUpdateParams.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link UsergroupUpdateParams UsergroupUpdateParams}.
*
* UsergroupUpdateParams.builder()
* .addRawChannelIds|addAllRawChannelIds(String) // {@link AbstractUsergroupUpdateParams#getRawChannelIds() rawChannelIds} elements
* .setUsergroupId(String) // required {@link AbstractUsergroupUpdateParams#getUsergroupId() usergroupId}
* .setName(String) // optional {@link AbstractUsergroupUpdateParams#getName() name}
* .setDescription(String) // optional {@link AbstractUsergroupUpdateParams#getDescription() description}
* .setHandle(String) // optional {@link AbstractUsergroupUpdateParams#getHandle() handle}
* .setIncludeCount(Boolean) // optional {@link AbstractUsergroupUpdateParams#getIncludeCount() includeCount}
* .build();
*
* @return A new UsergroupUpdateParams builder
*/
public static UsergroupUpdateParams.Builder builder() {
return new UsergroupUpdateParams.Builder();
}
/**
* Builds instances of type {@link UsergroupUpdateParams UsergroupUpdateParams}.
* 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 = "AbstractUsergroupUpdateParams", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_USERGROUP_ID = 0x1L;
private long initBits = 0x1L;
private List rawChannelIds = new ArrayList();
private @Nullable String usergroupId;
private @Nullable String name;
private @Nullable String description;
private @Nullable String handle;
private @Nullable Boolean includeCount;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.methods.interceptor.HasCommaSeperatedChannelIds} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(HasCommaSeperatedChannelIds instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.methods.interceptor.HasUsergroup} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(HasUsergroup instance) {
Objects.requireNonNull(instance, "instance");
from((short) 0, (Object) instance);
return this;
}
/**
* Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.methods.params.usergroups.AbstractUsergroupUpdateParams} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(AbstractUsergroupUpdateParams 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 HasCommaSeperatedChannelIds) {
HasCommaSeperatedChannelIds instance = (HasCommaSeperatedChannelIds) object;
if ((bits & 0x2L) == 0) {
addAllRawChannelIds(instance.getRawChannelIds());
bits |= 0x2L;
}
}
if (object instanceof HasUsergroup) {
HasUsergroup instance = (HasUsergroup) object;
if ((bits & 0x1L) == 0) {
this.setUsergroupId(instance.getUsergroupId());
bits |= 0x1L;
}
}
if (object instanceof AbstractUsergroupUpdateParams) {
AbstractUsergroupUpdateParams instance = (AbstractUsergroupUpdateParams) object;
Optional nameOptional = instance.getName();
if (nameOptional.isPresent()) {
setName(nameOptional);
}
if ((bits & 0x1L) == 0) {
this.setUsergroupId(instance.getUsergroupId());
bits |= 0x1L;
}
Optional descriptionOptional = instance.getDescription();
if (descriptionOptional.isPresent()) {
setDescription(descriptionOptional);
}
Optional handleOptional = instance.getHandle();
if (handleOptional.isPresent()) {
setHandle(handleOptional);
}
Optional includeCountOptional = instance.getIncludeCount();
if (includeCountOptional.isPresent()) {
setIncludeCount(includeCountOptional);
}
if ((bits & 0x2L) == 0) {
addAllRawChannelIds(instance.getRawChannelIds());
bits |= 0x2L;
}
}
}
/**
* Adds one element to {@link AbstractUsergroupUpdateParams#getRawChannelIds() rawChannelIds} list.
* @param element A rawChannelIds element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addRawChannelIds(String element) {
this.rawChannelIds.add(Objects.requireNonNull(element, "rawChannelIds element"));
return this;
}
/**
* Adds elements to {@link AbstractUsergroupUpdateParams#getRawChannelIds() rawChannelIds} list.
* @param elements An array of rawChannelIds elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addRawChannelIds(String... elements) {
for (String element : elements) {
this.rawChannelIds.add(Objects.requireNonNull(element, "rawChannelIds element"));
}
return this;
}
/**
* Sets or replaces all elements for {@link AbstractUsergroupUpdateParams#getRawChannelIds() rawChannelIds} list.
* @param elements An iterable of rawChannelIds elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setRawChannelIds(Iterable elements) {
this.rawChannelIds.clear();
return addAllRawChannelIds(elements);
}
/**
* Adds elements to {@link AbstractUsergroupUpdateParams#getRawChannelIds() rawChannelIds} list.
* @param elements An iterable of rawChannelIds elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllRawChannelIds(Iterable elements) {
for (String element : elements) {
this.rawChannelIds.add(Objects.requireNonNull(element, "rawChannelIds element"));
}
return this;
}
/**
* Initializes the value for the {@link AbstractUsergroupUpdateParams#getUsergroupId() usergroupId} attribute.
* @param usergroupId The value for usergroupId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setUsergroupId(String usergroupId) {
this.usergroupId = Objects.requireNonNull(usergroupId, "usergroupId");
initBits &= ~INIT_BIT_USERGROUP_ID;
return this;
}
/**
* Initializes the optional value {@link AbstractUsergroupUpdateParams#getName() name} to name.
* @param name The value for name, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setName(@Nullable String name) {
this.name = name;
return this;
}
/**
* Initializes the optional value {@link AbstractUsergroupUpdateParams#getName() name} to name.
* @param name The value for name
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setName(Optional name) {
this.name = name.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractUsergroupUpdateParams#getDescription() description} to description.
* @param description The value for description, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setDescription(@Nullable String description) {
this.description = description;
return this;
}
/**
* Initializes the optional value {@link AbstractUsergroupUpdateParams#getDescription() description} to description.
* @param description The value for description
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setDescription(Optional description) {
this.description = description.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractUsergroupUpdateParams#getHandle() handle} to handle.
* @param handle The value for handle, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setHandle(@Nullable String handle) {
this.handle = handle;
return this;
}
/**
* Initializes the optional value {@link AbstractUsergroupUpdateParams#getHandle() handle} to handle.
* @param handle The value for handle
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setHandle(Optional handle) {
this.handle = handle.orElse(null);
return this;
}
/**
* Initializes the optional value {@link AbstractUsergroupUpdateParams#getIncludeCount() includeCount} to includeCount.
* @param includeCount The value for includeCount, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setIncludeCount(@Nullable Boolean includeCount) {
this.includeCount = includeCount;
return this;
}
/**
* Initializes the optional value {@link AbstractUsergroupUpdateParams#getIncludeCount() includeCount} to includeCount.
* @param includeCount The value for includeCount
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setIncludeCount(Optional includeCount) {
this.includeCount = includeCount.orElse(null);
return this;
}
/**
* Builds a new {@link UsergroupUpdateParams UsergroupUpdateParams}.
* @return An immutable instance of UsergroupUpdateParams
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public UsergroupUpdateParams build() {
checkRequiredAttributes();
return new UsergroupUpdateParams(
createUnmodifiableList(true, rawChannelIds),
usergroupId,
name,
description,
handle,
includeCount);
}
private boolean usergroupIdIsSet() {
return (initBits & INIT_BIT_USERGROUP_ID) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!usergroupIdIsSet()) attributes.add("usergroupId");
return "Cannot build UsergroupUpdateParams, 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);
}
}
}
}