All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hubspot.slack.client.models.events.util.SlackReplyMessage Maven / Gradle / Ivy

package com.hubspot.slack.client.models.events.util;

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.methods.interceptor.HasChannel;
import com.hubspot.slack.client.methods.interceptor.HasUser;
import com.hubspot.slack.client.models.Attachment;
import com.hubspot.slack.client.models.events.SlackEvent;
import com.hubspot.slack.client.models.events.SlackEventMessageBase;
import com.hubspot.slack.client.models.events.SlackEventType;
import com.hubspot.slack.client.models.events.SlackMessageSubtype;
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 AbstractSlackReplyMessage}.
 * 

* Use the builder to create immutable instances: * {@code SlackReplyMessage.builder()}. */ @Generated(from = "AbstractSlackReplyMessage", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class SlackReplyMessage extends AbstractSlackReplyMessage { private final SlackEventType type; private final String ts; private final @Nullable SlackMessageSubtype subtype; private final List attachments; private final String threadTs; private final String userId; private final String channelId; private final int replyCount; private final @Nullable List replyUserIds; private final @Nullable Integer replyUsersCount; private final @Nullable String latestReplyTimestamp; private SlackReplyMessage(SlackReplyMessage.Builder builder) { this.type = builder.type; this.ts = builder.ts; this.subtype = builder.subtype; this.attachments = createUnmodifiableList(true, builder.attachments); this.threadTs = builder.threadTs; this.userId = builder.userId; this.channelId = builder.channelId; this.replyUserIds = builder.replyUserIds; this.replyUsersCount = builder.replyUsersCount; this.latestReplyTimestamp = builder.latestReplyTimestamp; this.replyCount = builder.replyCountIsSet() ? builder.replyCount : super.getReplyCount(); } private SlackReplyMessage( SlackEventType type, String ts, @Nullable SlackMessageSubtype subtype, List attachments, String threadTs, String userId, String channelId, int replyCount, @Nullable List replyUserIds, @Nullable Integer replyUsersCount, @Nullable String latestReplyTimestamp) { this.type = type; this.ts = ts; this.subtype = subtype; this.attachments = attachments; this.threadTs = threadTs; this.userId = userId; this.channelId = channelId; this.replyCount = replyCount; this.replyUserIds = replyUserIds; this.replyUsersCount = replyUsersCount; this.latestReplyTimestamp = latestReplyTimestamp; } /** * @return The value of the {@code type} attribute */ @JsonProperty @Override public SlackEventType getType() { return type; } /** * @return The value of the {@code ts} attribute */ @JsonProperty @Override public String getTs() { return ts; } /** * @return The value of the {@code subtype} attribute */ @JsonProperty @Override public Optional getSubtype() { return Optional.ofNullable(subtype); } /** * @return The value of the {@code attachments} attribute */ @JsonProperty @Override public List getAttachments() { return attachments; } /** * @return The value of the {@code threadTs} attribute */ @JsonProperty @Override public String getThreadTs() { return threadTs; } /** * @return The value of the {@code userId} attribute */ @JsonProperty("user") @Override public String getUserId() { return userId; } /** * @return The value of the {@code channelId} attribute */ @JsonProperty("channel") @Override public String getChannelId() { return channelId; } /** * @return The value of the {@code replyCount} attribute */ @JsonProperty @Override public int getReplyCount() { return 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 AbstractSlackReplyMessage#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 SlackReplyMessage withType(SlackEventType value) { SlackEventType newValue = Objects.requireNonNull(value, "type"); if (this.type == newValue) return this; return new SlackReplyMessage( newValue, this.ts, this.subtype, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting a value for the {@link AbstractSlackReplyMessage#getTs() ts} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for ts * @return A modified copy of the {@code this} object */ public final SlackReplyMessage withTs(String value) { String newValue = Objects.requireNonNull(value, "ts"); if (this.ts.equals(newValue)) return this; return new SlackReplyMessage( this.type, newValue, this.subtype, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting a present value for the optional {@link AbstractSlackReplyMessage#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 SlackReplyMessage withSubtype(@Nullable SlackMessageSubtype value) { @Nullable SlackMessageSubtype newValue = value; if (this.subtype == newValue) return this; return new SlackReplyMessage( this.type, this.ts, newValue, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting an optional value for the {@link AbstractSlackReplyMessage#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 */ @SuppressWarnings("unchecked") // safe covariant cast public final SlackReplyMessage withSubtype(Optional optional) { @Nullable SlackMessageSubtype value = optional.orElse(null); if (this.subtype == value) return this; return new SlackReplyMessage( this.type, this.ts, value, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object with elements that replace the content of {@link AbstractSlackReplyMessage#getAttachments() attachments}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final SlackReplyMessage withAttachments(Attachment... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new SlackReplyMessage( this.type, this.ts, this.subtype, newValue, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object with elements that replace the content of {@link AbstractSlackReplyMessage#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 SlackReplyMessage withAttachments(Iterable elements) { if (this.attachments == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new SlackReplyMessage( this.type, this.ts, this.subtype, newValue, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting a value for the {@link AbstractSlackReplyMessage#getThreadTs() threadTs} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for threadTs * @return A modified copy of the {@code this} object */ public final SlackReplyMessage withThreadTs(String value) { String newValue = Objects.requireNonNull(value, "threadTs"); if (this.threadTs.equals(newValue)) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, newValue, this.userId, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting a value for the {@link AbstractSlackReplyMessage#getUserId() userId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for userId * @return A modified copy of the {@code this} object */ public final SlackReplyMessage withUserId(String value) { String newValue = Objects.requireNonNull(value, "userId"); if (this.userId.equals(newValue)) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, this.threadTs, newValue, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting a value for the {@link AbstractSlackReplyMessage#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 SlackReplyMessage withChannelId(String value) { String newValue = Objects.requireNonNull(value, "channelId"); if (this.channelId.equals(newValue)) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, this.threadTs, this.userId, newValue, this.replyCount, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting a value for the {@link AbstractSlackReplyMessage#getReplyCount() replyCount} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for replyCount * @return A modified copy of the {@code this} object */ public final SlackReplyMessage withReplyCount(int value) { if (this.replyCount == value) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, this.threadTs, this.userId, this.channelId, value, this.replyUserIds, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting a present value for the optional {@link AbstractSlackReplyMessage#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 SlackReplyMessage withReplyUserIds(@Nullable List value) { @Nullable List newValue = value; if (this.replyUserIds == newValue) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, newValue, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting an optional value for the {@link AbstractSlackReplyMessage#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 SlackReplyMessage withReplyUserIds(Optional> optional) { @Nullable List value = optional.orElse(null); if (this.replyUserIds == value) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, value, this.replyUsersCount, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting a present value for the optional {@link AbstractSlackReplyMessage#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 SlackReplyMessage withReplyUsersCount(@Nullable Integer value) { @Nullable Integer newValue = value; if (Objects.equals(this.replyUsersCount, newValue)) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, newValue, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting an optional value for the {@link AbstractSlackReplyMessage#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 SlackReplyMessage withReplyUsersCount(Optional optional) { @Nullable Integer value = optional.orElse(null); if (Objects.equals(this.replyUsersCount, value)) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, value, this.latestReplyTimestamp); } /** * Copy the current immutable object by setting a present value for the optional {@link AbstractSlackReplyMessage#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 SlackReplyMessage withLatestReplyTimestamp(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.latestReplyTimestamp, newValue)) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link AbstractSlackReplyMessage#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 SlackReplyMessage withLatestReplyTimestamp(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.latestReplyTimestamp, value)) return this; return new SlackReplyMessage( this.type, this.ts, this.subtype, this.attachments, this.threadTs, this.userId, this.channelId, this.replyCount, this.replyUserIds, this.replyUsersCount, value); } /** * This instance is equal to all instances of {@code SlackReplyMessage} 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 SlackReplyMessage && equalTo(0, (SlackReplyMessage) another); } private boolean equalTo(int synthetic, SlackReplyMessage another) { return type.equals(another.type) && ts.equals(another.ts) && Objects.equals(subtype, another.subtype) && attachments.equals(another.attachments) && threadTs.equals(another.threadTs) && userId.equals(another.userId) && channelId.equals(another.channelId) && 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 ts}, {@code subtype}, {@code attachments}, {@code threadTs}, {@code userId}, {@code channelId}, {@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) + ts.hashCode(); h += (h << 5) + Objects.hashCode(subtype); h += (h << 5) + attachments.hashCode(); h += (h << 5) + threadTs.hashCode(); h += (h << 5) + userId.hashCode(); h += (h << 5) + channelId.hashCode(); h += (h << 5) + 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 SlackReplyMessage} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("SlackReplyMessage{"); builder.append("type=").append(type); builder.append(", "); builder.append("ts=").append(ts); if (subtype != null) { builder.append(", "); builder.append("subtype=").append(subtype); } builder.append(", "); builder.append("attachments=").append(attachments); builder.append(", "); builder.append("threadTs=").append(threadTs); builder.append(", "); builder.append("userId=").append(userId); builder.append(", "); builder.append("channelId=").append(channelId); 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 = "AbstractSlackReplyMessage", generator = "Immutables") @Deprecated @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json extends AbstractSlackReplyMessage { @Nullable SlackEventType type; @Nullable String ts; @Nullable Optional subtype = Optional.empty(); @Nullable List attachments = Collections.emptyList(); @Nullable String threadTs; @Nullable String userId; @Nullable String channelId; int replyCount; boolean replyCountIsSet; @Nullable Optional> replyUserIds = Optional.empty(); @Nullable Optional replyUsersCount = Optional.empty(); @Nullable Optional latestReplyTimestamp = Optional.empty(); @JsonProperty public void setType(SlackEventType type) { this.type = type; } @JsonProperty public void setTs(String ts) { this.ts = ts; } @JsonProperty public void setSubtype(Optional subtype) { this.subtype = subtype; } @JsonProperty public void setAttachments(List attachments) { this.attachments = attachments; } @JsonProperty public void setThreadTs(String threadTs) { this.threadTs = threadTs; } @JsonProperty("user") public void setUserId(String userId) { this.userId = userId; } @JsonProperty("channel") public void setChannelId(String channelId) { this.channelId = channelId; } @JsonProperty public void setReplyCount(int replyCount) { this.replyCount = replyCount; this.replyCountIsSet = true; } @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 SlackEventType getType() { throw new UnsupportedOperationException(); } @Override public String getTs() { throw new UnsupportedOperationException(); } @Override public Optional getSubtype() { throw new UnsupportedOperationException(); } @Override public List getAttachments() { throw new UnsupportedOperationException(); } @Override public String getThreadTs() { throw new UnsupportedOperationException(); } @Override public String getUserId() { throw new UnsupportedOperationException(); } @Override public String getChannelId() { throw new UnsupportedOperationException(); } @Override public int 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 SlackReplyMessage fromJson(Json json) { SlackReplyMessage.Builder builder = SlackReplyMessage.builder(); if (json.type != null) { builder.setType(json.type); } if (json.ts != null) { builder.setTs(json.ts); } if (json.subtype != null) { builder.setSubtype(json.subtype); } if (json.attachments != null) { builder.addAllAttachments(json.attachments); } if (json.threadTs != null) { builder.setThreadTs(json.threadTs); } if (json.userId != null) { builder.setUserId(json.userId); } if (json.channelId != null) { builder.setChannelId(json.channelId); } if (json.replyCountIsSet) { 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 AbstractSlackReplyMessage} 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 SlackReplyMessage instance */ public static SlackReplyMessage copyOf(AbstractSlackReplyMessage instance) { if (instance instanceof SlackReplyMessage) { return (SlackReplyMessage) instance; } return SlackReplyMessage.builder() .from(instance) .build(); } /** * Creates a builder for {@link SlackReplyMessage SlackReplyMessage}. *

   * SlackReplyMessage.builder()
   *    .setType(com.hubspot.slack.client.models.events.SlackEventType) // required {@link AbstractSlackReplyMessage#getType() type}
   *    .setTs(String) // required {@link AbstractSlackReplyMessage#getTs() ts}
   *    .setSubtype(com.hubspot.slack.client.models.events.SlackMessageSubtype) // optional {@link AbstractSlackReplyMessage#getSubtype() subtype}
   *    .addAttachments|addAllAttachments(com.hubspot.slack.client.models.Attachment) // {@link AbstractSlackReplyMessage#getAttachments() attachments} elements
   *    .setThreadTs(String) // required {@link AbstractSlackReplyMessage#getThreadTs() threadTs}
   *    .setUserId(String) // required {@link AbstractSlackReplyMessage#getUserId() userId}
   *    .setChannelId(String) // required {@link AbstractSlackReplyMessage#getChannelId() channelId}
   *    .setReplyCount(int) // optional {@link AbstractSlackReplyMessage#getReplyCount() replyCount}
   *    .setReplyUserIds(List&lt;String&gt;) // optional {@link AbstractSlackReplyMessage#getReplyUserIds() replyUserIds}
   *    .setReplyUsersCount(Integer) // optional {@link AbstractSlackReplyMessage#getReplyUsersCount() replyUsersCount}
   *    .setLatestReplyTimestamp(String) // optional {@link AbstractSlackReplyMessage#getLatestReplyTimestamp() latestReplyTimestamp}
   *    .build();
   * 
* @return A new SlackReplyMessage builder */ public static SlackReplyMessage.Builder builder() { return new SlackReplyMessage.Builder(); } /** * Builds instances of type {@link SlackReplyMessage SlackReplyMessage}. * 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 = "AbstractSlackReplyMessage", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_TYPE = 0x1L; private static final long INIT_BIT_TS = 0x2L; private static final long INIT_BIT_THREAD_TS = 0x4L; private static final long INIT_BIT_USER_ID = 0x8L; private static final long INIT_BIT_CHANNEL_ID = 0x10L; private static final long OPT_BIT_REPLY_COUNT = 0x1L; private long initBits = 0x1fL; private long optBits; private @Nullable SlackEventType type; private @Nullable String ts; private @Nullable SlackMessageSubtype subtype; private List attachments = new ArrayList(); private @Nullable String threadTs; private @Nullable String userId; private @Nullable String channelId; private int 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 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.models.events.SlackEvent} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(SlackEvent 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.models.events.SlackEventMessageBase} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(SlackEventMessageBase 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.HasUser} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(HasUser 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.models.events.util.AbstractSlackReplyMessage} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(AbstractSlackReplyMessage 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 & 0x10L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x10L; } } if (object instanceof SlackEvent) { SlackEvent instance = (SlackEvent) object; if ((bits & 0x2L) == 0) { this.setType(instance.getType()); bits |= 0x2L; } if ((bits & 0x20L) == 0) { this.setTs(instance.getTs()); bits |= 0x20L; } } if (object instanceof SlackEventMessageBase) { SlackEventMessageBase instance = (SlackEventMessageBase) object; if ((bits & 0x1L) == 0) { addAllAttachments(instance.getAttachments()); bits |= 0x1L; } if ((bits & 0x2L) == 0) { this.setType(instance.getType()); bits |= 0x2L; } if ((bits & 0x8L) == 0) { Optional subtypeOptional = instance.getSubtype(); if (subtypeOptional.isPresent()) { setSubtype(subtypeOptional); } bits |= 0x8L; } if ((bits & 0x10L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x10L; } if ((bits & 0x20L) == 0) { this.setTs(instance.getTs()); bits |= 0x20L; } } if (object instanceof HasUser) { HasUser instance = (HasUser) object; if ((bits & 0x4L) == 0) { this.setUserId(instance.getUserId()); bits |= 0x4L; } } if (object instanceof AbstractSlackReplyMessage) { AbstractSlackReplyMessage instance = (AbstractSlackReplyMessage) object; this.setReplyCount(instance.getReplyCount()); if ((bits & 0x1L) == 0) { addAllAttachments(instance.getAttachments()); bits |= 0x1L; } Optional replyUsersCountOptional = instance.getReplyUsersCount(); if (replyUsersCountOptional.isPresent()) { setReplyUsersCount(replyUsersCountOptional); } Optional> replyUserIdsOptional = instance.getReplyUserIds(); if (replyUserIdsOptional.isPresent()) { setReplyUserIds(replyUserIdsOptional); } if ((bits & 0x8L) == 0) { Optional subtypeOptional = instance.getSubtype(); if (subtypeOptional.isPresent()) { setSubtype(subtypeOptional); } bits |= 0x8L; } Optional latestReplyTimestampOptional = instance.getLatestReplyTimestamp(); if (latestReplyTimestampOptional.isPresent()) { setLatestReplyTimestamp(latestReplyTimestampOptional); } if ((bits & 0x2L) == 0) { this.setType(instance.getType()); bits |= 0x2L; } this.setThreadTs(instance.getThreadTs()); if ((bits & 0x4L) == 0) { this.setUserId(instance.getUserId()); bits |= 0x4L; } if ((bits & 0x10L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x10L; } if ((bits & 0x20L) == 0) { this.setTs(instance.getTs()); bits |= 0x20L; } } } /** * Initializes the value for the {@link AbstractSlackReplyMessage#getType() type} attribute. * @param type The value for type * @return {@code this} builder for use in a chained invocation */ public final Builder setType(SlackEventType type) { this.type = Objects.requireNonNull(type, "type"); initBits &= ~INIT_BIT_TYPE; return this; } /** * Initializes the value for the {@link AbstractSlackReplyMessage#getTs() ts} attribute. * @param ts The value for ts * @return {@code this} builder for use in a chained invocation */ public final Builder setTs(String ts) { this.ts = Objects.requireNonNull(ts, "ts"); initBits &= ~INIT_BIT_TS; return this; } /** * Initializes the optional value {@link AbstractSlackReplyMessage#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 SlackMessageSubtype subtype) { this.subtype = subtype; return this; } /** * Initializes the optional value {@link AbstractSlackReplyMessage#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; } /** * Adds one element to {@link AbstractSlackReplyMessage#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 AbstractSlackReplyMessage#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 AbstractSlackReplyMessage#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 elements) { this.attachments.clear(); return addAllAttachments(elements); } /** * Adds elements to {@link AbstractSlackReplyMessage#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 elements) { for (Attachment element : elements) { this.attachments.add(Objects.requireNonNull(element, "attachments element")); } return this; } /** * Initializes the value for the {@link AbstractSlackReplyMessage#getThreadTs() threadTs} attribute. * @param threadTs The value for threadTs * @return {@code this} builder for use in a chained invocation */ public final Builder setThreadTs(String threadTs) { this.threadTs = Objects.requireNonNull(threadTs, "threadTs"); initBits &= ~INIT_BIT_THREAD_TS; return this; } /** * Initializes the value for the {@link AbstractSlackReplyMessage#getUserId() userId} attribute. * @param userId The value for userId * @return {@code this} builder for use in a chained invocation */ public final Builder setUserId(String userId) { this.userId = Objects.requireNonNull(userId, "userId"); initBits &= ~INIT_BIT_USER_ID; return this; } /** * Initializes the value for the {@link AbstractSlackReplyMessage#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 AbstractSlackReplyMessage#getReplyCount() replyCount} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link AbstractSlackReplyMessage#getReplyCount() replyCount}. * @param replyCount The value for replyCount * @return {@code this} builder for use in a chained invocation */ public final Builder setReplyCount(int replyCount) { this.replyCount = replyCount; optBits |= OPT_BIT_REPLY_COUNT; return this; } /** * Initializes the optional value {@link AbstractSlackReplyMessage#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 AbstractSlackReplyMessage#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> replyUserIds) { this.replyUserIds = replyUserIds.orElse(null); return this; } /** * Initializes the optional value {@link AbstractSlackReplyMessage#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 AbstractSlackReplyMessage#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 AbstractSlackReplyMessage#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 AbstractSlackReplyMessage#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 SlackReplyMessage SlackReplyMessage}. * @return An immutable instance of SlackReplyMessage * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public SlackReplyMessage build() { checkRequiredAttributes(); return new SlackReplyMessage(this); } private boolean replyCountIsSet() { return (optBits & OPT_BIT_REPLY_COUNT) != 0; } private boolean typeIsSet() { return (initBits & INIT_BIT_TYPE) == 0; } private boolean tsIsSet() { return (initBits & INIT_BIT_TS) == 0; } private boolean threadTsIsSet() { return (initBits & INIT_BIT_THREAD_TS) == 0; } private boolean userIdIsSet() { return (initBits & INIT_BIT_USER_ID) == 0; } private boolean channelIdIsSet() { return (initBits & INIT_BIT_CHANNEL_ID) == 0; } private void checkRequiredAttributes() { if (initBits != 0) { throw new InvalidImmutableStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!typeIsSet()) attributes.add("type"); if (!tsIsSet()) attributes.add("ts"); if (!threadTsIsSet()) attributes.add("threadTs"); if (!userIdIsSet()) attributes.add("userId"); if (!channelIdIsSet()) attributes.add("channelId"); return "Cannot build SlackReplyMessage, some of required attributes are not set " + attributes; } } private static List createSafeList(Iterable 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); } } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy