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