
com.hubspot.slack.client.methods.params.dnd.DndInfoParams Maven / Gradle / Ivy
package com.hubspot.slack.client.methods.params.dnd;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
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 DndInfoParamsIF}.
*
* Use the builder to create immutable instances:
* {@code DndInfoParams.builder()}.
* Use the static factory method to create immutable instances:
* {@code DndInfoParams.of()}.
*/
@Generated(from = "DndInfoParamsIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class DndInfoParams implements DndInfoParamsIF {
private final @Nullable String userId;
private DndInfoParams(Optional userId) {
this.userId = userId.orElse(null);
}
private DndInfoParams(@Nullable String userId) {
this.userId = userId;
}
private DndInfoParams(DndInfoParams original, @Nullable String userId) {
this.userId = userId;
}
/**
* @return The value of the {@code userId} attribute
*/
@JsonProperty("user")
@Override
public Optional getUserId() {
return Optional.ofNullable(userId);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link DndInfoParamsIF#getUserId() userId} attribute.
* @param value The value for userId, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final DndInfoParams withUserId(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.userId, newValue)) return this;
return new DndInfoParams(this, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link DndInfoParamsIF#getUserId() userId} 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 userId
* @return A modified copy of {@code this} object
*/
public final DndInfoParams withUserId(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.userId, value)) return this;
return new DndInfoParams(this, value);
}
/**
* This instance is equal to all instances of {@code DndInfoParams} 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 DndInfoParams
&& equalTo(0, (DndInfoParams) another);
}
private boolean equalTo(int synthetic, DndInfoParams another) {
return Objects.equals(userId, another.userId);
}
/**
* Computes a hash code from attributes: {@code userId}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(userId);
return h;
}
/**
* Prints the immutable value {@code DndInfoParams} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("DndInfoParams{");
if (userId != null) {
builder.append("userId=").append(userId);
}
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 = "DndInfoParamsIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements DndInfoParamsIF {
@Nullable Optional userId = Optional.empty();
@JsonProperty("user")
public void setUserId(Optional userId) {
this.userId = userId;
}
@Override
public Optional getUserId() { 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 DndInfoParams fromJson(Json json) {
DndInfoParams.Builder builder = DndInfoParams.builder();
if (json.userId != null) {
builder.setUserId(json.userId);
}
return builder.build();
}
/**
* Construct a new immutable {@code DndInfoParams} instance.
* @param userId The value for the {@code userId} attribute
* @return An immutable DndInfoParams instance
*/
public static DndInfoParams of(Optional userId) {
return new DndInfoParams(userId);
}
/**
* Construct a new immutable {@code DndInfoParams} instance.
* @param userId The value for the {@code userId} attribute
* @return An immutable DndInfoParams instance
*/
public static DndInfoParams of(@Nullable String userId) {
return new DndInfoParams(userId);
}
/**
* Creates an immutable copy of a {@link DndInfoParamsIF} 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 DndInfoParams instance
*/
public static DndInfoParams copyOf(DndInfoParamsIF instance) {
if (instance instanceof DndInfoParams) {
return (DndInfoParams) instance;
}
return DndInfoParams.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link DndInfoParams DndInfoParams}.
*
* DndInfoParams.builder()
* .setUserId(String) // optional {@link DndInfoParamsIF#getUserId() userId}
* .build();
*
* @return A new DndInfoParams builder
*/
public static DndInfoParams.Builder builder() {
return new DndInfoParams.Builder();
}
/**
* Builds instances of type {@link DndInfoParams DndInfoParams}.
* 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 = "DndInfoParamsIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private @Nullable String userId;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code DndInfoParamsIF} 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(DndInfoParamsIF instance) {
Objects.requireNonNull(instance, "instance");
Optional userIdOptional = instance.getUserId();
if (userIdOptional.isPresent()) {
setUserId(userIdOptional);
}
return this;
}
/**
* Initializes the optional value {@link DndInfoParamsIF#getUserId() userId} to userId.
* @param userId The value for userId, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setUserId(@Nullable String userId) {
this.userId = userId;
return this;
}
/**
* Initializes the optional value {@link DndInfoParamsIF#getUserId() userId} to userId.
* @param userId The value for userId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setUserId(Optional userId) {
this.userId = userId.orElse(null);
return this;
}
/**
* Builds a new {@link DndInfoParams DndInfoParams}.
* @return An immutable instance of DndInfoParams
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public DndInfoParams build() {
return new DndInfoParams(null, userId);
}
}
}