
com.hubspot.slack.client.methods.params.usergroups.UsergroupEnableParams 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.JsonProperty;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
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 UsergroupEnableParamsIF}.
*
* Use the builder to create immutable instances:
* {@code UsergroupEnableParams.builder()}.
*/
@Generated(from = "UsergroupEnableParamsIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class UsergroupEnableParams
implements UsergroupEnableParamsIF {
private final String usergroupId;
private final @Nullable Boolean includeCount;
private UsergroupEnableParams(String usergroupId, @Nullable Boolean includeCount) {
this.usergroupId = usergroupId;
this.includeCount = includeCount;
}
/**
* @return The value of the {@code usergroupId} attribute
*/
@JsonProperty("usergroup")
@Override
public String getUsergroupId() {
return usergroupId;
}
/**
* @return The value of the {@code includeCount} attribute
*/
@JsonProperty
@Override
public Optional getIncludeCount() {
return Optional.ofNullable(includeCount);
}
/**
* Copy the current immutable object by setting a value for the {@link UsergroupEnableParamsIF#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 UsergroupEnableParams withUsergroupId(String value) {
String newValue = Objects.requireNonNull(value, "usergroupId");
if (this.usergroupId.equals(newValue)) return this;
return new UsergroupEnableParams(newValue, this.includeCount);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link UsergroupEnableParamsIF#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 UsergroupEnableParams withIncludeCount(@Nullable Boolean value) {
@Nullable Boolean newValue = value;
if (Objects.equals(this.includeCount, newValue)) return this;
return new UsergroupEnableParams(this.usergroupId, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link UsergroupEnableParamsIF#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 UsergroupEnableParams withIncludeCount(Optional optional) {
@Nullable Boolean value = optional.orElse(null);
if (Objects.equals(this.includeCount, value)) return this;
return new UsergroupEnableParams(this.usergroupId, value);
}
/**
* This instance is equal to all instances of {@code UsergroupEnableParams} 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 UsergroupEnableParams
&& equalTo(0, (UsergroupEnableParams) another);
}
private boolean equalTo(int synthetic, UsergroupEnableParams another) {
return usergroupId.equals(another.usergroupId)
&& Objects.equals(includeCount, another.includeCount);
}
/**
* Computes a hash code from attributes: {@code usergroupId}, {@code includeCount}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + usergroupId.hashCode();
h += (h << 5) + Objects.hashCode(includeCount);
return h;
}
/**
* Prints the immutable value {@code UsergroupEnableParams} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("UsergroupEnableParams{");
builder.append("usergroupId=").append(usergroupId);
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 = "UsergroupEnableParamsIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json
implements UsergroupEnableParamsIF {
@Nullable String usergroupId;
@Nullable Optional includeCount = Optional.empty();
@JsonProperty("usergroup")
public void setUsergroupId(String usergroupId) {
this.usergroupId = usergroupId;
}
@JsonProperty
public void setIncludeCount(Optional includeCount) {
this.includeCount = includeCount;
}
@Override
public String getUsergroupId() { 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 UsergroupEnableParams fromJson(Json json) {
UsergroupEnableParams.Builder builder = UsergroupEnableParams.builder();
if (json.usergroupId != null) {
builder.setUsergroupId(json.usergroupId);
}
if (json.includeCount != null) {
builder.setIncludeCount(json.includeCount);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link UsergroupEnableParamsIF} 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 UsergroupEnableParams instance
*/
public static UsergroupEnableParams copyOf(UsergroupEnableParamsIF instance) {
if (instance instanceof UsergroupEnableParams) {
return (UsergroupEnableParams) instance;
}
return UsergroupEnableParams.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link UsergroupEnableParams UsergroupEnableParams}.
*
* UsergroupEnableParams.builder()
* .setUsergroupId(String) // required {@link UsergroupEnableParamsIF#getUsergroupId() usergroupId}
* .setIncludeCount(Boolean) // optional {@link UsergroupEnableParamsIF#getIncludeCount() includeCount}
* .build();
*
* @return A new UsergroupEnableParams builder
*/
public static UsergroupEnableParams.Builder builder() {
return new UsergroupEnableParams.Builder();
}
/**
* Builds instances of type {@link UsergroupEnableParams UsergroupEnableParams}.
* 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 = "UsergroupEnableParamsIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_USERGROUP_ID = 0x1L;
private long initBits = 0x1L;
private @Nullable String usergroupId;
private @Nullable Boolean includeCount;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code UsergroupEnableParamsIF} 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
*/
public final Builder from(UsergroupEnableParamsIF instance) {
Objects.requireNonNull(instance, "instance");
this.setUsergroupId(instance.getUsergroupId());
Optional includeCountOptional = instance.getIncludeCount();
if (includeCountOptional.isPresent()) {
setIncludeCount(includeCountOptional);
}
return this;
}
/**
* Initializes the value for the {@link UsergroupEnableParamsIF#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 UsergroupEnableParamsIF#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 UsergroupEnableParamsIF#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 UsergroupEnableParams UsergroupEnableParams}.
* @return An immutable instance of UsergroupEnableParams
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public UsergroupEnableParams build() {
checkRequiredAttributes();
return new UsergroupEnableParams(usergroupId, 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 UsergroupEnableParams, some of required attributes are not set " + attributes;
}
}
}