
com.hubspot.slack.client.methods.params.bookmarks.BookmarksAddParams Maven / Gradle / Ivy
package com.hubspot.slack.client.methods.params.bookmarks;
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.HasChannel;
import com.hubspot.slack.client.models.bookmarks.BookmarkType;
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 BookmarksAddParamsIF}.
*
* Use the builder to create immutable instances:
* {@code BookmarksAddParams.builder()}.
*/
@Generated(from = "BookmarksAddParamsIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class BookmarksAddParams
implements BookmarksAddParamsIF {
private final String channelId;
private transient final String channel;
private final String title;
private final BookmarkType type;
private final @Nullable String emoji;
private final @Nullable String entityId;
private final @Nullable String link;
private final @Nullable String parentId;
private BookmarksAddParams(
String channelId,
String title,
BookmarkType type,
@Nullable String emoji,
@Nullable String entityId,
@Nullable String link,
@Nullable String parentId) {
this.channelId = channelId;
this.title = title;
this.type = type;
this.emoji = emoji;
this.entityId = entityId;
this.link = link;
this.parentId = parentId;
this.channel = Objects.requireNonNull(BookmarksAddParamsIF.super.getChannel(), "channel");
}
/**
* @return The value of the {@code channelId} attribute
*/
@JsonProperty
@Override
public String getChannelId() {
return channelId;
}
/**
* @return The computed-at-construction value of the {@code channel} attribute
*/
@JsonProperty
@Override
public String getChannel() {
return channel;
}
/**
* @return The value of the {@code title} attribute
*/
@JsonProperty
@Override
public String getTitle() {
return title;
}
/**
* @return The value of the {@code type} attribute
*/
@JsonProperty
@Override
public BookmarkType getType() {
return type;
}
/**
* @return The value of the {@code emoji} attribute
*/
@JsonProperty
@Override
public Optional getEmoji() {
return Optional.ofNullable(emoji);
}
/**
* @return The value of the {@code entityId} attribute
*/
@JsonProperty
@Override
public Optional getEntityId() {
return Optional.ofNullable(entityId);
}
/**
* @return The value of the {@code link} attribute
*/
@JsonProperty
@Override
public Optional getLink() {
return Optional.ofNullable(link);
}
/**
* @return The value of the {@code parentId} attribute
*/
@JsonProperty
@Override
public Optional getParentId() {
return Optional.ofNullable(parentId);
}
/**
* Copy the current immutable object by setting a value for the {@link BookmarksAddParamsIF#getChannelId() channelId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for channelId
* @return A modified copy of the {@code this} object
*/
public final BookmarksAddParams withChannelId(String value) {
String newValue = Objects.requireNonNull(value, "channelId");
if (this.channelId.equals(newValue)) return this;
return new BookmarksAddParams(newValue, this.title, this.type, this.emoji, this.entityId, this.link, this.parentId);
}
/**
* Copy the current immutable object by setting a value for the {@link BookmarksAddParamsIF#getTitle() title} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for title
* @return A modified copy of the {@code this} object
*/
public final BookmarksAddParams withTitle(String value) {
String newValue = Objects.requireNonNull(value, "title");
if (this.title.equals(newValue)) return this;
return new BookmarksAddParams(this.channelId, newValue, this.type, this.emoji, this.entityId, this.link, this.parentId);
}
/**
* Copy the current immutable object by setting a value for the {@link BookmarksAddParamsIF#getType() type} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for type
* @return A modified copy of the {@code this} object
*/
public final BookmarksAddParams withType(BookmarkType value) {
BookmarkType newValue = Objects.requireNonNull(value, "type");
if (this.type == newValue) return this;
return new BookmarksAddParams(this.channelId, this.title, newValue, this.emoji, this.entityId, this.link, this.parentId);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link BookmarksAddParamsIF#getEmoji() emoji} attribute.
* @param value The value for emoji, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BookmarksAddParams withEmoji(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.emoji, newValue)) return this;
return new BookmarksAddParams(this.channelId, this.title, this.type, newValue, this.entityId, this.link, this.parentId);
}
/**
* Copy the current immutable object by setting an optional value for the {@link BookmarksAddParamsIF#getEmoji() emoji} 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 emoji
* @return A modified copy of {@code this} object
*/
public final BookmarksAddParams withEmoji(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.emoji, value)) return this;
return new BookmarksAddParams(this.channelId, this.title, this.type, value, this.entityId, this.link, this.parentId);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link BookmarksAddParamsIF#getEntityId() entityId} attribute.
* @param value The value for entityId, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BookmarksAddParams withEntityId(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.entityId, newValue)) return this;
return new BookmarksAddParams(this.channelId, this.title, this.type, this.emoji, newValue, this.link, this.parentId);
}
/**
* Copy the current immutable object by setting an optional value for the {@link BookmarksAddParamsIF#getEntityId() entityId} 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 entityId
* @return A modified copy of {@code this} object
*/
public final BookmarksAddParams withEntityId(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.entityId, value)) return this;
return new BookmarksAddParams(this.channelId, this.title, this.type, this.emoji, value, this.link, this.parentId);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link BookmarksAddParamsIF#getLink() link} attribute.
* @param value The value for link, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BookmarksAddParams withLink(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.link, newValue)) return this;
return new BookmarksAddParams(this.channelId, this.title, this.type, this.emoji, this.entityId, newValue, this.parentId);
}
/**
* Copy the current immutable object by setting an optional value for the {@link BookmarksAddParamsIF#getLink() link} 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 link
* @return A modified copy of {@code this} object
*/
public final BookmarksAddParams withLink(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.link, value)) return this;
return new BookmarksAddParams(this.channelId, this.title, this.type, this.emoji, this.entityId, value, this.parentId);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link BookmarksAddParamsIF#getParentId() parentId} attribute.
* @param value The value for parentId, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final BookmarksAddParams withParentId(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.parentId, newValue)) return this;
return new BookmarksAddParams(this.channelId, this.title, this.type, this.emoji, this.entityId, this.link, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link BookmarksAddParamsIF#getParentId() parentId} 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 parentId
* @return A modified copy of {@code this} object
*/
public final BookmarksAddParams withParentId(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.parentId, value)) return this;
return new BookmarksAddParams(this.channelId, this.title, this.type, this.emoji, this.entityId, this.link, value);
}
/**
* This instance is equal to all instances of {@code BookmarksAddParams} 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 BookmarksAddParams
&& equalTo(0, (BookmarksAddParams) another);
}
private boolean equalTo(int synthetic, BookmarksAddParams another) {
return channelId.equals(another.channelId)
&& channel.equals(another.channel)
&& title.equals(another.title)
&& type.equals(another.type)
&& Objects.equals(emoji, another.emoji)
&& Objects.equals(entityId, another.entityId)
&& Objects.equals(link, another.link)
&& Objects.equals(parentId, another.parentId);
}
/**
* Computes a hash code from attributes: {@code channelId}, {@code channel}, {@code title}, {@code type}, {@code emoji}, {@code entityId}, {@code link}, {@code parentId}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + channelId.hashCode();
h += (h << 5) + channel.hashCode();
h += (h << 5) + title.hashCode();
h += (h << 5) + type.hashCode();
h += (h << 5) + Objects.hashCode(emoji);
h += (h << 5) + Objects.hashCode(entityId);
h += (h << 5) + Objects.hashCode(link);
h += (h << 5) + Objects.hashCode(parentId);
return h;
}
/**
* Prints the immutable value {@code BookmarksAddParams} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("BookmarksAddParams{");
builder.append("channelId=").append(channelId);
builder.append(", ");
builder.append("channel=").append(channel);
builder.append(", ");
builder.append("title=").append(title);
builder.append(", ");
builder.append("type=").append(type);
if (emoji != null) {
builder.append(", ");
builder.append("emoji=").append(emoji);
}
if (entityId != null) {
builder.append(", ");
builder.append("entityId=").append(entityId);
}
if (link != null) {
builder.append(", ");
builder.append("link=").append(link);
}
if (parentId != null) {
builder.append(", ");
builder.append("parentId=").append(parentId);
}
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 = "BookmarksAddParamsIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements BookmarksAddParamsIF {
@Nullable String channelId;
@Nullable String title;
@Nullable BookmarkType type;
@Nullable Optional emoji = Optional.empty();
@Nullable Optional entityId = Optional.empty();
@Nullable Optional link = Optional.empty();
@Nullable Optional parentId = Optional.empty();
@JsonProperty
public void setChannelId(String channelId) {
this.channelId = channelId;
}
@JsonProperty
public void setTitle(String title) {
this.title = title;
}
@JsonProperty
public void setType(BookmarkType type) {
this.type = type;
}
@JsonProperty
public void setEmoji(Optional emoji) {
this.emoji = emoji;
}
@JsonProperty
public void setEntityId(Optional entityId) {
this.entityId = entityId;
}
@JsonProperty
public void setLink(Optional link) {
this.link = link;
}
@JsonProperty
public void setParentId(Optional parentId) {
this.parentId = parentId;
}
@Override
public String getChannelId() { throw new UnsupportedOperationException(); }
@JsonIgnore
@Override
public String getChannel() { throw new UnsupportedOperationException(); }
@Override
public String getTitle() { throw new UnsupportedOperationException(); }
@Override
public BookmarkType getType() { throw new UnsupportedOperationException(); }
@Override
public Optional getEmoji() { throw new UnsupportedOperationException(); }
@Override
public Optional getEntityId() { throw new UnsupportedOperationException(); }
@Override
public Optional getLink() { throw new UnsupportedOperationException(); }
@Override
public Optional getParentId() { 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 BookmarksAddParams fromJson(Json json) {
BookmarksAddParams.Builder builder = BookmarksAddParams.builder();
if (json.channelId != null) {
builder.setChannelId(json.channelId);
}
if (json.title != null) {
builder.setTitle(json.title);
}
if (json.type != null) {
builder.setType(json.type);
}
if (json.emoji != null) {
builder.setEmoji(json.emoji);
}
if (json.entityId != null) {
builder.setEntityId(json.entityId);
}
if (json.link != null) {
builder.setLink(json.link);
}
if (json.parentId != null) {
builder.setParentId(json.parentId);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link BookmarksAddParamsIF} 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 BookmarksAddParams instance
*/
public static BookmarksAddParams copyOf(BookmarksAddParamsIF instance) {
if (instance instanceof BookmarksAddParams) {
return (BookmarksAddParams) instance;
}
return BookmarksAddParams.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link BookmarksAddParams BookmarksAddParams}.
*
* BookmarksAddParams.builder()
* .setChannelId(String) // required {@link BookmarksAddParamsIF#getChannelId() channelId}
* .setTitle(String) // required {@link BookmarksAddParamsIF#getTitle() title}
* .setType(com.hubspot.slack.client.models.bookmarks.BookmarkType) // required {@link BookmarksAddParamsIF#getType() type}
* .setEmoji(String) // optional {@link BookmarksAddParamsIF#getEmoji() emoji}
* .setEntityId(String) // optional {@link BookmarksAddParamsIF#getEntityId() entityId}
* .setLink(String) // optional {@link BookmarksAddParamsIF#getLink() link}
* .setParentId(String) // optional {@link BookmarksAddParamsIF#getParentId() parentId}
* .build();
*
* @return A new BookmarksAddParams builder
*/
public static BookmarksAddParams.Builder builder() {
return new BookmarksAddParams.Builder();
}
/**
* Builds instances of type {@link BookmarksAddParams BookmarksAddParams}.
* 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 = "BookmarksAddParamsIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_CHANNEL_ID = 0x1L;
private static final long INIT_BIT_TITLE = 0x2L;
private static final long INIT_BIT_TYPE = 0x4L;
private long initBits = 0x7L;
private @Nullable String channelId;
private @Nullable String title;
private @Nullable BookmarkType type;
private @Nullable String emoji;
private @Nullable String entityId;
private @Nullable String link;
private @Nullable String parentId;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.methods.interceptor.HasChannel} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(HasChannel 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.bookmarks.BookmarksAddParamsIF} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(BookmarksAddParamsIF 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 HasChannel) {
HasChannel instance = (HasChannel) object;
if ((bits & 0x1L) == 0) {
this.setChannelId(instance.getChannelId());
bits |= 0x1L;
}
}
if (object instanceof BookmarksAddParamsIF) {
BookmarksAddParamsIF instance = (BookmarksAddParamsIF) object;
Optional emojiOptional = instance.getEmoji();
if (emojiOptional.isPresent()) {
setEmoji(emojiOptional);
}
Optional linkOptional = instance.getLink();
if (linkOptional.isPresent()) {
setLink(linkOptional);
}
Optional entityIdOptional = instance.getEntityId();
if (entityIdOptional.isPresent()) {
setEntityId(entityIdOptional);
}
this.setTitle(instance.getTitle());
this.setType(instance.getType());
Optional parentIdOptional = instance.getParentId();
if (parentIdOptional.isPresent()) {
setParentId(parentIdOptional);
}
if ((bits & 0x1L) == 0) {
this.setChannelId(instance.getChannelId());
bits |= 0x1L;
}
}
}
/**
* Initializes the value for the {@link BookmarksAddParamsIF#getChannelId() channelId} attribute.
* @param channelId The value for channelId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setChannelId(String channelId) {
this.channelId = Objects.requireNonNull(channelId, "channelId");
initBits &= ~INIT_BIT_CHANNEL_ID;
return this;
}
/**
* Initializes the value for the {@link BookmarksAddParamsIF#getTitle() title} attribute.
* @param title The value for title
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setTitle(String title) {
this.title = Objects.requireNonNull(title, "title");
initBits &= ~INIT_BIT_TITLE;
return this;
}
/**
* Initializes the value for the {@link BookmarksAddParamsIF#getType() type} attribute.
* @param type The value for type
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setType(BookmarkType type) {
this.type = Objects.requireNonNull(type, "type");
initBits &= ~INIT_BIT_TYPE;
return this;
}
/**
* Initializes the optional value {@link BookmarksAddParamsIF#getEmoji() emoji} to emoji.
* @param emoji The value for emoji, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setEmoji(@Nullable String emoji) {
this.emoji = emoji;
return this;
}
/**
* Initializes the optional value {@link BookmarksAddParamsIF#getEmoji() emoji} to emoji.
* @param emoji The value for emoji
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setEmoji(Optional emoji) {
this.emoji = emoji.orElse(null);
return this;
}
/**
* Initializes the optional value {@link BookmarksAddParamsIF#getEntityId() entityId} to entityId.
* @param entityId The value for entityId, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setEntityId(@Nullable String entityId) {
this.entityId = entityId;
return this;
}
/**
* Initializes the optional value {@link BookmarksAddParamsIF#getEntityId() entityId} to entityId.
* @param entityId The value for entityId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setEntityId(Optional entityId) {
this.entityId = entityId.orElse(null);
return this;
}
/**
* Initializes the optional value {@link BookmarksAddParamsIF#getLink() link} to link.
* @param link The value for link, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setLink(@Nullable String link) {
this.link = link;
return this;
}
/**
* Initializes the optional value {@link BookmarksAddParamsIF#getLink() link} to link.
* @param link The value for link
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setLink(Optional link) {
this.link = link.orElse(null);
return this;
}
/**
* Initializes the optional value {@link BookmarksAddParamsIF#getParentId() parentId} to parentId.
* @param parentId The value for parentId, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setParentId(@Nullable String parentId) {
this.parentId = parentId;
return this;
}
/**
* Initializes the optional value {@link BookmarksAddParamsIF#getParentId() parentId} to parentId.
* @param parentId The value for parentId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setParentId(Optional parentId) {
this.parentId = parentId.orElse(null);
return this;
}
/**
* Builds a new {@link BookmarksAddParams BookmarksAddParams}.
* @return An immutable instance of BookmarksAddParams
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public BookmarksAddParams build() {
checkRequiredAttributes();
return new BookmarksAddParams(channelId, title, type, emoji, entityId, link, parentId);
}
private boolean channelIdIsSet() {
return (initBits & INIT_BIT_CHANNEL_ID) == 0;
}
private boolean titleIsSet() {
return (initBits & INIT_BIT_TITLE) == 0;
}
private boolean typeIsSet() {
return (initBits & INIT_BIT_TYPE) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!channelIdIsSet()) attributes.add("channelId");
if (!titleIsSet()) attributes.add("title");
if (!typeIsSet()) attributes.add("type");
return "Cannot build BookmarksAddParams, some of required attributes are not set " + attributes;
}
}
}