
com.hubspot.slack.client.models.LiteMessage Maven / Gradle / Ivy
package com.hubspot.slack.client.models;
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 com.hubspot.slack.client.models.blocks.Block;
import com.hubspot.slack.client.models.files.SlackFile;
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 LiteMessageIF}.
*
* Use the builder to create immutable instances:
* {@code LiteMessage.builder()}.
*/
@Generated(from = "LiteMessageIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class LiteMessage implements LiteMessageIF {
private final String type;
private final @Nullable String subtype;
private final @Nullable String user;
private final @Nullable String botId;
private final @Nullable String username;
private final String text;
private final List attachments;
private final List files;
private final List blocks;
private final List reactions;
private final String timestamp;
private final @Nullable String threadTimestamp;
private final @Nullable Integer replyCount;
private final @Nullable List replyUserIds;
private final @Nullable Integer replyUsersCount;
private final @Nullable String latestReplyTimestamp;
private LiteMessage(
String type,
@Nullable String subtype,
@Nullable String user,
@Nullable String botId,
@Nullable String username,
String text,
List attachments,
List files,
List blocks,
List reactions,
String timestamp,
@Nullable String threadTimestamp,
@Nullable Integer replyCount,
@Nullable List replyUserIds,
@Nullable Integer replyUsersCount,
@Nullable String latestReplyTimestamp) {
this.type = type;
this.subtype = subtype;
this.user = user;
this.botId = botId;
this.username = username;
this.text = text;
this.attachments = attachments;
this.files = files;
this.blocks = blocks;
this.reactions = reactions;
this.timestamp = timestamp;
this.threadTimestamp = threadTimestamp;
this.replyCount = replyCount;
this.replyUserIds = replyUserIds;
this.replyUsersCount = replyUsersCount;
this.latestReplyTimestamp = latestReplyTimestamp;
}
/**
* @return The value of the {@code type} attribute
*/
@JsonProperty
@Override
public String getType() {
return type;
}
/**
* @return The value of the {@code subtype} attribute
*/
@JsonProperty
@Override
public Optional getSubtype() {
return Optional.ofNullable(subtype);
}
/**
* @return The value of the {@code user} attribute
*/
@JsonProperty
@Override
public Optional getUser() {
return Optional.ofNullable(user);
}
/**
* @return The value of the {@code botId} attribute
*/
@JsonProperty
@Override
public Optional getBotId() {
return Optional.ofNullable(botId);
}
/**
* @return The value of the {@code username} attribute
*/
@JsonProperty
@Override
public Optional getUsername() {
return Optional.ofNullable(username);
}
/**
* @return The value of the {@code text} attribute
*/
@JsonProperty
@Override
public String getText() {
return text;
}
/**
* @return The value of the {@code attachments} attribute
*/
@JsonProperty
@Override
public List getAttachments() {
return attachments;
}
/**
* @return The value of the {@code files} attribute
*/
@JsonProperty
@Override
public List getFiles() {
return files;
}
/**
* @return The value of the {@code blocks} attribute
*/
@JsonProperty
@Override
public List getBlocks() {
return blocks;
}
/**
* @return The value of the {@code reactions} attribute
*/
@JsonProperty
@Override
public List getReactions() {
return reactions;
}
/**
* @return The value of the {@code timestamp} attribute
*/
@JsonProperty("ts")
@Override
public String getTimestamp() {
return timestamp;
}
/**
* @return The value of the {@code threadTimestamp} attribute
*/
@JsonProperty("thread_ts")
@Override
public Optional getThreadTimestamp() {
return Optional.ofNullable(threadTimestamp);
}
/**
* @return The value of the {@code replyCount} attribute
*/
@JsonProperty
@Override
public Optional getReplyCount() {
return Optional.ofNullable(replyCount);
}
/**
* @return The value of the {@code replyUserIds} attribute
*/
@JsonProperty("reply_users")
@Override
public Optional> getReplyUserIds() {
return Optional.ofNullable(replyUserIds);
}
/**
* @return The value of the {@code replyUsersCount} attribute
*/
@JsonProperty
@Override
public Optional getReplyUsersCount() {
return Optional.ofNullable(replyUsersCount);
}
/**
* @return The value of the {@code latestReplyTimestamp} attribute
*/
@JsonProperty("latest_reply")
@Override
public Optional getLatestReplyTimestamp() {
return Optional.ofNullable(latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a value for the {@link LiteMessageIF#getType() type} attribute.
* An equals check 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 LiteMessage withType(String value) {
String newValue = Objects.requireNonNull(value, "type");
if (this.type.equals(newValue)) return this;
return new LiteMessage(
newValue,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link LiteMessageIF#getSubtype() subtype} attribute.
* @param value The value for subtype, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final LiteMessage withSubtype(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.subtype, newValue)) return this;
return new LiteMessage(
this.type,
newValue,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting an optional value for the {@link LiteMessageIF#getSubtype() subtype} 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 subtype
* @return A modified copy of {@code this} object
*/
public final LiteMessage withSubtype(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.subtype, value)) return this;
return new LiteMessage(
this.type,
value,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link LiteMessageIF#getUser() user} attribute.
* @param value The value for user, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final LiteMessage withUser(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.user, newValue)) return this;
return new LiteMessage(
this.type,
this.subtype,
newValue,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting an optional value for the {@link LiteMessageIF#getUser() user} 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 user
* @return A modified copy of {@code this} object
*/
public final LiteMessage withUser(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.user, value)) return this;
return new LiteMessage(
this.type,
this.subtype,
value,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link LiteMessageIF#getBotId() botId} attribute.
* @param value The value for botId, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final LiteMessage withBotId(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.botId, newValue)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
newValue,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting an optional value for the {@link LiteMessageIF#getBotId() botId} 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 botId
* @return A modified copy of {@code this} object
*/
public final LiteMessage withBotId(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.botId, value)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
value,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link LiteMessageIF#getUsername() username} attribute.
* @param value The value for username, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final LiteMessage withUsername(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.username, newValue)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
newValue,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting an optional value for the {@link LiteMessageIF#getUsername() username} 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 username
* @return A modified copy of {@code this} object
*/
public final LiteMessage withUsername(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.username, value)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
value,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a value for the {@link LiteMessageIF#getText() text} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for text
* @return A modified copy of the {@code this} object
*/
public final LiteMessage withText(String value) {
String newValue = Objects.requireNonNull(value, "text");
if (this.text.equals(newValue)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
newValue,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object with elements that replace the content of {@link LiteMessageIF#getAttachments() attachments}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final LiteMessage withAttachments(Attachment... elements) {
List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false));
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
newValue,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object with elements that replace the content of {@link LiteMessageIF#getAttachments() attachments}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of attachments elements to set
* @return A modified copy of {@code this} object
*/
public final LiteMessage withAttachments(Iterable extends Attachment> elements) {
if (this.attachments == elements) return this;
List newValue = createUnmodifiableList(false, createSafeList(elements, true, false));
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
newValue,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object with elements that replace the content of {@link LiteMessageIF#getFiles() files}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final LiteMessage withFiles(SlackFile... elements) {
List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false));
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
newValue,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object with elements that replace the content of {@link LiteMessageIF#getFiles() files}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of files elements to set
* @return A modified copy of {@code this} object
*/
public final LiteMessage withFiles(Iterable extends SlackFile> elements) {
if (this.files == elements) return this;
List newValue = createUnmodifiableList(false, createSafeList(elements, true, false));
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
newValue,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object with elements that replace the content of {@link LiteMessageIF#getBlocks() blocks}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final LiteMessage withBlocks(Block... elements) {
List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false));
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
newValue,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object with elements that replace the content of {@link LiteMessageIF#getBlocks() blocks}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of blocks elements to set
* @return A modified copy of {@code this} object
*/
public final LiteMessage withBlocks(Iterable extends Block> elements) {
if (this.blocks == elements) return this;
List newValue = createUnmodifiableList(false, createSafeList(elements, true, false));
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
newValue,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object with elements that replace the content of {@link LiteMessageIF#getReactions() reactions}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final LiteMessage withReactions(Reaction... elements) {
List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false));
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
newValue,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object with elements that replace the content of {@link LiteMessageIF#getReactions() reactions}.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param elements An iterable of reactions elements to set
* @return A modified copy of {@code this} object
*/
public final LiteMessage withReactions(Iterable extends Reaction> elements) {
if (this.reactions == elements) return this;
List newValue = createUnmodifiableList(false, createSafeList(elements, true, false));
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
newValue,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a value for the {@link LiteMessageIF#getTimestamp() timestamp} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for timestamp
* @return A modified copy of the {@code this} object
*/
public final LiteMessage withTimestamp(String value) {
String newValue = Objects.requireNonNull(value, "timestamp");
if (this.timestamp.equals(newValue)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
newValue,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link LiteMessageIF#getThreadTimestamp() threadTimestamp} attribute.
* @param value The value for threadTimestamp, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final LiteMessage withThreadTimestamp(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.threadTimestamp, newValue)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
newValue,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting an optional value for the {@link LiteMessageIF#getThreadTimestamp() threadTimestamp} 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 threadTimestamp
* @return A modified copy of {@code this} object
*/
public final LiteMessage withThreadTimestamp(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.threadTimestamp, value)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
value,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link LiteMessageIF#getReplyCount() replyCount} attribute.
* @param value The value for replyCount, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final LiteMessage withReplyCount(@Nullable Integer value) {
@Nullable Integer newValue = value;
if (Objects.equals(this.replyCount, newValue)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
newValue,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting an optional value for the {@link LiteMessageIF#getReplyCount() replyCount} 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 replyCount
* @return A modified copy of {@code this} object
*/
public final LiteMessage withReplyCount(Optional optional) {
@Nullable Integer value = optional.orElse(null);
if (Objects.equals(this.replyCount, value)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
value,
this.replyUserIds,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link LiteMessageIF#getReplyUserIds() replyUserIds} attribute.
* @param value The value for replyUserIds, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final LiteMessage withReplyUserIds(@Nullable List value) {
@Nullable List newValue = value;
if (this.replyUserIds == newValue) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
newValue,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting an optional value for the {@link LiteMessageIF#getReplyUserIds() replyUserIds} attribute.
* A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}.
* @param optional A value for replyUserIds
* @return A modified copy of {@code this} object
*/
@SuppressWarnings("unchecked") // safe covariant cast
public final LiteMessage withReplyUserIds(Optional extends List> optional) {
@Nullable List value = optional.orElse(null);
if (this.replyUserIds == value) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
value,
this.replyUsersCount,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link LiteMessageIF#getReplyUsersCount() replyUsersCount} attribute.
* @param value The value for replyUsersCount, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final LiteMessage withReplyUsersCount(@Nullable Integer value) {
@Nullable Integer newValue = value;
if (Objects.equals(this.replyUsersCount, newValue)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
newValue,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting an optional value for the {@link LiteMessageIF#getReplyUsersCount() replyUsersCount} 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 replyUsersCount
* @return A modified copy of {@code this} object
*/
public final LiteMessage withReplyUsersCount(Optional optional) {
@Nullable Integer value = optional.orElse(null);
if (Objects.equals(this.replyUsersCount, value)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
value,
this.latestReplyTimestamp);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link LiteMessageIF#getLatestReplyTimestamp() latestReplyTimestamp} attribute.
* @param value The value for latestReplyTimestamp, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final LiteMessage withLatestReplyTimestamp(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.latestReplyTimestamp, newValue)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link LiteMessageIF#getLatestReplyTimestamp() latestReplyTimestamp} 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 latestReplyTimestamp
* @return A modified copy of {@code this} object
*/
public final LiteMessage withLatestReplyTimestamp(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.latestReplyTimestamp, value)) return this;
return new LiteMessage(
this.type,
this.subtype,
this.user,
this.botId,
this.username,
this.text,
this.attachments,
this.files,
this.blocks,
this.reactions,
this.timestamp,
this.threadTimestamp,
this.replyCount,
this.replyUserIds,
this.replyUsersCount,
value);
}
/**
* This instance is equal to all instances of {@code LiteMessage} 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 LiteMessage
&& equalTo(0, (LiteMessage) another);
}
private boolean equalTo(int synthetic, LiteMessage another) {
return type.equals(another.type)
&& Objects.equals(subtype, another.subtype)
&& Objects.equals(user, another.user)
&& Objects.equals(botId, another.botId)
&& Objects.equals(username, another.username)
&& text.equals(another.text)
&& attachments.equals(another.attachments)
&& files.equals(another.files)
&& blocks.equals(another.blocks)
&& reactions.equals(another.reactions)
&& timestamp.equals(another.timestamp)
&& Objects.equals(threadTimestamp, another.threadTimestamp)
&& Objects.equals(replyCount, another.replyCount)
&& Objects.equals(replyUserIds, another.replyUserIds)
&& Objects.equals(replyUsersCount, another.replyUsersCount)
&& Objects.equals(latestReplyTimestamp, another.latestReplyTimestamp);
}
/**
* Computes a hash code from attributes: {@code type}, {@code subtype}, {@code user}, {@code botId}, {@code username}, {@code text}, {@code attachments}, {@code files}, {@code blocks}, {@code reactions}, {@code timestamp}, {@code threadTimestamp}, {@code replyCount}, {@code replyUserIds}, {@code replyUsersCount}, {@code latestReplyTimestamp}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + type.hashCode();
h += (h << 5) + Objects.hashCode(subtype);
h += (h << 5) + Objects.hashCode(user);
h += (h << 5) + Objects.hashCode(botId);
h += (h << 5) + Objects.hashCode(username);
h += (h << 5) + text.hashCode();
h += (h << 5) + attachments.hashCode();
h += (h << 5) + files.hashCode();
h += (h << 5) + blocks.hashCode();
h += (h << 5) + reactions.hashCode();
h += (h << 5) + timestamp.hashCode();
h += (h << 5) + Objects.hashCode(threadTimestamp);
h += (h << 5) + Objects.hashCode(replyCount);
h += (h << 5) + Objects.hashCode(replyUserIds);
h += (h << 5) + Objects.hashCode(replyUsersCount);
h += (h << 5) + Objects.hashCode(latestReplyTimestamp);
return h;
}
/**
* Prints the immutable value {@code LiteMessage} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("LiteMessage{");
builder.append("type=").append(type);
if (subtype != null) {
builder.append(", ");
builder.append("subtype=").append(subtype);
}
if (user != null) {
builder.append(", ");
builder.append("user=").append(user);
}
if (botId != null) {
builder.append(", ");
builder.append("botId=").append(botId);
}
if (username != null) {
builder.append(", ");
builder.append("username=").append(username);
}
builder.append(", ");
builder.append("text=").append(text);
builder.append(", ");
builder.append("attachments=").append(attachments);
builder.append(", ");
builder.append("files=").append(files);
builder.append(", ");
builder.append("blocks=").append(blocks);
builder.append(", ");
builder.append("reactions=").append(reactions);
builder.append(", ");
builder.append("timestamp=").append(timestamp);
if (threadTimestamp != null) {
builder.append(", ");
builder.append("threadTimestamp=").append(threadTimestamp);
}
if (replyCount != null) {
builder.append(", ");
builder.append("replyCount=").append(replyCount);
}
if (replyUserIds != null) {
builder.append(", ");
builder.append("replyUserIds=").append(replyUserIds);
}
if (replyUsersCount != null) {
builder.append(", ");
builder.append("replyUsersCount=").append(replyUsersCount);
}
if (latestReplyTimestamp != null) {
builder.append(", ");
builder.append("latestReplyTimestamp=").append(latestReplyTimestamp);
}
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 = "LiteMessageIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements LiteMessageIF {
@Nullable String type;
@Nullable Optional subtype = Optional.empty();
@Nullable Optional user = Optional.empty();
@Nullable Optional botId = Optional.empty();
@Nullable Optional username = Optional.empty();
@Nullable String text;
@Nullable List attachments = Collections.emptyList();
@Nullable List files = Collections.emptyList();
@Nullable List blocks = Collections.emptyList();
@Nullable List reactions = Collections.emptyList();
@Nullable String timestamp;
@Nullable Optional threadTimestamp = Optional.empty();
@Nullable Optional replyCount = Optional.empty();
@Nullable Optional> replyUserIds = Optional.empty();
@Nullable Optional replyUsersCount = Optional.empty();
@Nullable Optional latestReplyTimestamp = Optional.empty();
@JsonProperty
public void setType(String type) {
this.type = type;
}
@JsonProperty
public void setSubtype(Optional subtype) {
this.subtype = subtype;
}
@JsonProperty
public void setUser(Optional user) {
this.user = user;
}
@JsonProperty
public void setBotId(Optional botId) {
this.botId = botId;
}
@JsonProperty
public void setUsername(Optional username) {
this.username = username;
}
@JsonProperty
public void setText(String text) {
this.text = text;
}
@JsonProperty
public void setAttachments(List attachments) {
this.attachments = attachments;
}
@JsonProperty
public void setFiles(List files) {
this.files = files;
}
@JsonProperty
public void setBlocks(List blocks) {
this.blocks = blocks;
}
@JsonProperty
public void setReactions(List reactions) {
this.reactions = reactions;
}
@JsonProperty("ts")
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
@JsonProperty("thread_ts")
public void setThreadTimestamp(Optional threadTimestamp) {
this.threadTimestamp = threadTimestamp;
}
@JsonProperty
public void setReplyCount(Optional replyCount) {
this.replyCount = replyCount;
}
@JsonProperty("reply_users")
public void setReplyUserIds(Optional> replyUserIds) {
this.replyUserIds = replyUserIds;
}
@JsonProperty
public void setReplyUsersCount(Optional replyUsersCount) {
this.replyUsersCount = replyUsersCount;
}
@JsonProperty("latest_reply")
public void setLatestReplyTimestamp(Optional latestReplyTimestamp) {
this.latestReplyTimestamp = latestReplyTimestamp;
}
@Override
public String getType() { throw new UnsupportedOperationException(); }
@Override
public Optional getSubtype() { throw new UnsupportedOperationException(); }
@Override
public Optional getUser() { throw new UnsupportedOperationException(); }
@Override
public Optional getBotId() { throw new UnsupportedOperationException(); }
@Override
public Optional getUsername() { throw new UnsupportedOperationException(); }
@Override
public String getText() { throw new UnsupportedOperationException(); }
@Override
public List getAttachments() { throw new UnsupportedOperationException(); }
@Override
public List getFiles() { throw new UnsupportedOperationException(); }
@Override
public List getBlocks() { throw new UnsupportedOperationException(); }
@Override
public List getReactions() { throw new UnsupportedOperationException(); }
@Override
public String getTimestamp() { throw new UnsupportedOperationException(); }
@Override
public Optional getThreadTimestamp() { throw new UnsupportedOperationException(); }
@Override
public Optional getReplyCount() { throw new UnsupportedOperationException(); }
@Override
public Optional> getReplyUserIds() { throw new UnsupportedOperationException(); }
@Override
public Optional getReplyUsersCount() { throw new UnsupportedOperationException(); }
@Override
public Optional getLatestReplyTimestamp() { 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 LiteMessage fromJson(Json json) {
LiteMessage.Builder builder = LiteMessage.builder();
if (json.type != null) {
builder.setType(json.type);
}
if (json.subtype != null) {
builder.setSubtype(json.subtype);
}
if (json.user != null) {
builder.setUser(json.user);
}
if (json.botId != null) {
builder.setBotId(json.botId);
}
if (json.username != null) {
builder.setUsername(json.username);
}
if (json.text != null) {
builder.setText(json.text);
}
if (json.attachments != null) {
builder.addAllAttachments(json.attachments);
}
if (json.files != null) {
builder.addAllFiles(json.files);
}
if (json.blocks != null) {
builder.addAllBlocks(json.blocks);
}
if (json.reactions != null) {
builder.addAllReactions(json.reactions);
}
if (json.timestamp != null) {
builder.setTimestamp(json.timestamp);
}
if (json.threadTimestamp != null) {
builder.setThreadTimestamp(json.threadTimestamp);
}
if (json.replyCount != null) {
builder.setReplyCount(json.replyCount);
}
if (json.replyUserIds != null) {
builder.setReplyUserIds(json.replyUserIds);
}
if (json.replyUsersCount != null) {
builder.setReplyUsersCount(json.replyUsersCount);
}
if (json.latestReplyTimestamp != null) {
builder.setLatestReplyTimestamp(json.latestReplyTimestamp);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link LiteMessageIF} 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 LiteMessage instance
*/
public static LiteMessage copyOf(LiteMessageIF instance) {
if (instance instanceof LiteMessage) {
return (LiteMessage) instance;
}
return LiteMessage.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link LiteMessage LiteMessage}.
*
* LiteMessage.builder()
* .setType(String) // required {@link LiteMessageIF#getType() type}
* .setSubtype(String) // optional {@link LiteMessageIF#getSubtype() subtype}
* .setUser(String) // optional {@link LiteMessageIF#getUser() user}
* .setBotId(String) // optional {@link LiteMessageIF#getBotId() botId}
* .setUsername(String) // optional {@link LiteMessageIF#getUsername() username}
* .setText(String) // required {@link LiteMessageIF#getText() text}
* .addAttachments|addAllAttachments(Attachment) // {@link LiteMessageIF#getAttachments() attachments} elements
* .addFiles|addAllFiles(com.hubspot.slack.client.models.files.SlackFile) // {@link LiteMessageIF#getFiles() files} elements
* .addBlocks|addAllBlocks(com.hubspot.slack.client.models.blocks.Block) // {@link LiteMessageIF#getBlocks() blocks} elements
* .addReactions|addAllReactions(Reaction) // {@link LiteMessageIF#getReactions() reactions} elements
* .setTimestamp(String) // required {@link LiteMessageIF#getTimestamp() timestamp}
* .setThreadTimestamp(String) // optional {@link LiteMessageIF#getThreadTimestamp() threadTimestamp}
* .setReplyCount(Integer) // optional {@link LiteMessageIF#getReplyCount() replyCount}
* .setReplyUserIds(List<String>) // optional {@link LiteMessageIF#getReplyUserIds() replyUserIds}
* .setReplyUsersCount(Integer) // optional {@link LiteMessageIF#getReplyUsersCount() replyUsersCount}
* .setLatestReplyTimestamp(String) // optional {@link LiteMessageIF#getLatestReplyTimestamp() latestReplyTimestamp}
* .build();
*
* @return A new LiteMessage builder
*/
public static LiteMessage.Builder builder() {
return new LiteMessage.Builder();
}
/**
* Builds instances of type {@link LiteMessage LiteMessage}.
* 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 = "LiteMessageIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_TYPE = 0x1L;
private static final long INIT_BIT_TEXT = 0x2L;
private static final long INIT_BIT_TIMESTAMP = 0x4L;
private long initBits = 0x7L;
private @Nullable String type;
private @Nullable String subtype;
private @Nullable String user;
private @Nullable String botId;
private @Nullable String username;
private @Nullable String text;
private List attachments = new ArrayList();
private List files = new ArrayList();
private List blocks = new ArrayList();
private List reactions = new ArrayList();
private @Nullable String timestamp;
private @Nullable String threadTimestamp;
private @Nullable Integer replyCount;
private @Nullable List replyUserIds;
private @Nullable Integer replyUsersCount;
private @Nullable String latestReplyTimestamp;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code LiteMessageIF} instance.
* Regular attribute values will be replaced with those from the given instance.
* Absent optional values will not replace present values.
* Collection elements and entries will be added, not replaced.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(LiteMessageIF instance) {
Objects.requireNonNull(instance, "instance");
this.setType(instance.getType());
Optional subtypeOptional = instance.getSubtype();
if (subtypeOptional.isPresent()) {
setSubtype(subtypeOptional);
}
Optional userOptional = instance.getUser();
if (userOptional.isPresent()) {
setUser(userOptional);
}
Optional botIdOptional = instance.getBotId();
if (botIdOptional.isPresent()) {
setBotId(botIdOptional);
}
Optional usernameOptional = instance.getUsername();
if (usernameOptional.isPresent()) {
setUsername(usernameOptional);
}
this.setText(instance.getText());
addAllAttachments(instance.getAttachments());
addAllFiles(instance.getFiles());
addAllBlocks(instance.getBlocks());
addAllReactions(instance.getReactions());
this.setTimestamp(instance.getTimestamp());
Optional threadTimestampOptional = instance.getThreadTimestamp();
if (threadTimestampOptional.isPresent()) {
setThreadTimestamp(threadTimestampOptional);
}
Optional replyCountOptional = instance.getReplyCount();
if (replyCountOptional.isPresent()) {
setReplyCount(replyCountOptional);
}
Optional> replyUserIdsOptional = instance.getReplyUserIds();
if (replyUserIdsOptional.isPresent()) {
setReplyUserIds(replyUserIdsOptional);
}
Optional replyUsersCountOptional = instance.getReplyUsersCount();
if (replyUsersCountOptional.isPresent()) {
setReplyUsersCount(replyUsersCountOptional);
}
Optional latestReplyTimestampOptional = instance.getLatestReplyTimestamp();
if (latestReplyTimestampOptional.isPresent()) {
setLatestReplyTimestamp(latestReplyTimestampOptional);
}
return this;
}
/**
* Initializes the value for the {@link LiteMessageIF#getType() type} attribute.
* @param type The value for type
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setType(String type) {
this.type = Objects.requireNonNull(type, "type");
initBits &= ~INIT_BIT_TYPE;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getSubtype() subtype} to subtype.
* @param subtype The value for subtype, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setSubtype(@Nullable String subtype) {
this.subtype = subtype;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getSubtype() subtype} to subtype.
* @param subtype The value for subtype
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setSubtype(Optional subtype) {
this.subtype = subtype.orElse(null);
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getUser() user} to user.
* @param user The value for user, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setUser(@Nullable String user) {
this.user = user;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getUser() user} to user.
* @param user The value for user
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setUser(Optional user) {
this.user = user.orElse(null);
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getBotId() botId} to botId.
* @param botId The value for botId, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setBotId(@Nullable String botId) {
this.botId = botId;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getBotId() botId} to botId.
* @param botId The value for botId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setBotId(Optional botId) {
this.botId = botId.orElse(null);
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getUsername() username} to username.
* @param username The value for username, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setUsername(@Nullable String username) {
this.username = username;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getUsername() username} to username.
* @param username The value for username
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setUsername(Optional username) {
this.username = username.orElse(null);
return this;
}
/**
* Initializes the value for the {@link LiteMessageIF#getText() text} attribute.
* @param text The value for text
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setText(String text) {
this.text = Objects.requireNonNull(text, "text");
initBits &= ~INIT_BIT_TEXT;
return this;
}
/**
* Adds one element to {@link LiteMessageIF#getAttachments() attachments} list.
* @param element A attachments element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAttachments(Attachment element) {
this.attachments.add(Objects.requireNonNull(element, "attachments element"));
return this;
}
/**
* Adds elements to {@link LiteMessageIF#getAttachments() attachments} list.
* @param elements An array of attachments elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAttachments(Attachment... elements) {
for (Attachment element : elements) {
this.attachments.add(Objects.requireNonNull(element, "attachments element"));
}
return this;
}
/**
* Sets or replaces all elements for {@link LiteMessageIF#getAttachments() attachments} list.
* @param elements An iterable of attachments elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setAttachments(Iterable extends Attachment> elements) {
this.attachments.clear();
return addAllAttachments(elements);
}
/**
* Adds elements to {@link LiteMessageIF#getAttachments() attachments} list.
* @param elements An iterable of attachments elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllAttachments(Iterable extends Attachment> elements) {
for (Attachment element : elements) {
this.attachments.add(Objects.requireNonNull(element, "attachments element"));
}
return this;
}
/**
* Adds one element to {@link LiteMessageIF#getFiles() files} list.
* @param element A files element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addFiles(SlackFile element) {
this.files.add(Objects.requireNonNull(element, "files element"));
return this;
}
/**
* Adds elements to {@link LiteMessageIF#getFiles() files} list.
* @param elements An array of files elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addFiles(SlackFile... elements) {
for (SlackFile element : elements) {
this.files.add(Objects.requireNonNull(element, "files element"));
}
return this;
}
/**
* Sets or replaces all elements for {@link LiteMessageIF#getFiles() files} list.
* @param elements An iterable of files elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setFiles(Iterable extends SlackFile> elements) {
this.files.clear();
return addAllFiles(elements);
}
/**
* Adds elements to {@link LiteMessageIF#getFiles() files} list.
* @param elements An iterable of files elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllFiles(Iterable extends SlackFile> elements) {
for (SlackFile element : elements) {
this.files.add(Objects.requireNonNull(element, "files element"));
}
return this;
}
/**
* Adds one element to {@link LiteMessageIF#getBlocks() blocks} list.
* @param element A blocks element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addBlocks(Block element) {
this.blocks.add(Objects.requireNonNull(element, "blocks element"));
return this;
}
/**
* Adds elements to {@link LiteMessageIF#getBlocks() blocks} list.
* @param elements An array of blocks elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addBlocks(Block... elements) {
for (Block element : elements) {
this.blocks.add(Objects.requireNonNull(element, "blocks element"));
}
return this;
}
/**
* Sets or replaces all elements for {@link LiteMessageIF#getBlocks() blocks} list.
* @param elements An iterable of blocks elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setBlocks(Iterable extends Block> elements) {
this.blocks.clear();
return addAllBlocks(elements);
}
/**
* Adds elements to {@link LiteMessageIF#getBlocks() blocks} list.
* @param elements An iterable of blocks elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllBlocks(Iterable extends Block> elements) {
for (Block element : elements) {
this.blocks.add(Objects.requireNonNull(element, "blocks element"));
}
return this;
}
/**
* Adds one element to {@link LiteMessageIF#getReactions() reactions} list.
* @param element A reactions element
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addReactions(Reaction element) {
this.reactions.add(Objects.requireNonNull(element, "reactions element"));
return this;
}
/**
* Adds elements to {@link LiteMessageIF#getReactions() reactions} list.
* @param elements An array of reactions elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addReactions(Reaction... elements) {
for (Reaction element : elements) {
this.reactions.add(Objects.requireNonNull(element, "reactions element"));
}
return this;
}
/**
* Sets or replaces all elements for {@link LiteMessageIF#getReactions() reactions} list.
* @param elements An iterable of reactions elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setReactions(Iterable extends Reaction> elements) {
this.reactions.clear();
return addAllReactions(elements);
}
/**
* Adds elements to {@link LiteMessageIF#getReactions() reactions} list.
* @param elements An iterable of reactions elements
* @return {@code this} builder for use in a chained invocation
*/
public final Builder addAllReactions(Iterable extends Reaction> elements) {
for (Reaction element : elements) {
this.reactions.add(Objects.requireNonNull(element, "reactions element"));
}
return this;
}
/**
* Initializes the value for the {@link LiteMessageIF#getTimestamp() timestamp} attribute.
* @param timestamp The value for timestamp
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setTimestamp(String timestamp) {
this.timestamp = Objects.requireNonNull(timestamp, "timestamp");
initBits &= ~INIT_BIT_TIMESTAMP;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getThreadTimestamp() threadTimestamp} to threadTimestamp.
* @param threadTimestamp The value for threadTimestamp, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setThreadTimestamp(@Nullable String threadTimestamp) {
this.threadTimestamp = threadTimestamp;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getThreadTimestamp() threadTimestamp} to threadTimestamp.
* @param threadTimestamp The value for threadTimestamp
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setThreadTimestamp(Optional threadTimestamp) {
this.threadTimestamp = threadTimestamp.orElse(null);
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getReplyCount() replyCount} to replyCount.
* @param replyCount The value for replyCount, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setReplyCount(@Nullable Integer replyCount) {
this.replyCount = replyCount;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getReplyCount() replyCount} to replyCount.
* @param replyCount The value for replyCount
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setReplyCount(Optional replyCount) {
this.replyCount = replyCount.orElse(null);
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getReplyUserIds() replyUserIds} to replyUserIds.
* @param replyUserIds The value for replyUserIds, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setReplyUserIds(@Nullable List replyUserIds) {
this.replyUserIds = replyUserIds;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getReplyUserIds() replyUserIds} to replyUserIds.
* @param replyUserIds The value for replyUserIds
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setReplyUserIds(Optional extends List> replyUserIds) {
this.replyUserIds = replyUserIds.orElse(null);
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getReplyUsersCount() replyUsersCount} to replyUsersCount.
* @param replyUsersCount The value for replyUsersCount, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setReplyUsersCount(@Nullable Integer replyUsersCount) {
this.replyUsersCount = replyUsersCount;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getReplyUsersCount() replyUsersCount} to replyUsersCount.
* @param replyUsersCount The value for replyUsersCount
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setReplyUsersCount(Optional replyUsersCount) {
this.replyUsersCount = replyUsersCount.orElse(null);
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getLatestReplyTimestamp() latestReplyTimestamp} to latestReplyTimestamp.
* @param latestReplyTimestamp The value for latestReplyTimestamp, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setLatestReplyTimestamp(@Nullable String latestReplyTimestamp) {
this.latestReplyTimestamp = latestReplyTimestamp;
return this;
}
/**
* Initializes the optional value {@link LiteMessageIF#getLatestReplyTimestamp() latestReplyTimestamp} to latestReplyTimestamp.
* @param latestReplyTimestamp The value for latestReplyTimestamp
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setLatestReplyTimestamp(Optional latestReplyTimestamp) {
this.latestReplyTimestamp = latestReplyTimestamp.orElse(null);
return this;
}
/**
* Builds a new {@link LiteMessage LiteMessage}.
* @return An immutable instance of LiteMessage
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public LiteMessage build() {
checkRequiredAttributes();
return new LiteMessage(
type,
subtype,
user,
botId,
username,
text,
createUnmodifiableList(true, attachments),
createUnmodifiableList(true, files),
createUnmodifiableList(true, blocks),
createUnmodifiableList(true, reactions),
timestamp,
threadTimestamp,
replyCount,
replyUserIds,
replyUsersCount,
latestReplyTimestamp);
}
private boolean typeIsSet() {
return (initBits & INIT_BIT_TYPE) == 0;
}
private boolean textIsSet() {
return (initBits & INIT_BIT_TEXT) == 0;
}
private boolean timestampIsSet() {
return (initBits & INIT_BIT_TIMESTAMP) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!typeIsSet()) attributes.add("type");
if (!textIsSet()) attributes.add("text");
if (!timestampIsSet()) attributes.add("timestamp");
return "Cannot build LiteMessage, 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);
}
}
}
}