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

com.hubspot.slack.client.methods.params.chat.ChatPostEphemeralMessageParams Maven / Gradle / Ivy

package com.hubspot.slack.client.methods.params.chat;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.methods.interceptor.HasChannel;
import com.hubspot.slack.client.models.Attachment;
import com.hubspot.slack.client.models.blocks.Block;
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 ChatPostEphemeralMessageParamsIF}.
 * 

* Use the builder to create immutable instances: * {@code ChatPostEphemeralMessageParams.builder()}. */ @Generated(from = "ChatPostEphemeralMessageParamsIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ChatPostEphemeralMessageParams implements ChatPostEphemeralMessageParamsIF { private final @Nullable String text; private final List attachments; private final List blocks; private final String channelId; private final String userToSendTo; private final @Nullable Boolean sendAsUser; private final @Nullable String threadTs; private final boolean shouldLinkNames; private final String parseMode; private ChatPostEphemeralMessageParams(ChatPostEphemeralMessageParams.Builder builder) { this.text = builder.text; this.attachments = createUnmodifiableList(true, builder.attachments); this.channelId = builder.channelId; this.userToSendTo = builder.userToSendTo; this.sendAsUser = builder.sendAsUser; this.threadTs = builder.threadTs; if (builder.blocksIsSet()) { initShim.setBlocks(createUnmodifiableList(true, builder.blocks)); } if (builder.shouldLinkNamesIsSet()) { initShim.setShouldLinkNames(builder.shouldLinkNames); } if (builder.parseMode != null) { initShim.setParseMode(builder.parseMode); } this.blocks = initShim.getBlocks(); this.shouldLinkNames = initShim.getShouldLinkNames(); this.parseMode = initShim.getParseMode(); this.initShim = null; } private ChatPostEphemeralMessageParams( @Nullable String text, List attachments, List blocks, String channelId, String userToSendTo, @Nullable Boolean sendAsUser, @Nullable String threadTs, boolean shouldLinkNames, String parseMode) { this.text = text; this.attachments = attachments; this.blocks = blocks; this.channelId = channelId; this.userToSendTo = userToSendTo; this.sendAsUser = sendAsUser; this.threadTs = threadTs; this.shouldLinkNames = shouldLinkNames; this.parseMode = parseMode; this.initShim = null; } private static final byte STAGE_INITIALIZING = -1; private static final byte STAGE_UNINITIALIZED = 0; private static final byte STAGE_INITIALIZED = 1; private transient volatile InitShim initShim = new InitShim(); @Generated(from = "ChatPostEphemeralMessageParamsIF", generator = "Immutables") private final class InitShim { private byte blocksBuildStage = STAGE_UNINITIALIZED; private List blocks; List getBlocks() { if (blocksBuildStage == STAGE_INITIALIZING) throw new InvalidImmutableStateException(formatInitCycleMessage()); if (blocksBuildStage == STAGE_UNINITIALIZED) { blocksBuildStage = STAGE_INITIALIZING; this.blocks = createUnmodifiableList(false, createSafeList(getBlocksInitialize(), true, false)); blocksBuildStage = STAGE_INITIALIZED; } return this.blocks; } void setBlocks(List blocks) { this.blocks = blocks; blocksBuildStage = STAGE_INITIALIZED; } private byte shouldLinkNamesBuildStage = STAGE_UNINITIALIZED; private boolean shouldLinkNames; boolean getShouldLinkNames() { if (shouldLinkNamesBuildStage == STAGE_INITIALIZING) throw new InvalidImmutableStateException(formatInitCycleMessage()); if (shouldLinkNamesBuildStage == STAGE_UNINITIALIZED) { shouldLinkNamesBuildStage = STAGE_INITIALIZING; this.shouldLinkNames = getShouldLinkNamesInitialize(); shouldLinkNamesBuildStage = STAGE_INITIALIZED; } return this.shouldLinkNames; } void setShouldLinkNames(boolean shouldLinkNames) { this.shouldLinkNames = shouldLinkNames; shouldLinkNamesBuildStage = STAGE_INITIALIZED; } private byte parseModeBuildStage = STAGE_UNINITIALIZED; private String parseMode; String getParseMode() { if (parseModeBuildStage == STAGE_INITIALIZING) throw new InvalidImmutableStateException(formatInitCycleMessage()); if (parseModeBuildStage == STAGE_UNINITIALIZED) { parseModeBuildStage = STAGE_INITIALIZING; this.parseMode = Objects.requireNonNull(getParseModeInitialize(), "parseMode"); parseModeBuildStage = STAGE_INITIALIZED; } return this.parseMode; } void setParseMode(String parseMode) { this.parseMode = parseMode; parseModeBuildStage = STAGE_INITIALIZED; } private String formatInitCycleMessage() { List attributes = new ArrayList<>(); if (blocksBuildStage == STAGE_INITIALIZING) attributes.add("blocks"); if (shouldLinkNamesBuildStage == STAGE_INITIALIZING) attributes.add("shouldLinkNames"); if (parseModeBuildStage == STAGE_INITIALIZING) attributes.add("parseMode"); return "Cannot build ChatPostEphemeralMessageParams, attribute initializers form cycle " + attributes; } } private List getBlocksInitialize() { return ChatPostEphemeralMessageParamsIF.super.getBlocks(); } private boolean getShouldLinkNamesInitialize() { return ChatPostEphemeralMessageParamsIF.super.getShouldLinkNames(); } private String getParseModeInitialize() { return ChatPostEphemeralMessageParamsIF.super.getParseMode(); } /** * @return The value of the {@code text} attribute */ @JsonProperty @Override public Optional getText() { return Optional.ofNullable(text); } /** * @return The value of the {@code attachments} attribute */ @JsonProperty @Override public List getAttachments() { return attachments; } /** * @return The value of the {@code blocks} attribute */ @JsonProperty @Override public List getBlocks() { InitShim shim = this.initShim; return shim != null ? shim.getBlocks() : this.blocks; } /** * @return The value of the {@code channelId} attribute */ @JsonProperty("channel") @Override public String getChannelId() { return channelId; } /** * @return The value of the {@code userToSendTo} attribute */ @JsonProperty("user") @Override public String getUserToSendTo() { return userToSendTo; } /** * @return The value of the {@code sendAsUser} attribute */ @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonProperty("as_user") @Override public Optional getSendAsUser() { return Optional.ofNullable(sendAsUser); } /** * @return The value of the {@code threadTs} attribute */ @JsonProperty("thread_ts") @Override public Optional getThreadTs() { return Optional.ofNullable(threadTs); } /** * @return The value of the {@code shouldLinkNames} attribute */ @JsonProperty("link_names") @Override public boolean getShouldLinkNames() { InitShim shim = this.initShim; return shim != null ? shim.getShouldLinkNames() : this.shouldLinkNames; } /** * @return The value of the {@code parseMode} attribute */ @JsonProperty("parse") @Override public String getParseMode() { InitShim shim = this.initShim; return shim != null ? shim.getParseMode() : this.parseMode; } /** * Copy the current immutable object by setting a present value for the optional {@link ChatPostEphemeralMessageParamsIF#getText() text} attribute. * @param value The value for text, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ChatPostEphemeralMessageParams withText(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.text, newValue)) return this; return validate(new ChatPostEphemeralMessageParams( newValue, this.attachments, this.blocks, this.channelId, this.userToSendTo, this.sendAsUser, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object by setting an optional value for the {@link ChatPostEphemeralMessageParamsIF#getText() text} 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 text * @return A modified copy of {@code this} object */ public final ChatPostEphemeralMessageParams withText(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.text, value)) return this; return validate(new ChatPostEphemeralMessageParams( value, this.attachments, this.blocks, this.channelId, this.userToSendTo, this.sendAsUser, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object with elements that replace the content of {@link ChatPostEphemeralMessageParamsIF#getAttachments() attachments}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ChatPostEphemeralMessageParams withAttachments(Attachment... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ChatPostEphemeralMessageParams( this.text, newValue, this.blocks, this.channelId, this.userToSendTo, this.sendAsUser, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object with elements that replace the content of {@link ChatPostEphemeralMessageParamsIF#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 ChatPostEphemeralMessageParams withAttachments(Iterable elements) { if (this.attachments == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ChatPostEphemeralMessageParams( this.text, newValue, this.blocks, this.channelId, this.userToSendTo, this.sendAsUser, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object with elements that replace the content of {@link ChatPostEphemeralMessageParamsIF#getBlocks() blocks}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ChatPostEphemeralMessageParams withBlocks(Block... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, newValue, this.channelId, this.userToSendTo, this.sendAsUser, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object with elements that replace the content of {@link ChatPostEphemeralMessageParamsIF#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 ChatPostEphemeralMessageParams withBlocks(Iterable elements) { if (this.blocks == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, newValue, this.channelId, this.userToSendTo, this.sendAsUser, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object by setting a value for the {@link ChatPostEphemeralMessageParamsIF#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 ChatPostEphemeralMessageParams withChannelId(String value) { String newValue = Objects.requireNonNull(value, "channelId"); if (this.channelId.equals(newValue)) return this; return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, this.blocks, newValue, this.userToSendTo, this.sendAsUser, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object by setting a value for the {@link ChatPostEphemeralMessageParamsIF#getUserToSendTo() userToSendTo} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for userToSendTo * @return A modified copy of the {@code this} object */ public final ChatPostEphemeralMessageParams withUserToSendTo(String value) { String newValue = Objects.requireNonNull(value, "userToSendTo"); if (this.userToSendTo.equals(newValue)) return this; return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, this.blocks, this.channelId, newValue, this.sendAsUser, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object by setting a present value for the optional {@link ChatPostEphemeralMessageParamsIF#getSendAsUser() sendAsUser} attribute. * @param value The value for sendAsUser, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ChatPostEphemeralMessageParams withSendAsUser(@Nullable Boolean value) { @Nullable Boolean newValue = value; if (Objects.equals(this.sendAsUser, newValue)) return this; return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.userToSendTo, newValue, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object by setting an optional value for the {@link ChatPostEphemeralMessageParamsIF#getSendAsUser() sendAsUser} 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 sendAsUser * @return A modified copy of {@code this} object */ public final ChatPostEphemeralMessageParams withSendAsUser(Optional optional) { @Nullable Boolean value = optional.orElse(null); if (Objects.equals(this.sendAsUser, value)) return this; return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.userToSendTo, value, this.threadTs, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object by setting a present value for the optional {@link ChatPostEphemeralMessageParamsIF#getThreadTs() threadTs} attribute. * @param value The value for threadTs, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ChatPostEphemeralMessageParams withThreadTs(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.threadTs, newValue)) return this; return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.userToSendTo, this.sendAsUser, newValue, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object by setting an optional value for the {@link ChatPostEphemeralMessageParamsIF#getThreadTs() threadTs} 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 threadTs * @return A modified copy of {@code this} object */ public final ChatPostEphemeralMessageParams withThreadTs(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.threadTs, value)) return this; return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.userToSendTo, this.sendAsUser, value, this.shouldLinkNames, this.parseMode)); } /** * Copy the current immutable object by setting a value for the {@link ChatPostEphemeralMessageParamsIF#getShouldLinkNames() shouldLinkNames} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for shouldLinkNames * @return A modified copy of the {@code this} object */ public final ChatPostEphemeralMessageParams withShouldLinkNames(boolean value) { if (this.shouldLinkNames == value) return this; return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.userToSendTo, this.sendAsUser, this.threadTs, value, this.parseMode)); } /** * Copy the current immutable object by setting a value for the {@link ChatPostEphemeralMessageParamsIF#getParseMode() parseMode} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for parseMode * @return A modified copy of the {@code this} object */ public final ChatPostEphemeralMessageParams withParseMode(String value) { String newValue = Objects.requireNonNull(value, "parseMode"); if (this.parseMode.equals(newValue)) return this; return validate(new ChatPostEphemeralMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.userToSendTo, this.sendAsUser, this.threadTs, this.shouldLinkNames, newValue)); } /** * This instance is equal to all instances of {@code ChatPostEphemeralMessageParams} 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 ChatPostEphemeralMessageParams && equalTo(0, (ChatPostEphemeralMessageParams) another); } private boolean equalTo(int synthetic, ChatPostEphemeralMessageParams another) { return Objects.equals(text, another.text) && attachments.equals(another.attachments) && blocks.equals(another.blocks) && channelId.equals(another.channelId) && userToSendTo.equals(another.userToSendTo) && Objects.equals(sendAsUser, another.sendAsUser) && Objects.equals(threadTs, another.threadTs) && shouldLinkNames == another.shouldLinkNames && parseMode.equals(another.parseMode); } /** * Computes a hash code from attributes: {@code text}, {@code attachments}, {@code blocks}, {@code channelId}, {@code userToSendTo}, {@code sendAsUser}, {@code threadTs}, {@code shouldLinkNames}, {@code parseMode}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(text); h += (h << 5) + attachments.hashCode(); h += (h << 5) + blocks.hashCode(); h += (h << 5) + channelId.hashCode(); h += (h << 5) + userToSendTo.hashCode(); h += (h << 5) + Objects.hashCode(sendAsUser); h += (h << 5) + Objects.hashCode(threadTs); h += (h << 5) + Boolean.hashCode(shouldLinkNames); h += (h << 5) + parseMode.hashCode(); return h; } /** * Prints the immutable value {@code ChatPostEphemeralMessageParams} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ChatPostEphemeralMessageParams{"); if (text != null) { builder.append("text=").append(text); } if (builder.length() > 31) builder.append(", "); builder.append("attachments=").append(attachments); builder.append(", "); builder.append("blocks=").append(blocks); builder.append(", "); builder.append("channelId=").append(channelId); builder.append(", "); builder.append("userToSendTo=").append(userToSendTo); if (sendAsUser != null) { builder.append(", "); builder.append("sendAsUser=").append(sendAsUser); } if (threadTs != null) { builder.append(", "); builder.append("threadTs=").append(threadTs); } builder.append(", "); builder.append("shouldLinkNames=").append(shouldLinkNames); builder.append(", "); builder.append("parseMode=").append(parseMode); 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 = "ChatPostEphemeralMessageParamsIF", generator = "Immutables") @Deprecated @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ChatPostEphemeralMessageParamsIF { @Nullable Optional text = Optional.empty(); @Nullable List attachments = Collections.emptyList(); @Nullable List blocks = Collections.emptyList(); boolean blocksIsSet; @Nullable String channelId; @Nullable String userToSendTo; @Nullable Optional sendAsUser = Optional.empty(); @Nullable Optional threadTs = Optional.empty(); boolean shouldLinkNames; boolean shouldLinkNamesIsSet; @Nullable String parseMode; @JsonProperty public void setText(Optional text) { this.text = text; } @JsonProperty public void setAttachments(List attachments) { this.attachments = attachments; } @JsonProperty public void setBlocks(List blocks) { this.blocks = blocks; this.blocksIsSet = null != blocks; } @JsonProperty("channel") public void setChannelId(String channelId) { this.channelId = channelId; } @JsonProperty("user") public void setUserToSendTo(String userToSendTo) { this.userToSendTo = userToSendTo; } @JsonInclude(JsonInclude.Include.NON_ABSENT) @JsonProperty("as_user") public void setSendAsUser(Optional sendAsUser) { this.sendAsUser = sendAsUser; } @JsonProperty("thread_ts") public void setThreadTs(Optional threadTs) { this.threadTs = threadTs; } @JsonProperty("link_names") public void setShouldLinkNames(boolean shouldLinkNames) { this.shouldLinkNames = shouldLinkNames; this.shouldLinkNamesIsSet = true; } @JsonProperty("parse") public void setParseMode(String parseMode) { this.parseMode = parseMode; } @Override public Optional getText() { throw new UnsupportedOperationException(); } @Override public List getAttachments() { throw new UnsupportedOperationException(); } @Override public List getBlocks() { throw new UnsupportedOperationException(); } @Override public String getChannelId() { throw new UnsupportedOperationException(); } @Override public String getUserToSendTo() { throw new UnsupportedOperationException(); } @Override public Optional getSendAsUser() { throw new UnsupportedOperationException(); } @Override public Optional getThreadTs() { throw new UnsupportedOperationException(); } @Override public boolean getShouldLinkNames() { throw new UnsupportedOperationException(); } @Override public String getParseMode() { 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 ChatPostEphemeralMessageParams fromJson(Json json) { ChatPostEphemeralMessageParams.Builder builder = ChatPostEphemeralMessageParams.builder(); if (json.text != null) { builder.setText(json.text); } if (json.attachments != null) { builder.addAllAttachments(json.attachments); } if (json.blocksIsSet) { builder.addAllBlocks(json.blocks); } if (json.channelId != null) { builder.setChannelId(json.channelId); } if (json.userToSendTo != null) { builder.setUserToSendTo(json.userToSendTo); } if (json.sendAsUser != null) { builder.setSendAsUser(json.sendAsUser); } if (json.threadTs != null) { builder.setThreadTs(json.threadTs); } if (json.shouldLinkNamesIsSet) { builder.setShouldLinkNames(json.shouldLinkNames); } if (json.parseMode != null) { builder.setParseMode(json.parseMode); } return builder.build(); } private static ChatPostEphemeralMessageParams validate(ChatPostEphemeralMessageParams instance) { instance.check(); return instance; } /** * Creates an immutable copy of a {@link ChatPostEphemeralMessageParamsIF} 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 ChatPostEphemeralMessageParams instance */ public static ChatPostEphemeralMessageParams copyOf(ChatPostEphemeralMessageParamsIF instance) { if (instance instanceof ChatPostEphemeralMessageParams) { return (ChatPostEphemeralMessageParams) instance; } return ChatPostEphemeralMessageParams.builder() .from(instance) .build(); } /** * Creates a builder for {@link ChatPostEphemeralMessageParams ChatPostEphemeralMessageParams}. *

   * ChatPostEphemeralMessageParams.builder()
   *    .setText(String) // optional {@link ChatPostEphemeralMessageParamsIF#getText() text}
   *    .addAttachments|addAllAttachments(com.hubspot.slack.client.models.Attachment) // {@link ChatPostEphemeralMessageParamsIF#getAttachments() attachments} elements
   *    .addBlocks|addAllBlocks(com.hubspot.slack.client.models.blocks.Block) // {@link ChatPostEphemeralMessageParamsIF#getBlocks() blocks} elements
   *    .setChannelId(String) // required {@link ChatPostEphemeralMessageParamsIF#getChannelId() channelId}
   *    .setUserToSendTo(String) // required {@link ChatPostEphemeralMessageParamsIF#getUserToSendTo() userToSendTo}
   *    .setSendAsUser(Boolean) // optional {@link ChatPostEphemeralMessageParamsIF#getSendAsUser() sendAsUser}
   *    .setThreadTs(String) // optional {@link ChatPostEphemeralMessageParamsIF#getThreadTs() threadTs}
   *    .setShouldLinkNames(boolean) // optional {@link ChatPostEphemeralMessageParamsIF#getShouldLinkNames() shouldLinkNames}
   *    .setParseMode(String) // optional {@link ChatPostEphemeralMessageParamsIF#getParseMode() parseMode}
   *    .build();
   * 
* @return A new ChatPostEphemeralMessageParams builder */ public static ChatPostEphemeralMessageParams.Builder builder() { return new ChatPostEphemeralMessageParams.Builder(); } /** * Builds instances of type {@link ChatPostEphemeralMessageParams ChatPostEphemeralMessageParams}. * 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 = "ChatPostEphemeralMessageParamsIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_CHANNEL_ID = 0x1L; private static final long INIT_BIT_USER_TO_SEND_TO = 0x2L; private static final long OPT_BIT_BLOCKS = 0x1L; private static final long OPT_BIT_SHOULD_LINK_NAMES = 0x2L; private long initBits = 0x3L; private long optBits; private @Nullable String text; private List attachments = new ArrayList(); private List blocks = new ArrayList(); private @Nullable String channelId; private @Nullable String userToSendTo; private @Nullable Boolean sendAsUser; private @Nullable String threadTs; private boolean shouldLinkNames; private @Nullable String parseMode; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.methods.interceptor.HasChannel} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(HasChannel instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.methods.params.chat.MessageParams} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(MessageParams instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.methods.params.chat.ChatPostEphemeralMessageParamsIF} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ChatPostEphemeralMessageParamsIF 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 & 0x8L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x8L; } } if (object instanceof MessageParams) { MessageParams instance = (MessageParams) object; if ((bits & 0x1L) == 0) { addAllAttachments(instance.getAttachments()); bits |= 0x1L; } if ((bits & 0x4L) == 0) { Optional textOptional = instance.getText(); if (textOptional.isPresent()) { setText(textOptional); } bits |= 0x4L; } if ((bits & 0x2L) == 0) { addAllBlocks(instance.getBlocks()); bits |= 0x2L; } if ((bits & 0x8L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x8L; } } if (object instanceof ChatPostEphemeralMessageParamsIF) { ChatPostEphemeralMessageParamsIF instance = (ChatPostEphemeralMessageParamsIF) object; Optional sendAsUserOptional = instance.getSendAsUser(); if (sendAsUserOptional.isPresent()) { setSendAsUser(sendAsUserOptional); } this.setUserToSendTo(instance.getUserToSendTo()); if ((bits & 0x1L) == 0) { addAllAttachments(instance.getAttachments()); bits |= 0x1L; } this.setShouldLinkNames(instance.getShouldLinkNames()); if ((bits & 0x2L) == 0) { addAllBlocks(instance.getBlocks()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { Optional textOptional = instance.getText(); if (textOptional.isPresent()) { setText(textOptional); } bits |= 0x4L; } this.setParseMode(instance.getParseMode()); Optional threadTsOptional = instance.getThreadTs(); if (threadTsOptional.isPresent()) { setThreadTs(threadTsOptional); } if ((bits & 0x8L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x8L; } } } /** * Initializes the optional value {@link ChatPostEphemeralMessageParamsIF#getText() text} to text. * @param text The value for text, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setText(@Nullable String text) { this.text = text; return this; } /** * Initializes the optional value {@link ChatPostEphemeralMessageParamsIF#getText() text} to text. * @param text The value for text * @return {@code this} builder for use in a chained invocation */ public final Builder setText(Optional text) { this.text = text.orElse(null); return this; } /** * Adds one element to {@link ChatPostEphemeralMessageParamsIF#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 ChatPostEphemeralMessageParamsIF#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 ChatPostEphemeralMessageParamsIF#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 ChatPostEphemeralMessageParamsIF#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; } /** * Adds one element to {@link ChatPostEphemeralMessageParamsIF#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")); optBits |= OPT_BIT_BLOCKS; return this; } /** * Adds elements to {@link ChatPostEphemeralMessageParamsIF#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")); } optBits |= OPT_BIT_BLOCKS; return this; } /** * Sets or replaces all elements for {@link ChatPostEphemeralMessageParamsIF#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 elements) { this.blocks.clear(); return addAllBlocks(elements); } /** * Adds elements to {@link ChatPostEphemeralMessageParamsIF#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 elements) { for (Block element : elements) { this.blocks.add(Objects.requireNonNull(element, "blocks element")); } optBits |= OPT_BIT_BLOCKS; return this; } /** * Initializes the value for the {@link ChatPostEphemeralMessageParamsIF#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 ChatPostEphemeralMessageParamsIF#getUserToSendTo() userToSendTo} attribute. * @param userToSendTo The value for userToSendTo * @return {@code this} builder for use in a chained invocation */ public final Builder setUserToSendTo(String userToSendTo) { this.userToSendTo = Objects.requireNonNull(userToSendTo, "userToSendTo"); initBits &= ~INIT_BIT_USER_TO_SEND_TO; return this; } /** * Initializes the optional value {@link ChatPostEphemeralMessageParamsIF#getSendAsUser() sendAsUser} to sendAsUser. * @param sendAsUser The value for sendAsUser, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setSendAsUser(@Nullable Boolean sendAsUser) { this.sendAsUser = sendAsUser; return this; } /** * Initializes the optional value {@link ChatPostEphemeralMessageParamsIF#getSendAsUser() sendAsUser} to sendAsUser. * @param sendAsUser The value for sendAsUser * @return {@code this} builder for use in a chained invocation */ public final Builder setSendAsUser(Optional sendAsUser) { this.sendAsUser = sendAsUser.orElse(null); return this; } /** * Initializes the optional value {@link ChatPostEphemeralMessageParamsIF#getThreadTs() threadTs} to threadTs. * @param threadTs The value for threadTs, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setThreadTs(@Nullable String threadTs) { this.threadTs = threadTs; return this; } /** * Initializes the optional value {@link ChatPostEphemeralMessageParamsIF#getThreadTs() threadTs} to threadTs. * @param threadTs The value for threadTs * @return {@code this} builder for use in a chained invocation */ public final Builder setThreadTs(Optional threadTs) { this.threadTs = threadTs.orElse(null); return this; } /** * Initializes the value for the {@link ChatPostEphemeralMessageParamsIF#getShouldLinkNames() shouldLinkNames} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link ChatPostEphemeralMessageParamsIF#getShouldLinkNames() shouldLinkNames}. * @param shouldLinkNames The value for shouldLinkNames * @return {@code this} builder for use in a chained invocation */ public final Builder setShouldLinkNames(boolean shouldLinkNames) { this.shouldLinkNames = shouldLinkNames; optBits |= OPT_BIT_SHOULD_LINK_NAMES; return this; } /** * Initializes the value for the {@link ChatPostEphemeralMessageParamsIF#getParseMode() parseMode} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link ChatPostEphemeralMessageParamsIF#getParseMode() parseMode}. * @param parseMode The value for parseMode * @return {@code this} builder for use in a chained invocation */ public final Builder setParseMode(String parseMode) { this.parseMode = Objects.requireNonNull(parseMode, "parseMode"); return this; } /** * Builds a new {@link ChatPostEphemeralMessageParams ChatPostEphemeralMessageParams}. * @return An immutable instance of ChatPostEphemeralMessageParams * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public ChatPostEphemeralMessageParams build() { checkRequiredAttributes(); return ChatPostEphemeralMessageParams.validate(new ChatPostEphemeralMessageParams(this)); } private boolean blocksIsSet() { return (optBits & OPT_BIT_BLOCKS) != 0; } private boolean shouldLinkNamesIsSet() { return (optBits & OPT_BIT_SHOULD_LINK_NAMES) != 0; } private boolean channelIdIsSet() { return (initBits & INIT_BIT_CHANNEL_ID) == 0; } private boolean userToSendToIsSet() { return (initBits & INIT_BIT_USER_TO_SEND_TO) == 0; } private void checkRequiredAttributes() { if (initBits != 0) { throw new InvalidImmutableStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!channelIdIsSet()) attributes.add("channelId"); if (!userToSendToIsSet()) attributes.add("userToSendTo"); return "Cannot build ChatPostEphemeralMessageParams, 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