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

com.hubspot.slack.client.methods.params.chat.ChatUpdateMessageParams 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 ChatUpdateMessageParamsIF}.
 * 

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

   * ChatUpdateMessageParams.builder()
   *    .addAttachments|addAllAttachments(com.hubspot.slack.client.models.Attachment) // {@link ChatUpdateMessageParamsIF#getAttachments() attachments} elements
   *    .addBlocks|addAllBlocks(com.hubspot.slack.client.models.blocks.Block) // {@link ChatUpdateMessageParamsIF#getBlocks() blocks} elements
   *    .setChannelId(String) // required {@link ChatUpdateMessageParamsIF#getChannelId() channelId}
   *    .setText(String) // optional {@link ChatUpdateMessageParamsIF#getText() text}
   *    .setTs(String) // required {@link ChatUpdateMessageParamsIF#getTs() ts}
   *    .setAsUser(Boolean) // optional {@link ChatUpdateMessageParamsIF#getAsUser() asUser}
   *    .setShouldLinkNames(boolean) // optional {@link ChatUpdateMessageParamsIF#shouldLinkNames() shouldLinkNames}
   *    .setParse(String) // optional {@link ChatUpdateMessageParamsIF#getParse() parse}
   *    .build();
   * 
* @return A new ChatUpdateMessageParams builder */ public static ChatUpdateMessageParams.Builder builder() { return new ChatUpdateMessageParams.Builder(); } /** * Builds instances of type {@link ChatUpdateMessageParams ChatUpdateMessageParams}. * 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 = "ChatUpdateMessageParamsIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_CHANNEL_ID = 0x1L; private static final long INIT_BIT_TS = 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 List attachments = new ArrayList(); private List blocks = new ArrayList(); private @Nullable String channelId; private @Nullable String text; private @Nullable String ts; private @Nullable Boolean asUser; private boolean shouldLinkNames; private @Nullable String parse; 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.ChatUpdateMessageParamsIF} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ChatUpdateMessageParamsIF 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; } 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 ChatUpdateMessageParamsIF) { ChatUpdateMessageParamsIF instance = (ChatUpdateMessageParamsIF) object; if ((bits & 0x1L) == 0) { addAllAttachments(instance.getAttachments()); bits |= 0x1L; } this.setShouldLinkNames(instance.shouldLinkNames()); if ((bits & 0x2L) == 0) { addAllBlocks(instance.getBlocks()); bits |= 0x2L; } this.setParse(instance.getParse()); if ((bits & 0x4L) == 0) { Optional textOptional = instance.getText(); if (textOptional.isPresent()) { setText(textOptional); } bits |= 0x4L; } if ((bits & 0x8L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x8L; } Optional asUserOptional = instance.getAsUser(); if (asUserOptional.isPresent()) { setAsUser(asUserOptional); } this.setTs(instance.getTs()); } 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; } } } /** * Adds one element to {@link ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#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 optional value {@link ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#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; } /** * Initializes the value for the {@link ChatUpdateMessageParamsIF#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 ChatUpdateMessageParamsIF#getAsUser() asUser} to asUser. * @param asUser The value for asUser, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setAsUser(@Nullable Boolean asUser) { this.asUser = asUser; return this; } /** * Initializes the optional value {@link ChatUpdateMessageParamsIF#getAsUser() asUser} to asUser. * @param asUser The value for asUser * @return {@code this} builder for use in a chained invocation */ public final Builder setAsUser(Optional asUser) { this.asUser = asUser.orElse(null); return this; } /** * Initializes the value for the {@link ChatUpdateMessageParamsIF#shouldLinkNames() shouldLinkNames} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link ChatUpdateMessageParamsIF#shouldLinkNames() 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 ChatUpdateMessageParamsIF#getParse() parse} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link ChatUpdateMessageParamsIF#getParse() parse}. * @param parse The value for parse * @return {@code this} builder for use in a chained invocation */ public final Builder setParse(String parse) { this.parse = Objects.requireNonNull(parse, "parse"); return this; } /** * Builds a new {@link ChatUpdateMessageParams ChatUpdateMessageParams}. * @return An immutable instance of ChatUpdateMessageParams * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public ChatUpdateMessageParams build() { checkRequiredAttributes(); return ChatUpdateMessageParams.validate(new ChatUpdateMessageParams(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 tsIsSet() { return (initBits & INIT_BIT_TS) == 0; } private void checkRequiredAttributes() { if (initBits != 0) { throw new InvalidImmutableStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!channelIdIsSet()) attributes.add("channelId"); if (!tsIsSet()) attributes.add("ts"); return "Cannot build ChatUpdateMessageParams, 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