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

com.hubspot.slack.client.models.views.ModalViewPayload Maven / Gradle / Ivy

There is a newer version: 1.16.7
Show newest version
package com.hubspot.slack.client.models.views;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.models.blocks.Block;
import com.hubspot.slack.client.models.blocks.objects.Text;
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 ModalViewPayloadIF}.
 * 

* Use the builder to create immutable instances: * {@code ModalViewPayload.builder()}. * Use the static factory method to create immutable instances: * {@code ModalViewPayload.of()}. */ @Generated(from = "ModalViewPayloadIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ModalViewPayload implements ModalViewPayloadIF { private final @Nullable String privateMetadata; private final @Nullable String callbackId; private final @Nullable String externalId; private transient final String type; private final @Nullable Text closeButtonText; private final @Nullable Text submitButtonText; private final @Nullable Boolean clearOnClose; private final @Nullable Boolean notifyOnClose; private final Text title; private final List blocks; private ModalViewPayload( Text title, Iterable blocks) { this.title = Objects.requireNonNull(title, "title"); this.blocks = createUnmodifiableList(false, createSafeList(blocks, true, false)); this.privateMetadata = null; this.callbackId = null; this.externalId = null; this.closeButtonText = null; this.submitButtonText = null; this.clearOnClose = null; this.notifyOnClose = null; this.type = Objects.requireNonNull(ModalViewPayloadIF.super.getType(), "type"); } private ModalViewPayload( @Nullable String privateMetadata, @Nullable String callbackId, @Nullable String externalId, @Nullable Text closeButtonText, @Nullable Text submitButtonText, @Nullable Boolean clearOnClose, @Nullable Boolean notifyOnClose, Text title, List blocks) { this.privateMetadata = privateMetadata; this.callbackId = callbackId; this.externalId = externalId; this.closeButtonText = closeButtonText; this.submitButtonText = submitButtonText; this.clearOnClose = clearOnClose; this.notifyOnClose = notifyOnClose; this.title = title; this.blocks = blocks; this.type = Objects.requireNonNull(ModalViewPayloadIF.super.getType(), "type"); } /** * @return The value of the {@code privateMetadata} attribute */ @JsonProperty @Override public Optional getPrivateMetadata() { return Optional.ofNullable(privateMetadata); } /** * @return The value of the {@code callbackId} attribute */ @JsonProperty @Override public Optional getCallbackId() { return Optional.ofNullable(callbackId); } /** * @return The value of the {@code externalId} attribute */ @JsonProperty @Override public Optional getExternalId() { return Optional.ofNullable(externalId); } /** * @return The computed-at-construction value of the {@code type} attribute */ @JsonProperty @Override public String getType() { return type; } /** * @return The value of the {@code closeButtonText} attribute */ @JsonProperty("close") @Override public Optional getCloseButtonText() { return Optional.ofNullable(closeButtonText); } /** * @return The value of the {@code submitButtonText} attribute */ @JsonProperty("submit") @Override public Optional getSubmitButtonText() { return Optional.ofNullable(submitButtonText); } /** * @return The value of the {@code clearOnClose} attribute */ @JsonProperty @Override public Optional getClearOnClose() { return Optional.ofNullable(clearOnClose); } /** * @return The value of the {@code notifyOnClose} attribute */ @JsonProperty @Override public Optional getNotifyOnClose() { return Optional.ofNullable(notifyOnClose); } /** * @return The value of the {@code title} attribute */ @JsonProperty @Override public Text getTitle() { return title; } /** * @return The value of the {@code blocks} attribute */ @JsonProperty @Override public List getBlocks() { return blocks; } /** * Copy the current immutable object by setting a present value for the optional {@link ModalViewPayloadIF#getPrivateMetadata() privateMetadata} attribute. * @param value The value for privateMetadata, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ModalViewPayload withPrivateMetadata(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.privateMetadata, newValue)) return this; return new ModalViewPayload( newValue, this.callbackId, this.externalId, this.closeButtonText, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting an optional value for the {@link ModalViewPayloadIF#getPrivateMetadata() privateMetadata} 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 privateMetadata * @return A modified copy of {@code this} object */ public final ModalViewPayload withPrivateMetadata(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.privateMetadata, value)) return this; return new ModalViewPayload( value, this.callbackId, this.externalId, this.closeButtonText, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting a present value for the optional {@link ModalViewPayloadIF#getCallbackId() callbackId} attribute. * @param value The value for callbackId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ModalViewPayload withCallbackId(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.callbackId, newValue)) return this; return new ModalViewPayload( this.privateMetadata, newValue, this.externalId, this.closeButtonText, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting an optional value for the {@link ModalViewPayloadIF#getCallbackId() callbackId} 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 callbackId * @return A modified copy of {@code this} object */ public final ModalViewPayload withCallbackId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.callbackId, value)) return this; return new ModalViewPayload( this.privateMetadata, value, this.externalId, this.closeButtonText, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting a present value for the optional {@link ModalViewPayloadIF#getExternalId() externalId} attribute. * @param value The value for externalId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ModalViewPayload withExternalId(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.externalId, newValue)) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, newValue, this.closeButtonText, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting an optional value for the {@link ModalViewPayloadIF#getExternalId() externalId} 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 externalId * @return A modified copy of {@code this} object */ public final ModalViewPayload withExternalId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.externalId, value)) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, value, this.closeButtonText, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting a present value for the optional {@link ModalViewPayloadIF#getCloseButtonText() closeButtonText} attribute. * @param value The value for closeButtonText, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ModalViewPayload withCloseButtonText(@Nullable Text value) { @Nullable Text newValue = value; if (this.closeButtonText == newValue) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, newValue, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting an optional value for the {@link ModalViewPayloadIF#getCloseButtonText() closeButtonText} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for closeButtonText * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final ModalViewPayload withCloseButtonText(Optional optional) { @Nullable Text value = optional.orElse(null); if (this.closeButtonText == value) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, value, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting a present value for the optional {@link ModalViewPayloadIF#getSubmitButtonText() submitButtonText} attribute. * @param value The value for submitButtonText, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ModalViewPayload withSubmitButtonText(@Nullable Text value) { @Nullable Text newValue = value; if (this.submitButtonText == newValue) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, this.closeButtonText, newValue, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting an optional value for the {@link ModalViewPayloadIF#getSubmitButtonText() submitButtonText} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for submitButtonText * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final ModalViewPayload withSubmitButtonText(Optional optional) { @Nullable Text value = optional.orElse(null); if (this.submitButtonText == value) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, this.closeButtonText, value, this.clearOnClose, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting a present value for the optional {@link ModalViewPayloadIF#getClearOnClose() clearOnClose} attribute. * @param value The value for clearOnClose, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ModalViewPayload withClearOnClose(@Nullable Boolean value) { @Nullable Boolean newValue = value; if (Objects.equals(this.clearOnClose, newValue)) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, this.closeButtonText, this.submitButtonText, newValue, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting an optional value for the {@link ModalViewPayloadIF#getClearOnClose() clearOnClose} 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 clearOnClose * @return A modified copy of {@code this} object */ public final ModalViewPayload withClearOnClose(Optional optional) { @Nullable Boolean value = optional.orElse(null); if (Objects.equals(this.clearOnClose, value)) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, this.closeButtonText, this.submitButtonText, value, this.notifyOnClose, this.title, this.blocks); } /** * Copy the current immutable object by setting a present value for the optional {@link ModalViewPayloadIF#getNotifyOnClose() notifyOnClose} attribute. * @param value The value for notifyOnClose, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ModalViewPayload withNotifyOnClose(@Nullable Boolean value) { @Nullable Boolean newValue = value; if (Objects.equals(this.notifyOnClose, newValue)) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, this.closeButtonText, this.submitButtonText, this.clearOnClose, newValue, this.title, this.blocks); } /** * Copy the current immutable object by setting an optional value for the {@link ModalViewPayloadIF#getNotifyOnClose() notifyOnClose} 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 notifyOnClose * @return A modified copy of {@code this} object */ public final ModalViewPayload withNotifyOnClose(Optional optional) { @Nullable Boolean value = optional.orElse(null); if (Objects.equals(this.notifyOnClose, value)) return this; return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, this.closeButtonText, this.submitButtonText, this.clearOnClose, value, this.title, this.blocks); } /** * Copy the current immutable object by setting a value for the {@link ModalViewPayloadIF#getTitle() title} attribute. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for title * @return A modified copy of the {@code this} object */ public final ModalViewPayload withTitle(Text value) { if (this.title == value) return this; Text newValue = Objects.requireNonNull(value, "title"); return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, this.closeButtonText, this.submitButtonText, this.clearOnClose, this.notifyOnClose, newValue, this.blocks); } /** * Copy the current immutable object with elements that replace the content of {@link ModalViewPayloadIF#getBlocks() blocks}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ModalViewPayload withBlocks(Block... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, this.closeButtonText, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link ModalViewPayloadIF#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 ModalViewPayload withBlocks(Iterable elements) { if (this.blocks == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new ModalViewPayload( this.privateMetadata, this.callbackId, this.externalId, this.closeButtonText, this.submitButtonText, this.clearOnClose, this.notifyOnClose, this.title, newValue); } /** * This instance is equal to all instances of {@code ModalViewPayload} 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 ModalViewPayload && equalTo(0, (ModalViewPayload) another); } private boolean equalTo(int synthetic, ModalViewPayload another) { return Objects.equals(privateMetadata, another.privateMetadata) && Objects.equals(callbackId, another.callbackId) && Objects.equals(externalId, another.externalId) && type.equals(another.type) && Objects.equals(closeButtonText, another.closeButtonText) && Objects.equals(submitButtonText, another.submitButtonText) && Objects.equals(clearOnClose, another.clearOnClose) && Objects.equals(notifyOnClose, another.notifyOnClose) && title.equals(another.title) && blocks.equals(another.blocks); } /** * Computes a hash code from attributes: {@code privateMetadata}, {@code callbackId}, {@code externalId}, {@code type}, {@code closeButtonText}, {@code submitButtonText}, {@code clearOnClose}, {@code notifyOnClose}, {@code title}, {@code blocks}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(privateMetadata); h += (h << 5) + Objects.hashCode(callbackId); h += (h << 5) + Objects.hashCode(externalId); h += (h << 5) + type.hashCode(); h += (h << 5) + Objects.hashCode(closeButtonText); h += (h << 5) + Objects.hashCode(submitButtonText); h += (h << 5) + Objects.hashCode(clearOnClose); h += (h << 5) + Objects.hashCode(notifyOnClose); h += (h << 5) + title.hashCode(); h += (h << 5) + blocks.hashCode(); return h; } /** * Prints the immutable value {@code ModalViewPayload} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ModalViewPayload{"); if (privateMetadata != null) { builder.append("privateMetadata=").append(privateMetadata); } if (callbackId != null) { if (builder.length() > 17) builder.append(", "); builder.append("callbackId=").append(callbackId); } if (externalId != null) { if (builder.length() > 17) builder.append(", "); builder.append("externalId=").append(externalId); } if (builder.length() > 17) builder.append(", "); builder.append("type=").append(type); if (closeButtonText != null) { builder.append(", "); builder.append("closeButtonText=").append(closeButtonText); } if (submitButtonText != null) { builder.append(", "); builder.append("submitButtonText=").append(submitButtonText); } if (clearOnClose != null) { builder.append(", "); builder.append("clearOnClose=").append(clearOnClose); } if (notifyOnClose != null) { builder.append(", "); builder.append("notifyOnClose=").append(notifyOnClose); } builder.append(", "); builder.append("title=").append(title); builder.append(", "); builder.append("blocks=").append(blocks); 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 = "ModalViewPayloadIF", generator = "Immutables") @Deprecated @JsonTypeInfo(use=JsonTypeInfo.Id.NONE) @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ModalViewPayloadIF { @Nullable Optional privateMetadata = Optional.empty(); @Nullable Optional callbackId = Optional.empty(); @Nullable Optional externalId = Optional.empty(); @Nullable Optional closeButtonText = Optional.empty(); @Nullable Optional submitButtonText = Optional.empty(); @Nullable Optional clearOnClose = Optional.empty(); @Nullable Optional notifyOnClose = Optional.empty(); @Nullable Text title; @Nullable List blocks = Collections.emptyList(); @JsonProperty public void setPrivateMetadata(Optional privateMetadata) { this.privateMetadata = privateMetadata; } @JsonProperty public void setCallbackId(Optional callbackId) { this.callbackId = callbackId; } @JsonProperty public void setExternalId(Optional externalId) { this.externalId = externalId; } @JsonProperty("close") public void setCloseButtonText(Optional closeButtonText) { this.closeButtonText = closeButtonText; } @JsonProperty("submit") public void setSubmitButtonText(Optional submitButtonText) { this.submitButtonText = submitButtonText; } @JsonProperty public void setClearOnClose(Optional clearOnClose) { this.clearOnClose = clearOnClose; } @JsonProperty public void setNotifyOnClose(Optional notifyOnClose) { this.notifyOnClose = notifyOnClose; } @JsonProperty public void setTitle(Text title) { this.title = title; } @JsonProperty public void setBlocks(List blocks) { this.blocks = blocks; } @Override public Optional getPrivateMetadata() { throw new UnsupportedOperationException(); } @Override public Optional getCallbackId() { throw new UnsupportedOperationException(); } @Override public Optional getExternalId() { throw new UnsupportedOperationException(); } @JsonIgnore @Override public String getType() { throw new UnsupportedOperationException(); } @Override public Optional getCloseButtonText() { throw new UnsupportedOperationException(); } @Override public Optional getSubmitButtonText() { throw new UnsupportedOperationException(); } @Override public Optional getClearOnClose() { throw new UnsupportedOperationException(); } @Override public Optional getNotifyOnClose() { throw new UnsupportedOperationException(); } @Override public Text getTitle() { throw new UnsupportedOperationException(); } @Override public List getBlocks() { 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 ModalViewPayload fromJson(Json json) { ModalViewPayload.Builder builder = ModalViewPayload.builder(); if (json.privateMetadata != null) { builder.setPrivateMetadata(json.privateMetadata); } if (json.callbackId != null) { builder.setCallbackId(json.callbackId); } if (json.externalId != null) { builder.setExternalId(json.externalId); } if (json.closeButtonText != null) { builder.setCloseButtonText(json.closeButtonText); } if (json.submitButtonText != null) { builder.setSubmitButtonText(json.submitButtonText); } if (json.clearOnClose != null) { builder.setClearOnClose(json.clearOnClose); } if (json.notifyOnClose != null) { builder.setNotifyOnClose(json.notifyOnClose); } if (json.title != null) { builder.setTitle(json.title); } if (json.blocks != null) { builder.addAllBlocks(json.blocks); } return builder.build(); } /** * Construct a new immutable {@code ModalViewPayload} instance. * @param title The value for the {@code title} attribute * @param blocks The value for the {@code blocks} attribute * @return An immutable ModalViewPayload instance */ public static ModalViewPayload of(Text title, List blocks) { return of(title, (Iterable) blocks); } /** * Construct a new immutable {@code ModalViewPayload} instance. * @param title The value for the {@code title} attribute * @param blocks The value for the {@code blocks} attribute * @return An immutable ModalViewPayload instance */ public static ModalViewPayload of(Text title, Iterable blocks) { return new ModalViewPayload(title, blocks); } /** * Creates an immutable copy of a {@link ModalViewPayloadIF} 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 ModalViewPayload instance */ public static ModalViewPayload copyOf(ModalViewPayloadIF instance) { if (instance instanceof ModalViewPayload) { return (ModalViewPayload) instance; } return ModalViewPayload.builder() .from(instance) .build(); } /** * Creates a builder for {@link ModalViewPayload ModalViewPayload}. *

   * ModalViewPayload.builder()
   *    .setPrivateMetadata(String) // optional {@link ModalViewPayloadIF#getPrivateMetadata() privateMetadata}
   *    .setCallbackId(String) // optional {@link ModalViewPayloadIF#getCallbackId() callbackId}
   *    .setExternalId(String) // optional {@link ModalViewPayloadIF#getExternalId() externalId}
   *    .setCloseButtonText(com.hubspot.slack.client.models.blocks.objects.Text) // optional {@link ModalViewPayloadIF#getCloseButtonText() closeButtonText}
   *    .setSubmitButtonText(com.hubspot.slack.client.models.blocks.objects.Text) // optional {@link ModalViewPayloadIF#getSubmitButtonText() submitButtonText}
   *    .setClearOnClose(Boolean) // optional {@link ModalViewPayloadIF#getClearOnClose() clearOnClose}
   *    .setNotifyOnClose(Boolean) // optional {@link ModalViewPayloadIF#getNotifyOnClose() notifyOnClose}
   *    .setTitle(com.hubspot.slack.client.models.blocks.objects.Text) // required {@link ModalViewPayloadIF#getTitle() title}
   *    .addBlocks|addAllBlocks(com.hubspot.slack.client.models.blocks.Block) // {@link ModalViewPayloadIF#getBlocks() blocks} elements
   *    .build();
   * 
* @return A new ModalViewPayload builder */ public static ModalViewPayload.Builder builder() { return new ModalViewPayload.Builder(); } /** * Builds instances of type {@link ModalViewPayload ModalViewPayload}. * 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 = "ModalViewPayloadIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_TITLE = 0x1L; private long initBits = 0x1L; private @Nullable String privateMetadata; private @Nullable String callbackId; private @Nullable String externalId; private @Nullable Text closeButtonText; private @Nullable Text submitButtonText; private @Nullable Boolean clearOnClose; private @Nullable Boolean notifyOnClose; private @Nullable Text title; private List blocks = new ArrayList(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.views.ModalViewPayloadIF} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ModalViewPayloadIF instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.views.ModalViewPayloadBase} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ModalViewPayloadBase instance) { Objects.requireNonNull(instance, "instance"); from((short) 0, (Object) instance); return this; } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.views.ViewPayloadBase} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ViewPayloadBase 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 ModalViewPayloadIF) { ModalViewPayloadIF instance = (ModalViewPayloadIF) object; if ((bits & 0x1L) == 0) { Optional closeButtonTextOptional = instance.getCloseButtonText(); if (closeButtonTextOptional.isPresent()) { setCloseButtonText(closeButtonTextOptional); } bits |= 0x1L; } if ((bits & 0x40L) == 0) { Optional callbackIdOptional = instance.getCallbackId(); if (callbackIdOptional.isPresent()) { setCallbackId(callbackIdOptional); } bits |= 0x40L; } if ((bits & 0x2L) == 0) { addAllBlocks(instance.getBlocks()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { Optional externalIdOptional = instance.getExternalId(); if (externalIdOptional.isPresent()) { setExternalId(externalIdOptional); } bits |= 0x4L; } if ((bits & 0x8L) == 0) { Optional privateMetadataOptional = instance.getPrivateMetadata(); if (privateMetadataOptional.isPresent()) { setPrivateMetadata(privateMetadataOptional); } bits |= 0x8L; } if ((bits & 0x80L) == 0) { Optional submitButtonTextOptional = instance.getSubmitButtonText(); if (submitButtonTextOptional.isPresent()) { setSubmitButtonText(submitButtonTextOptional); } bits |= 0x80L; } if ((bits & 0x100L) == 0) { Optional notifyOnCloseOptional = instance.getNotifyOnClose(); if (notifyOnCloseOptional.isPresent()) { setNotifyOnClose(notifyOnCloseOptional); } bits |= 0x100L; } if ((bits & 0x10L) == 0) { Optional clearOnCloseOptional = instance.getClearOnClose(); if (clearOnCloseOptional.isPresent()) { setClearOnClose(clearOnCloseOptional); } bits |= 0x10L; } if ((bits & 0x20L) == 0) { this.setTitle(instance.getTitle()); bits |= 0x20L; } } if (object instanceof ModalViewPayloadBase) { ModalViewPayloadBase instance = (ModalViewPayloadBase) object; if ((bits & 0x1L) == 0) { Optional closeButtonTextOptional = instance.getCloseButtonText(); if (closeButtonTextOptional.isPresent()) { setCloseButtonText(closeButtonTextOptional); } bits |= 0x1L; } if ((bits & 0x40L) == 0) { Optional callbackIdOptional = instance.getCallbackId(); if (callbackIdOptional.isPresent()) { setCallbackId(callbackIdOptional); } bits |= 0x40L; } if ((bits & 0x2L) == 0) { addAllBlocks(instance.getBlocks()); bits |= 0x2L; } if ((bits & 0x4L) == 0) { Optional externalIdOptional = instance.getExternalId(); if (externalIdOptional.isPresent()) { setExternalId(externalIdOptional); } bits |= 0x4L; } if ((bits & 0x8L) == 0) { Optional privateMetadataOptional = instance.getPrivateMetadata(); if (privateMetadataOptional.isPresent()) { setPrivateMetadata(privateMetadataOptional); } bits |= 0x8L; } if ((bits & 0x80L) == 0) { Optional submitButtonTextOptional = instance.getSubmitButtonText(); if (submitButtonTextOptional.isPresent()) { setSubmitButtonText(submitButtonTextOptional); } bits |= 0x80L; } if ((bits & 0x100L) == 0) { Optional notifyOnCloseOptional = instance.getNotifyOnClose(); if (notifyOnCloseOptional.isPresent()) { setNotifyOnClose(notifyOnCloseOptional); } bits |= 0x100L; } if ((bits & 0x10L) == 0) { Optional clearOnCloseOptional = instance.getClearOnClose(); if (clearOnCloseOptional.isPresent()) { setClearOnClose(clearOnCloseOptional); } bits |= 0x10L; } if ((bits & 0x20L) == 0) { this.setTitle(instance.getTitle()); bits |= 0x20L; } } if (object instanceof ViewPayloadBase) { ViewPayloadBase instance = (ViewPayloadBase) object; if ((bits & 0x4L) == 0) { Optional externalIdOptional = instance.getExternalId(); if (externalIdOptional.isPresent()) { setExternalId(externalIdOptional); } bits |= 0x4L; } if ((bits & 0x8L) == 0) { Optional privateMetadataOptional = instance.getPrivateMetadata(); if (privateMetadataOptional.isPresent()) { setPrivateMetadata(privateMetadataOptional); } bits |= 0x8L; } if ((bits & 0x40L) == 0) { Optional callbackIdOptional = instance.getCallbackId(); if (callbackIdOptional.isPresent()) { setCallbackId(callbackIdOptional); } bits |= 0x40L; } if ((bits & 0x2L) == 0) { addAllBlocks(instance.getBlocks()); bits |= 0x2L; } } } /** * Initializes the optional value {@link ModalViewPayloadIF#getPrivateMetadata() privateMetadata} to privateMetadata. * @param privateMetadata The value for privateMetadata, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setPrivateMetadata(@Nullable String privateMetadata) { this.privateMetadata = privateMetadata; return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getPrivateMetadata() privateMetadata} to privateMetadata. * @param privateMetadata The value for privateMetadata * @return {@code this} builder for use in a chained invocation */ public final Builder setPrivateMetadata(Optional privateMetadata) { this.privateMetadata = privateMetadata.orElse(null); return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getCallbackId() callbackId} to callbackId. * @param callbackId The value for callbackId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setCallbackId(@Nullable String callbackId) { this.callbackId = callbackId; return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getCallbackId() callbackId} to callbackId. * @param callbackId The value for callbackId * @return {@code this} builder for use in a chained invocation */ public final Builder setCallbackId(Optional callbackId) { this.callbackId = callbackId.orElse(null); return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getExternalId() externalId} to externalId. * @param externalId The value for externalId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setExternalId(@Nullable String externalId) { this.externalId = externalId; return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getExternalId() externalId} to externalId. * @param externalId The value for externalId * @return {@code this} builder for use in a chained invocation */ public final Builder setExternalId(Optional externalId) { this.externalId = externalId.orElse(null); return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getCloseButtonText() closeButtonText} to closeButtonText. * @param closeButtonText The value for closeButtonText, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setCloseButtonText(@Nullable Text closeButtonText) { this.closeButtonText = closeButtonText; return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getCloseButtonText() closeButtonText} to closeButtonText. * @param closeButtonText The value for closeButtonText * @return {@code this} builder for use in a chained invocation */ public final Builder setCloseButtonText(Optional closeButtonText) { this.closeButtonText = closeButtonText.orElse(null); return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getSubmitButtonText() submitButtonText} to submitButtonText. * @param submitButtonText The value for submitButtonText, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setSubmitButtonText(@Nullable Text submitButtonText) { this.submitButtonText = submitButtonText; return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getSubmitButtonText() submitButtonText} to submitButtonText. * @param submitButtonText The value for submitButtonText * @return {@code this} builder for use in a chained invocation */ public final Builder setSubmitButtonText(Optional submitButtonText) { this.submitButtonText = submitButtonText.orElse(null); return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getClearOnClose() clearOnClose} to clearOnClose. * @param clearOnClose The value for clearOnClose, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setClearOnClose(@Nullable Boolean clearOnClose) { this.clearOnClose = clearOnClose; return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getClearOnClose() clearOnClose} to clearOnClose. * @param clearOnClose The value for clearOnClose * @return {@code this} builder for use in a chained invocation */ public final Builder setClearOnClose(Optional clearOnClose) { this.clearOnClose = clearOnClose.orElse(null); return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getNotifyOnClose() notifyOnClose} to notifyOnClose. * @param notifyOnClose The value for notifyOnClose, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setNotifyOnClose(@Nullable Boolean notifyOnClose) { this.notifyOnClose = notifyOnClose; return this; } /** * Initializes the optional value {@link ModalViewPayloadIF#getNotifyOnClose() notifyOnClose} to notifyOnClose. * @param notifyOnClose The value for notifyOnClose * @return {@code this} builder for use in a chained invocation */ public final Builder setNotifyOnClose(Optional notifyOnClose) { this.notifyOnClose = notifyOnClose.orElse(null); return this; } /** * Initializes the value for the {@link ModalViewPayloadIF#getTitle() title} attribute. * @param title The value for title * @return {@code this} builder for use in a chained invocation */ public final Builder setTitle(Text title) { this.title = Objects.requireNonNull(title, "title"); initBits &= ~INIT_BIT_TITLE; return this; } /** * Adds one element to {@link ModalViewPayloadIF#getBlocks() blocks} list. * @param element A blocks element * @return {@code this} builder for use in a chained invocation */ public final Builder addBlocks(Block element) { this.blocks.add(Objects.requireNonNull(element, "blocks element")); return this; } /** * Adds elements to {@link ModalViewPayloadIF#getBlocks() blocks} list. * @param elements An array of blocks elements * @return {@code this} builder for use in a chained invocation */ public final Builder addBlocks(Block... elements) { for (Block element : elements) { this.blocks.add(Objects.requireNonNull(element, "blocks element")); } return this; } /** * Sets or replaces all elements for {@link ModalViewPayloadIF#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 ModalViewPayloadIF#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")); } return this; } /** * Builds a new {@link ModalViewPayload ModalViewPayload}. * @return An immutable instance of ModalViewPayload * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public ModalViewPayload build() { checkRequiredAttributes(); return new ModalViewPayload( privateMetadata, callbackId, externalId, closeButtonText, submitButtonText, clearOnClose, notifyOnClose, title, createUnmodifiableList(true, blocks)); } private boolean titleIsSet() { return (initBits & INIT_BIT_TITLE) == 0; } private void checkRequiredAttributes() { if (initBits != 0) { throw new InvalidImmutableStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!titleIsSet()) attributes.add("title"); return "Cannot build ModalViewPayload, 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