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

com.hubspot.slack.client.methods.params.chat.ChatUnfurlParams 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.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.methods.interceptor.HasChannel;
import com.hubspot.slack.client.models.ChatUnfurlBlocksOrAttachment;
import com.hubspot.slack.client.models.json.BlockOrAttachmentDeserializer;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
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 ChatUnfurlParamsIF}.
 * 

* Use the builder to create immutable instances: * {@code ChatUnfurlParams.builder()}. */ @Generated(from = "ChatUnfurlParamsIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ChatUnfurlParams implements ChatUnfurlParamsIF { private final String channelId; private final String ts; private final Map unfurls; private final @Nullable Boolean userAuthRequired; private final @Nullable String userAuthMessage; private final @Nullable URI userAuthUrl; private ChatUnfurlParams( String channelId, String ts, Map unfurls, @Nullable Boolean userAuthRequired, @Nullable String userAuthMessage, @Nullable URI userAuthUrl) { this.channelId = channelId; this.ts = ts; this.unfurls = unfurls; this.userAuthRequired = userAuthRequired; this.userAuthMessage = userAuthMessage; this.userAuthUrl = userAuthUrl; } /** * @return The value of the {@code channelId} attribute */ @JsonProperty("channel") @Override public String getChannelId() { return channelId; } /** * @return The value of the {@code ts} attribute */ @JsonProperty @Override public String getTs() { return ts; } /** * @return The value of the {@code unfurls} attribute */ @JsonProperty @JsonDeserialize(contentUsing = BlockOrAttachmentDeserializer.class) @Override public Map getUnfurls() { return unfurls; } /** * @return The value of the {@code userAuthRequired} attribute */ @JsonProperty @Override public Optional isUserAuthRequired() { return Optional.ofNullable(userAuthRequired); } /** * @return The value of the {@code userAuthMessage} attribute */ @JsonProperty @Override public Optional getUserAuthMessage() { return Optional.ofNullable(userAuthMessage); } /** * @return The value of the {@code userAuthUrl} attribute */ @JsonProperty @Override public Optional getUserAuthUrl() { return Optional.ofNullable(userAuthUrl); } /** * Copy the current immutable object by setting a value for the {@link ChatUnfurlParamsIF#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 ChatUnfurlParams withChannelId(String value) { String newValue = Objects.requireNonNull(value, "channelId"); if (this.channelId.equals(newValue)) return this; return new ChatUnfurlParams(newValue, this.ts, this.unfurls, this.userAuthRequired, this.userAuthMessage, this.userAuthUrl); } /** * Copy the current immutable object by setting a value for the {@link ChatUnfurlParamsIF#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 ChatUnfurlParams withTs(String value) { String newValue = Objects.requireNonNull(value, "ts"); if (this.ts.equals(newValue)) return this; return new ChatUnfurlParams( this.channelId, newValue, this.unfurls, this.userAuthRequired, this.userAuthMessage, this.userAuthUrl); } /** * Copy the current immutable object by replacing the {@link ChatUnfurlParamsIF#getUnfurls() unfurls} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the unfurls map * @return A modified copy of {@code this} object */ public final ChatUnfurlParams withUnfurls(Map entries) { if (this.unfurls == entries) return this; Map newValue = createUnmodifiableMap(true, false, entries); return new ChatUnfurlParams( this.channelId, this.ts, newValue, this.userAuthRequired, this.userAuthMessage, this.userAuthUrl); } /** * Copy the current immutable object by setting a present value for the optional {@link ChatUnfurlParamsIF#isUserAuthRequired() userAuthRequired} attribute. * @param value The value for userAuthRequired, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ChatUnfurlParams withUserAuthRequired(@Nullable Boolean value) { @Nullable Boolean newValue = value; if (Objects.equals(this.userAuthRequired, newValue)) return this; return new ChatUnfurlParams(this.channelId, this.ts, this.unfurls, newValue, this.userAuthMessage, this.userAuthUrl); } /** * Copy the current immutable object by setting an optional value for the {@link ChatUnfurlParamsIF#isUserAuthRequired() userAuthRequired} 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 userAuthRequired * @return A modified copy of {@code this} object */ public final ChatUnfurlParams withUserAuthRequired(Optional optional) { @Nullable Boolean value = optional.orElse(null); if (Objects.equals(this.userAuthRequired, value)) return this; return new ChatUnfurlParams(this.channelId, this.ts, this.unfurls, value, this.userAuthMessage, this.userAuthUrl); } /** * Copy the current immutable object by setting a present value for the optional {@link ChatUnfurlParamsIF#getUserAuthMessage() userAuthMessage} attribute. * @param value The value for userAuthMessage, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ChatUnfurlParams withUserAuthMessage(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.userAuthMessage, newValue)) return this; return new ChatUnfurlParams(this.channelId, this.ts, this.unfurls, this.userAuthRequired, newValue, this.userAuthUrl); } /** * Copy the current immutable object by setting an optional value for the {@link ChatUnfurlParamsIF#getUserAuthMessage() userAuthMessage} 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 userAuthMessage * @return A modified copy of {@code this} object */ public final ChatUnfurlParams withUserAuthMessage(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.userAuthMessage, value)) return this; return new ChatUnfurlParams(this.channelId, this.ts, this.unfurls, this.userAuthRequired, value, this.userAuthUrl); } /** * Copy the current immutable object by setting a present value for the optional {@link ChatUnfurlParamsIF#getUserAuthUrl() userAuthUrl} attribute. * @param value The value for userAuthUrl, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ChatUnfurlParams withUserAuthUrl(@Nullable URI value) { @Nullable URI newValue = value; if (this.userAuthUrl == newValue) return this; return new ChatUnfurlParams(this.channelId, this.ts, this.unfurls, this.userAuthRequired, this.userAuthMessage, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link ChatUnfurlParamsIF#getUserAuthUrl() userAuthUrl} 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 userAuthUrl * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final ChatUnfurlParams withUserAuthUrl(Optional optional) { @Nullable URI value = optional.orElse(null); if (this.userAuthUrl == value) return this; return new ChatUnfurlParams(this.channelId, this.ts, this.unfurls, this.userAuthRequired, this.userAuthMessage, value); } /** * This instance is equal to all instances of {@code ChatUnfurlParams} 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 ChatUnfurlParams && equalTo(0, (ChatUnfurlParams) another); } private boolean equalTo(int synthetic, ChatUnfurlParams another) { return channelId.equals(another.channelId) && ts.equals(another.ts) && unfurls.equals(another.unfurls) && Objects.equals(userAuthRequired, another.userAuthRequired) && Objects.equals(userAuthMessage, another.userAuthMessage) && Objects.equals(userAuthUrl, another.userAuthUrl); } /** * Computes a hash code from attributes: {@code channelId}, {@code ts}, {@code unfurls}, {@code userAuthRequired}, {@code userAuthMessage}, {@code userAuthUrl}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + channelId.hashCode(); h += (h << 5) + ts.hashCode(); h += (h << 5) + unfurls.hashCode(); h += (h << 5) + Objects.hashCode(userAuthRequired); h += (h << 5) + Objects.hashCode(userAuthMessage); h += (h << 5) + Objects.hashCode(userAuthUrl); return h; } /** * Prints the immutable value {@code ChatUnfurlParams} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ChatUnfurlParams{"); builder.append("channelId=").append(channelId); builder.append(", "); builder.append("ts=").append(ts); builder.append(", "); builder.append("unfurls=").append(unfurls); if (userAuthRequired != null) { builder.append(", "); builder.append("userAuthRequired=").append(userAuthRequired); } if (userAuthMessage != null) { builder.append(", "); builder.append("userAuthMessage=").append(userAuthMessage); } if (userAuthUrl != null) { builder.append(", "); builder.append("userAuthUrl=").append(userAuthUrl); } 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 = "ChatUnfurlParamsIF", generator = "Immutables") @Deprecated @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ChatUnfurlParamsIF { @Nullable String channelId; @Nullable String ts; @Nullable Map unfurls = Collections.emptyMap(); @Nullable Optional userAuthRequired = Optional.empty(); @Nullable Optional userAuthMessage = Optional.empty(); @Nullable Optional userAuthUrl = Optional.empty(); @JsonProperty("channel") public void setChannelId(String channelId) { this.channelId = channelId; } @JsonProperty public void setTs(String ts) { this.ts = ts; } @JsonProperty @JsonDeserialize(contentUsing = BlockOrAttachmentDeserializer.class) public void setUnfurls(Map unfurls) { this.unfurls = unfurls; } @JsonProperty public void setUserAuthRequired(Optional userAuthRequired) { this.userAuthRequired = userAuthRequired; } @JsonProperty public void setUserAuthMessage(Optional userAuthMessage) { this.userAuthMessage = userAuthMessage; } @JsonProperty public void setUserAuthUrl(Optional userAuthUrl) { this.userAuthUrl = userAuthUrl; } @Override public String getChannelId() { throw new UnsupportedOperationException(); } @Override public String getTs() { throw new UnsupportedOperationException(); } @Override public Map getUnfurls() { throw new UnsupportedOperationException(); } @Override public Optional isUserAuthRequired() { throw new UnsupportedOperationException(); } @Override public Optional getUserAuthMessage() { throw new UnsupportedOperationException(); } @Override public Optional getUserAuthUrl() { 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 ChatUnfurlParams fromJson(Json json) { ChatUnfurlParams.Builder builder = ChatUnfurlParams.builder(); if (json.channelId != null) { builder.setChannelId(json.channelId); } if (json.ts != null) { builder.setTs(json.ts); } if (json.unfurls != null) { builder.putAllUnfurls(json.unfurls); } if (json.userAuthRequired != null) { builder.setUserAuthRequired(json.userAuthRequired); } if (json.userAuthMessage != null) { builder.setUserAuthMessage(json.userAuthMessage); } if (json.userAuthUrl != null) { builder.setUserAuthUrl(json.userAuthUrl); } return builder.build(); } /** * Creates an immutable copy of a {@link ChatUnfurlParamsIF} 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 ChatUnfurlParams instance */ public static ChatUnfurlParams copyOf(ChatUnfurlParamsIF instance) { if (instance instanceof ChatUnfurlParams) { return (ChatUnfurlParams) instance; } return ChatUnfurlParams.builder() .from(instance) .build(); } /** * Creates a builder for {@link ChatUnfurlParams ChatUnfurlParams}. *

   * ChatUnfurlParams.builder()
   *    .setChannelId(String) // required {@link ChatUnfurlParamsIF#getChannelId() channelId}
   *    .setTs(String) // required {@link ChatUnfurlParamsIF#getTs() ts}
   *    .putUnfurls|putAllUnfurls(String => com.hubspot.slack.client.models.ChatUnfurlBlocksOrAttachment) // {@link ChatUnfurlParamsIF#getUnfurls() unfurls} mappings
   *    .setUserAuthRequired(Boolean) // optional {@link ChatUnfurlParamsIF#isUserAuthRequired() userAuthRequired}
   *    .setUserAuthMessage(String) // optional {@link ChatUnfurlParamsIF#getUserAuthMessage() userAuthMessage}
   *    .setUserAuthUrl(java.net.URI) // optional {@link ChatUnfurlParamsIF#getUserAuthUrl() userAuthUrl}
   *    .build();
   * 
* @return A new ChatUnfurlParams builder */ public static ChatUnfurlParams.Builder builder() { return new ChatUnfurlParams.Builder(); } /** * Builds instances of type {@link ChatUnfurlParams ChatUnfurlParams}. * 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 = "ChatUnfurlParamsIF", 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 long initBits = 0x3L; private @Nullable String channelId; private @Nullable String ts; private Map unfurls = new LinkedHashMap(); private @Nullable Boolean userAuthRequired; private @Nullable String userAuthMessage; private @Nullable URI userAuthUrl; 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.ChatUnfurlParamsIF} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ChatUnfurlParamsIF 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 & 0x1L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x1L; } } if (object instanceof ChatUnfurlParamsIF) { ChatUnfurlParamsIF instance = (ChatUnfurlParamsIF) object; putAllUnfurls(instance.getUnfurls()); Optional userAuthUrlOptional = instance.getUserAuthUrl(); if (userAuthUrlOptional.isPresent()) { setUserAuthUrl(userAuthUrlOptional); } Optional userAuthMessageOptional = instance.getUserAuthMessage(); if (userAuthMessageOptional.isPresent()) { setUserAuthMessage(userAuthMessageOptional); } if ((bits & 0x1L) == 0) { this.setChannelId(instance.getChannelId()); bits |= 0x1L; } Optional userAuthRequiredOptional = instance.isUserAuthRequired(); if (userAuthRequiredOptional.isPresent()) { setUserAuthRequired(userAuthRequiredOptional); } this.setTs(instance.getTs()); } } /** * Initializes the value for the {@link ChatUnfurlParamsIF#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 ChatUnfurlParamsIF#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; } /** * Put one entry to the {@link ChatUnfurlParamsIF#getUnfurls() unfurls} map. * @param key The key in the unfurls map * @param value The associated value in the unfurls map * @return {@code this} builder for use in a chained invocation */ public final Builder putUnfurls(String key, ChatUnfurlBlocksOrAttachment value) { this.unfurls.put( Objects.requireNonNull(key, "unfurls key"), Objects.requireNonNull(value, value == null ? "unfurls value for key: " + key : null)); return this; } /** * Put one entry to the {@link ChatUnfurlParamsIF#getUnfurls() unfurls} map. Nulls are not permitted * @param entry The key and value entry * @return {@code this} builder for use in a chained invocation */ public final Builder putUnfurls(Map.Entry entry) { String k = entry.getKey(); ChatUnfurlBlocksOrAttachment v = entry.getValue(); this.unfurls.put( Objects.requireNonNull(k, "unfurls key"), Objects.requireNonNull(v, v == null ? "unfurls value for key: " + k : null)); return this; } /** * Sets or replaces all mappings from the specified map as entries for the {@link ChatUnfurlParamsIF#getUnfurls() unfurls} map. Nulls are not permitted * @param entries The entries that will be added to the unfurls map * @return {@code this} builder for use in a chained invocation */ public final Builder setUnfurls(Map entries) { this.unfurls.clear(); return putAllUnfurls(entries); } /** * Put all mappings from the specified map as entries to {@link ChatUnfurlParamsIF#getUnfurls() unfurls} map. Nulls are not permitted * @param entries The entries that will be added to the unfurls map * @return {@code this} builder for use in a chained invocation */ public final Builder putAllUnfurls(Map entries) { for (Map.Entry e : entries.entrySet()) { String k = e.getKey(); ChatUnfurlBlocksOrAttachment v = e.getValue(); this.unfurls.put( Objects.requireNonNull(k, "unfurls key"), Objects.requireNonNull(v, v == null ? "unfurls value for key: " + k : null)); } return this; } /** * Initializes the optional value {@link ChatUnfurlParamsIF#isUserAuthRequired() userAuthRequired} to userAuthRequired. * @param userAuthRequired The value for userAuthRequired, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setUserAuthRequired(@Nullable Boolean userAuthRequired) { this.userAuthRequired = userAuthRequired; return this; } /** * Initializes the optional value {@link ChatUnfurlParamsIF#isUserAuthRequired() userAuthRequired} to userAuthRequired. * @param userAuthRequired The value for userAuthRequired * @return {@code this} builder for use in a chained invocation */ public final Builder setUserAuthRequired(Optional userAuthRequired) { this.userAuthRequired = userAuthRequired.orElse(null); return this; } /** * Initializes the optional value {@link ChatUnfurlParamsIF#getUserAuthMessage() userAuthMessage} to userAuthMessage. * @param userAuthMessage The value for userAuthMessage, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setUserAuthMessage(@Nullable String userAuthMessage) { this.userAuthMessage = userAuthMessage; return this; } /** * Initializes the optional value {@link ChatUnfurlParamsIF#getUserAuthMessage() userAuthMessage} to userAuthMessage. * @param userAuthMessage The value for userAuthMessage * @return {@code this} builder for use in a chained invocation */ public final Builder setUserAuthMessage(Optional userAuthMessage) { this.userAuthMessage = userAuthMessage.orElse(null); return this; } /** * Initializes the optional value {@link ChatUnfurlParamsIF#getUserAuthUrl() userAuthUrl} to userAuthUrl. * @param userAuthUrl The value for userAuthUrl, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setUserAuthUrl(@Nullable URI userAuthUrl) { this.userAuthUrl = userAuthUrl; return this; } /** * Initializes the optional value {@link ChatUnfurlParamsIF#getUserAuthUrl() userAuthUrl} to userAuthUrl. * @param userAuthUrl The value for userAuthUrl * @return {@code this} builder for use in a chained invocation */ public final Builder setUserAuthUrl(Optional userAuthUrl) { this.userAuthUrl = userAuthUrl.orElse(null); return this; } /** * Builds a new {@link ChatUnfurlParams ChatUnfurlParams}. * @return An immutable instance of ChatUnfurlParams * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public ChatUnfurlParams build() { checkRequiredAttributes(); return new ChatUnfurlParams( channelId, ts, createUnmodifiableMap(false, false, unfurls), userAuthRequired, userAuthMessage, userAuthUrl); } 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 ChatUnfurlParams, some of required attributes are not set " + attributes; } } private static Map createUnmodifiableMap(boolean checkNulls, boolean skipNulls, Map map) { switch (map.size()) { case 0: return Collections.emptyMap(); case 1: { Map.Entry e = map.entrySet().iterator().next(); K k = e.getKey(); V v = e.getValue(); if (checkNulls) { Objects.requireNonNull(k, "key"); Objects.requireNonNull(v, v == null ? "value for key: " + k : null); } if (skipNulls && (k == null || v == null)) { return Collections.emptyMap(); } return Collections.singletonMap(k, v); } default: { Map linkedMap = new LinkedHashMap<>(map.size() * 4 / 3 + 1); if (skipNulls || checkNulls) { for (Map.Entry e : map.entrySet()) { K k = e.getKey(); V v = e.getValue(); if (skipNulls) { if (k == null || v == null) continue; } else if (checkNulls) { Objects.requireNonNull(k, "key"); Objects.requireNonNull(v, v == null ? "value for key: " + k : null); } linkedMap.put(k, v); } } else { linkedMap.putAll(map); } return Collections.unmodifiableMap(linkedMap); } } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy