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

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

* Use the builder to create immutable instances: * {@code ChatScheduleMessageParams.builder()}. */ @Generated(from = "ChatScheduleMessageParamsIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ChatScheduleMessageParams implements ChatScheduleMessageParamsIF { private final @Nullable String text; private final List attachments; private final List blocks; private final String channelId; private final long postAt; private final boolean shouldLinkNames; private final String parseMode; private final String threadTs; private final @Nullable Boolean unfurlLinks; private final @Nullable Boolean unfurlMedia; private ChatScheduleMessageParams(ChatScheduleMessageParams.Builder builder) { this.text = builder.text; this.attachments = createUnmodifiableList(true, builder.attachments); this.channelId = builder.channelId; this.postAt = builder.postAt; this.unfurlLinks = builder.unfurlLinks; this.unfurlMedia = builder.unfurlMedia; if (builder.blocksIsSet()) { initShim.setBlocks(createUnmodifiableList(true, builder.blocks)); } if (builder.shouldLinkNamesIsSet()) { initShim.setShouldLinkNames(builder.shouldLinkNames); } if (builder.parseMode != null) { initShim.setParseMode(builder.parseMode); } if (builder.threadTs != null) { initShim.setThreadTs(builder.threadTs); } this.blocks = initShim.getBlocks(); this.shouldLinkNames = initShim.getShouldLinkNames(); this.parseMode = initShim.getParseMode(); this.threadTs = initShim.getThreadTs(); this.initShim = null; } private ChatScheduleMessageParams( @Nullable String text, List attachments, List blocks, String channelId, long postAt, boolean shouldLinkNames, String parseMode, String threadTs, @Nullable Boolean unfurlLinks, @Nullable Boolean unfurlMedia) { this.text = text; this.attachments = attachments; this.blocks = blocks; this.channelId = channelId; this.postAt = postAt; this.shouldLinkNames = shouldLinkNames; this.parseMode = parseMode; this.threadTs = threadTs; this.unfurlLinks = unfurlLinks; this.unfurlMedia = unfurlMedia; 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 = "ChatScheduleMessageParamsIF", 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 byte threadTsBuildStage = STAGE_UNINITIALIZED; private String threadTs; String getThreadTs() { if (threadTsBuildStage == STAGE_INITIALIZING) throw new InvalidImmutableStateException(formatInitCycleMessage()); if (threadTsBuildStage == STAGE_UNINITIALIZED) { threadTsBuildStage = STAGE_INITIALIZING; this.threadTs = Objects.requireNonNull(getThreadTsInitialize(), "threadTs"); threadTsBuildStage = STAGE_INITIALIZED; } return this.threadTs; } void setThreadTs(String threadTs) { this.threadTs = threadTs; threadTsBuildStage = 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"); if (threadTsBuildStage == STAGE_INITIALIZING) attributes.add("threadTs"); return "Cannot build ChatScheduleMessageParams, attribute initializers form cycle " + attributes; } } private List getBlocksInitialize() { return ChatScheduleMessageParamsIF.super.getBlocks(); } private boolean getShouldLinkNamesInitialize() { return ChatScheduleMessageParamsIF.super.getShouldLinkNames(); } private String getParseModeInitialize() { return ChatScheduleMessageParamsIF.super.getParseMode(); } private String getThreadTsInitialize() { return ChatScheduleMessageParamsIF.super.getThreadTs(); } /** * @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 postAt} attribute */ @JsonProperty @Override public long getPostAt() { return postAt; } /** * @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; } /** * @return The value of the {@code threadTs} attribute */ @JsonProperty @Override public String getThreadTs() { InitShim shim = this.initShim; return shim != null ? shim.getThreadTs() : this.threadTs; } /** * @return The value of the {@code unfurlLinks} attribute */ @JsonProperty @Override public Optional getUnfurlLinks() { return Optional.ofNullable(unfurlLinks); } /** * @return The value of the {@code unfurlMedia} attribute */ @JsonProperty @Override public Optional getUnfurlMedia() { return Optional.ofNullable(unfurlMedia); } /** * Copy the current immutable object by setting a present value for the optional {@link ChatScheduleMessageParamsIF#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 ChatScheduleMessageParams withText(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.text, newValue)) return this; return validate(new ChatScheduleMessageParams( newValue, this.attachments, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object by setting an optional value for the {@link ChatScheduleMessageParamsIF#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 ChatScheduleMessageParams withText(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.text, value)) return this; return validate(new ChatScheduleMessageParams( value, this.attachments, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object with elements that replace the content of {@link ChatScheduleMessageParamsIF#getAttachments() attachments}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ChatScheduleMessageParams withAttachments(Attachment... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ChatScheduleMessageParams( this.text, newValue, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object with elements that replace the content of {@link ChatScheduleMessageParamsIF#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 ChatScheduleMessageParams withAttachments(Iterable elements) { if (this.attachments == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ChatScheduleMessageParams( this.text, newValue, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object with elements that replace the content of {@link ChatScheduleMessageParamsIF#getBlocks() blocks}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ChatScheduleMessageParams withBlocks(Block... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new ChatScheduleMessageParams( this.text, this.attachments, newValue, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object with elements that replace the content of {@link ChatScheduleMessageParamsIF#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 ChatScheduleMessageParams withBlocks(Iterable elements) { if (this.blocks == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new ChatScheduleMessageParams( this.text, this.attachments, newValue, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object by setting a value for the {@link ChatScheduleMessageParamsIF#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 ChatScheduleMessageParams withChannelId(String value) { String newValue = Objects.requireNonNull(value, "channelId"); if (this.channelId.equals(newValue)) return this; return validate(new ChatScheduleMessageParams( this.text, this.attachments, this.blocks, newValue, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object by setting a value for the {@link ChatScheduleMessageParamsIF#getPostAt() postAt} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for postAt * @return A modified copy of the {@code this} object */ public final ChatScheduleMessageParams withPostAt(long value) { if (this.postAt == value) return this; return validate(new ChatScheduleMessageParams( this.text, this.attachments, this.blocks, this.channelId, value, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object by setting a value for the {@link ChatScheduleMessageParamsIF#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 ChatScheduleMessageParams withShouldLinkNames(boolean value) { if (this.shouldLinkNames == value) return this; return validate(new ChatScheduleMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.postAt, value, this.parseMode, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object by setting a value for the {@link ChatScheduleMessageParamsIF#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 ChatScheduleMessageParams withParseMode(String value) { String newValue = Objects.requireNonNull(value, "parseMode"); if (this.parseMode.equals(newValue)) return this; return validate(new ChatScheduleMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, newValue, this.threadTs, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object by setting a value for the {@link ChatScheduleMessageParamsIF#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 ChatScheduleMessageParams withThreadTs(String value) { String newValue = Objects.requireNonNull(value, "threadTs"); if (this.threadTs.equals(newValue)) return this; return validate(new ChatScheduleMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, newValue, this.unfurlLinks, this.unfurlMedia)); } /** * Copy the current immutable object by setting a present value for the optional {@link ChatScheduleMessageParamsIF#getUnfurlLinks() unfurlLinks} attribute. * @param value The value for unfurlLinks, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ChatScheduleMessageParams withUnfurlLinks(@Nullable Boolean value) { @Nullable Boolean newValue = value; if (Objects.equals(this.unfurlLinks, newValue)) return this; return validate(new ChatScheduleMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, newValue, this.unfurlMedia)); } /** * Copy the current immutable object by setting an optional value for the {@link ChatScheduleMessageParamsIF#getUnfurlLinks() unfurlLinks} 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 unfurlLinks * @return A modified copy of {@code this} object */ public final ChatScheduleMessageParams withUnfurlLinks(Optional optional) { @Nullable Boolean value = optional.orElse(null); if (Objects.equals(this.unfurlLinks, value)) return this; return validate(new ChatScheduleMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, value, this.unfurlMedia)); } /** * Copy the current immutable object by setting a present value for the optional {@link ChatScheduleMessageParamsIF#getUnfurlMedia() unfurlMedia} attribute. * @param value The value for unfurlMedia, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ChatScheduleMessageParams withUnfurlMedia(@Nullable Boolean value) { @Nullable Boolean newValue = value; if (Objects.equals(this.unfurlMedia, newValue)) return this; return validate(new ChatScheduleMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, newValue)); } /** * Copy the current immutable object by setting an optional value for the {@link ChatScheduleMessageParamsIF#getUnfurlMedia() unfurlMedia} 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 unfurlMedia * @return A modified copy of {@code this} object */ public final ChatScheduleMessageParams withUnfurlMedia(Optional optional) { @Nullable Boolean value = optional.orElse(null); if (Objects.equals(this.unfurlMedia, value)) return this; return validate(new ChatScheduleMessageParams( this.text, this.attachments, this.blocks, this.channelId, this.postAt, this.shouldLinkNames, this.parseMode, this.threadTs, this.unfurlLinks, value)); } /** * This instance is equal to all instances of {@code ChatScheduleMessageParams} 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 ChatScheduleMessageParams && equalTo(0, (ChatScheduleMessageParams) another); } private boolean equalTo(int synthetic, ChatScheduleMessageParams another) { return Objects.equals(text, another.text) && attachments.equals(another.attachments) && blocks.equals(another.blocks) && channelId.equals(another.channelId) && postAt == another.postAt && shouldLinkNames == another.shouldLinkNames && parseMode.equals(another.parseMode) && threadTs.equals(another.threadTs) && Objects.equals(unfurlLinks, another.unfurlLinks) && Objects.equals(unfurlMedia, another.unfurlMedia); } /** * Computes a hash code from attributes: {@code text}, {@code attachments}, {@code blocks}, {@code channelId}, {@code postAt}, {@code shouldLinkNames}, {@code parseMode}, {@code threadTs}, {@code unfurlLinks}, {@code unfurlMedia}. * @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) + Long.hashCode(postAt); h += (h << 5) + Boolean.hashCode(shouldLinkNames); h += (h << 5) + parseMode.hashCode(); h += (h << 5) + threadTs.hashCode(); h += (h << 5) + Objects.hashCode(unfurlLinks); h += (h << 5) + Objects.hashCode(unfurlMedia); return h; } /** * Prints the immutable value {@code ChatScheduleMessageParams} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ChatScheduleMessageParams{"); if (text != null) { builder.append("text=").append(text); } if (builder.length() > 26) 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("postAt=").append(postAt); builder.append(", "); builder.append("shouldLinkNames=").append(shouldLinkNames); builder.append(", "); builder.append("parseMode=").append(parseMode); builder.append(", "); builder.append("threadTs=").append(threadTs); if (unfurlLinks != null) { builder.append(", "); builder.append("unfurlLinks=").append(unfurlLinks); } if (unfurlMedia != null) { builder.append(", "); builder.append("unfurlMedia=").append(unfurlMedia); } 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 = "ChatScheduleMessageParamsIF", generator = "Immutables") @Deprecated @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ChatScheduleMessageParamsIF { @Nullable Optional text = Optional.empty(); @Nullable List attachments = Collections.emptyList(); @Nullable List blocks = Collections.emptyList(); boolean blocksIsSet; @Nullable String channelId; long postAt; boolean postAtIsSet; boolean shouldLinkNames; boolean shouldLinkNamesIsSet; @Nullable String parseMode; @Nullable String threadTs; @Nullable Optional unfurlLinks = Optional.empty(); @Nullable Optional unfurlMedia = Optional.empty(); @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 public void setPostAt(long postAt) { this.postAt = postAt; this.postAtIsSet = true; } @JsonProperty("link_names") public void setShouldLinkNames(boolean shouldLinkNames) { this.shouldLinkNames = shouldLinkNames; this.shouldLinkNamesIsSet = true; } @JsonProperty("parse") public void setParseMode(String parseMode) { this.parseMode = parseMode; } @JsonProperty public void setThreadTs(String threadTs) { this.threadTs = threadTs; } @JsonProperty public void setUnfurlLinks(Optional unfurlLinks) { this.unfurlLinks = unfurlLinks; } @JsonProperty public void setUnfurlMedia(Optional unfurlMedia) { this.unfurlMedia = unfurlMedia; } @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 long getPostAt() { throw new UnsupportedOperationException(); } @Override public boolean getShouldLinkNames() { throw new UnsupportedOperationException(); } @Override public String getParseMode() { throw new UnsupportedOperationException(); } @Override public String getThreadTs() { throw new UnsupportedOperationException(); } @Override public Optional getUnfurlLinks() { throw new UnsupportedOperationException(); } @Override public Optional getUnfurlMedia() { 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 ChatScheduleMessageParams fromJson(Json json) { ChatScheduleMessageParams.Builder builder = ChatScheduleMessageParams.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.postAtIsSet) { builder.setPostAt(json.postAt); } if (json.shouldLinkNamesIsSet) { builder.setShouldLinkNames(json.shouldLinkNames); } if (json.parseMode != null) { builder.setParseMode(json.parseMode); } if (json.threadTs != null) { builder.setThreadTs(json.threadTs); } if (json.unfurlLinks != null) { builder.setUnfurlLinks(json.unfurlLinks); } if (json.unfurlMedia != null) { builder.setUnfurlMedia(json.unfurlMedia); } return builder.build(); } private static ChatScheduleMessageParams validate(ChatScheduleMessageParams instance) { instance.check(); return instance; } /** * Creates an immutable copy of a {@link ChatScheduleMessageParamsIF} 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 ChatScheduleMessageParams instance */ public static ChatScheduleMessageParams copyOf(ChatScheduleMessageParamsIF instance) { if (instance instanceof ChatScheduleMessageParams) { return (ChatScheduleMessageParams) instance; } return ChatScheduleMessageParams.builder() .from(instance) .build(); } /** * Creates a builder for {@link ChatScheduleMessageParams ChatScheduleMessageParams}. *

   * ChatScheduleMessageParams.builder()
   *    .setText(String) // optional {@link ChatScheduleMessageParamsIF#getText() text}
   *    .addAttachments|addAllAttachments(com.hubspot.slack.client.models.Attachment) // {@link ChatScheduleMessageParamsIF#getAttachments() attachments} elements
   *    .addBlocks|addAllBlocks(com.hubspot.slack.client.models.blocks.Block) // {@link ChatScheduleMessageParamsIF#getBlocks() blocks} elements
   *    .setChannelId(String) // required {@link ChatScheduleMessageParamsIF#getChannelId() channelId}
   *    .setPostAt(long) // required {@link ChatScheduleMessageParamsIF#getPostAt() postAt}
   *    .setShouldLinkNames(boolean) // optional {@link ChatScheduleMessageParamsIF#getShouldLinkNames() shouldLinkNames}
   *    .setParseMode(String) // optional {@link ChatScheduleMessageParamsIF#getParseMode() parseMode}
   *    .setThreadTs(String) // optional {@link ChatScheduleMessageParamsIF#getThreadTs() threadTs}
   *    .setUnfurlLinks(Boolean) // optional {@link ChatScheduleMessageParamsIF#getUnfurlLinks() unfurlLinks}
   *    .setUnfurlMedia(Boolean) // optional {@link ChatScheduleMessageParamsIF#getUnfurlMedia() unfurlMedia}
   *    .build();
   * 
* @return A new ChatScheduleMessageParams builder */ public static ChatScheduleMessageParams.Builder builder() { return new ChatScheduleMessageParams.Builder(); } /** * Builds instances of type {@link ChatScheduleMessageParams ChatScheduleMessageParams}. * 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 = "ChatScheduleMessageParamsIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_CHANNEL_ID = 0x1L; private static final long INIT_BIT_POST_AT = 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 long postAt; private boolean shouldLinkNames; private @Nullable String parseMode; private @Nullable String threadTs; private @Nullable Boolean unfurlLinks; private @Nullable Boolean unfurlMedia; 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.ChatScheduleMessageParamsIF} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ChatScheduleMessageParamsIF 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 ChatScheduleMessageParamsIF) { ChatScheduleMessageParamsIF instance = (ChatScheduleMessageParamsIF) object; Optional unfurlMediaOptional = instance.getUnfurlMedia(); if (unfurlMediaOptional.isPresent()) { setUnfurlMedia(unfurlMediaOptional); } if ((bits & 0x1L) == 0) { addAllAttachments(instance.getAttachments()); bits |= 0x1L; } this.setPostAt(instance.getPostAt()); Optional unfurlLinksOptional = instance.getUnfurlLinks(); if (unfurlLinksOptional.isPresent()) { setUnfurlLinks(unfurlLinksOptional); } 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()); this.setThreadTs(instance.getThreadTs()); if ((bits & 0x8L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x8L; } } } /** * Initializes the optional value {@link ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#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 ChatScheduleMessageParamsIF#getPostAt() postAt} attribute. * @param postAt The value for postAt * @return {@code this} builder for use in a chained invocation */ public final Builder setPostAt(long postAt) { this.postAt = postAt; initBits &= ~INIT_BIT_POST_AT; return this; } /** * Initializes the value for the {@link ChatScheduleMessageParamsIF#getShouldLinkNames() shouldLinkNames} attribute. *

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

If not set, this attribute will have a default value as returned by the initializer of {@link ChatScheduleMessageParamsIF#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; } /** * Initializes the value for the {@link ChatScheduleMessageParamsIF#getThreadTs() threadTs} attribute. *

If not set, this attribute will have a default value as returned by the initializer of {@link ChatScheduleMessageParamsIF#getThreadTs() threadTs}. * @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"); return this; } /** * Initializes the optional value {@link ChatScheduleMessageParamsIF#getUnfurlLinks() unfurlLinks} to unfurlLinks. * @param unfurlLinks The value for unfurlLinks, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setUnfurlLinks(@Nullable Boolean unfurlLinks) { this.unfurlLinks = unfurlLinks; return this; } /** * Initializes the optional value {@link ChatScheduleMessageParamsIF#getUnfurlLinks() unfurlLinks} to unfurlLinks. * @param unfurlLinks The value for unfurlLinks * @return {@code this} builder for use in a chained invocation */ public final Builder setUnfurlLinks(Optional unfurlLinks) { this.unfurlLinks = unfurlLinks.orElse(null); return this; } /** * Initializes the optional value {@link ChatScheduleMessageParamsIF#getUnfurlMedia() unfurlMedia} to unfurlMedia. * @param unfurlMedia The value for unfurlMedia, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setUnfurlMedia(@Nullable Boolean unfurlMedia) { this.unfurlMedia = unfurlMedia; return this; } /** * Initializes the optional value {@link ChatScheduleMessageParamsIF#getUnfurlMedia() unfurlMedia} to unfurlMedia. * @param unfurlMedia The value for unfurlMedia * @return {@code this} builder for use in a chained invocation */ public final Builder setUnfurlMedia(Optional unfurlMedia) { this.unfurlMedia = unfurlMedia.orElse(null); return this; } /** * Builds a new {@link ChatScheduleMessageParams ChatScheduleMessageParams}. * @return An immutable instance of ChatScheduleMessageParams * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public ChatScheduleMessageParams build() { checkRequiredAttributes(); return ChatScheduleMessageParams.validate(new ChatScheduleMessageParams(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 postAtIsSet() { return (initBits & INIT_BIT_POST_AT) == 0; } private void checkRequiredAttributes() { if (initBits != 0) { throw new InvalidImmutableStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!channelIdIsSet()) attributes.add("channelId"); if (!postAtIsSet()) attributes.add("postAt"); return "Cannot build ChatScheduleMessageParams, 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