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

com.hubspot.slack.client.models.calls.SlackCall Maven / Gradle / Ivy

package com.hubspot.slack.client.models.calls;

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.databind.annotation.JsonDeserialize;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.models.json.SlackOrExternalUserDeserializer;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Instant;
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 SlackCallIF}.
 * 

* Use the builder to create immutable instances: * {@code SlackCall.builder()}. */ @Generated(from = "SlackCallIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class SlackCall implements SlackCallIF { private final String externalUniqueId; private final String id; private final @Nullable Integer startDateEpochSeconds; private transient final Optional startDate; private final @Nullable String desktopAppJoinUrl; private final @Nullable String externalDisplayId; private final @Nullable String title; private final List users; private SlackCall( String externalUniqueId, String id, @Nullable Integer startDateEpochSeconds, @Nullable String desktopAppJoinUrl, @Nullable String externalDisplayId, @Nullable String title, List users) { this.externalUniqueId = externalUniqueId; this.id = id; this.startDateEpochSeconds = startDateEpochSeconds; this.desktopAppJoinUrl = desktopAppJoinUrl; this.externalDisplayId = externalDisplayId; this.title = title; this.users = users; this.startDate = Objects.requireNonNull(SlackCallIF.super.getStartDate(), "startDate"); } /** * @return The value of the {@code externalUniqueId} attribute */ @JsonProperty @Override public String getExternalUniqueId() { return externalUniqueId; } /** * @return The value of the {@code id} attribute */ @JsonProperty @Override public String getId() { return id; } /** * @return The value of the {@code startDateEpochSeconds} attribute */ @JsonProperty("start_date") @Override public Optional getStartDateEpochSeconds() { return Optional.ofNullable(startDateEpochSeconds); } /** * @return The computed-at-construction value of the {@code startDate} attribute */ @JsonProperty @JsonIgnore @Override public Optional getStartDate() { return startDate; } /** * @return The value of the {@code desktopAppJoinUrl} attribute */ @JsonProperty @Override public Optional getDesktopAppJoinUrl() { return Optional.ofNullable(desktopAppJoinUrl); } /** * @return The value of the {@code externalDisplayId} attribute */ @JsonProperty @Override public Optional getExternalDisplayId() { return Optional.ofNullable(externalDisplayId); } /** * @return The value of the {@code title} attribute */ @JsonProperty @Override public Optional getTitle() { return Optional.ofNullable(title); } /** * @return The value of the {@code users} attribute */ @JsonProperty @JsonDeserialize(contentUsing = SlackOrExternalUserDeserializer.class) @Override public List getUsers() { return users; } /** * Copy the current immutable object by setting a value for the {@link SlackCallIF#getExternalUniqueId() externalUniqueId} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for externalUniqueId * @return A modified copy of the {@code this} object */ public final SlackCall withExternalUniqueId(String value) { String newValue = Objects.requireNonNull(value, "externalUniqueId"); if (this.externalUniqueId.equals(newValue)) return this; return new SlackCall( newValue, this.id, this.startDateEpochSeconds, this.desktopAppJoinUrl, this.externalDisplayId, this.title, this.users); } /** * Copy the current immutable object by setting a value for the {@link SlackCallIF#getId() id} attribute. * An equals check used to prevent copying of the same value by returning {@code this}. * @param value A new value for id * @return A modified copy of the {@code this} object */ public final SlackCall withId(String value) { String newValue = Objects.requireNonNull(value, "id"); if (this.id.equals(newValue)) return this; return new SlackCall( this.externalUniqueId, newValue, this.startDateEpochSeconds, this.desktopAppJoinUrl, this.externalDisplayId, this.title, this.users); } /** * Copy the current immutable object by setting a present value for the optional {@link SlackCallIF#getStartDateEpochSeconds() startDateEpochSeconds} attribute. * @param value The value for startDateEpochSeconds, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final SlackCall withStartDateEpochSeconds(@Nullable Integer value) { @Nullable Integer newValue = value; if (Objects.equals(this.startDateEpochSeconds, newValue)) return this; return new SlackCall( this.externalUniqueId, this.id, newValue, this.desktopAppJoinUrl, this.externalDisplayId, this.title, this.users); } /** * Copy the current immutable object by setting an optional value for the {@link SlackCallIF#getStartDateEpochSeconds() startDateEpochSeconds} 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 startDateEpochSeconds * @return A modified copy of {@code this} object */ public final SlackCall withStartDateEpochSeconds(Optional optional) { @Nullable Integer value = optional.orElse(null); if (Objects.equals(this.startDateEpochSeconds, value)) return this; return new SlackCall( this.externalUniqueId, this.id, value, this.desktopAppJoinUrl, this.externalDisplayId, this.title, this.users); } /** * Copy the current immutable object by setting a present value for the optional {@link SlackCallIF#getDesktopAppJoinUrl() desktopAppJoinUrl} attribute. * @param value The value for desktopAppJoinUrl, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final SlackCall withDesktopAppJoinUrl(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.desktopAppJoinUrl, newValue)) return this; return new SlackCall( this.externalUniqueId, this.id, this.startDateEpochSeconds, newValue, this.externalDisplayId, this.title, this.users); } /** * Copy the current immutable object by setting an optional value for the {@link SlackCallIF#getDesktopAppJoinUrl() desktopAppJoinUrl} 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 desktopAppJoinUrl * @return A modified copy of {@code this} object */ public final SlackCall withDesktopAppJoinUrl(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.desktopAppJoinUrl, value)) return this; return new SlackCall( this.externalUniqueId, this.id, this.startDateEpochSeconds, value, this.externalDisplayId, this.title, this.users); } /** * Copy the current immutable object by setting a present value for the optional {@link SlackCallIF#getExternalDisplayId() externalDisplayId} attribute. * @param value The value for externalDisplayId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final SlackCall withExternalDisplayId(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.externalDisplayId, newValue)) return this; return new SlackCall( this.externalUniqueId, this.id, this.startDateEpochSeconds, this.desktopAppJoinUrl, newValue, this.title, this.users); } /** * Copy the current immutable object by setting an optional value for the {@link SlackCallIF#getExternalDisplayId() externalDisplayId} 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 externalDisplayId * @return A modified copy of {@code this} object */ public final SlackCall withExternalDisplayId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.externalDisplayId, value)) return this; return new SlackCall( this.externalUniqueId, this.id, this.startDateEpochSeconds, this.desktopAppJoinUrl, value, this.title, this.users); } /** * Copy the current immutable object by setting a present value for the optional {@link SlackCallIF#getTitle() title} attribute. * @param value The value for title, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final SlackCall withTitle(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.title, newValue)) return this; return new SlackCall( this.externalUniqueId, this.id, this.startDateEpochSeconds, this.desktopAppJoinUrl, this.externalDisplayId, newValue, this.users); } /** * Copy the current immutable object by setting an optional value for the {@link SlackCallIF#getTitle() title} 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 title * @return A modified copy of {@code this} object */ public final SlackCall withTitle(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.title, value)) return this; return new SlackCall( this.externalUniqueId, this.id, this.startDateEpochSeconds, this.desktopAppJoinUrl, this.externalDisplayId, value, this.users); } /** * Copy the current immutable object with elements that replace the content of {@link SlackCallIF#getUsers() users}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final SlackCall withUsers(SlackInternalOrExternalUser... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new SlackCall( this.externalUniqueId, this.id, this.startDateEpochSeconds, this.desktopAppJoinUrl, this.externalDisplayId, this.title, newValue); } /** * Copy the current immutable object with elements that replace the content of {@link SlackCallIF#getUsers() users}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of users elements to set * @return A modified copy of {@code this} object */ public final SlackCall withUsers(Iterable elements) { if (this.users == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new SlackCall( this.externalUniqueId, this.id, this.startDateEpochSeconds, this.desktopAppJoinUrl, this.externalDisplayId, this.title, newValue); } /** * This instance is equal to all instances of {@code SlackCall} 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 SlackCall && equalTo(0, (SlackCall) another); } private boolean equalTo(int synthetic, SlackCall another) { return externalUniqueId.equals(another.externalUniqueId) && id.equals(another.id) && Objects.equals(startDateEpochSeconds, another.startDateEpochSeconds) && startDate.equals(another.startDate) && Objects.equals(desktopAppJoinUrl, another.desktopAppJoinUrl) && Objects.equals(externalDisplayId, another.externalDisplayId) && Objects.equals(title, another.title) && users.equals(another.users); } /** * Computes a hash code from attributes: {@code externalUniqueId}, {@code id}, {@code startDateEpochSeconds}, {@code startDate}, {@code desktopAppJoinUrl}, {@code externalDisplayId}, {@code title}, {@code users}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + externalUniqueId.hashCode(); h += (h << 5) + id.hashCode(); h += (h << 5) + Objects.hashCode(startDateEpochSeconds); h += (h << 5) + startDate.hashCode(); h += (h << 5) + Objects.hashCode(desktopAppJoinUrl); h += (h << 5) + Objects.hashCode(externalDisplayId); h += (h << 5) + Objects.hashCode(title); h += (h << 5) + users.hashCode(); return h; } /** * Prints the immutable value {@code SlackCall} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("SlackCall{"); builder.append("externalUniqueId=").append(externalUniqueId); builder.append(", "); builder.append("id=").append(id); if (startDateEpochSeconds != null) { builder.append(", "); builder.append("startDateEpochSeconds=").append(startDateEpochSeconds); } builder.append(", "); builder.append("startDate=").append(startDate); if (desktopAppJoinUrl != null) { builder.append(", "); builder.append("desktopAppJoinUrl=").append(desktopAppJoinUrl); } if (externalDisplayId != null) { builder.append(", "); builder.append("externalDisplayId=").append(externalDisplayId); } if (title != null) { builder.append(", "); builder.append("title=").append(title); } builder.append(", "); builder.append("users=").append(users); 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 = "SlackCallIF", generator = "Immutables") @Deprecated @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements SlackCallIF { @Nullable String externalUniqueId; @Nullable String id; @Nullable Optional startDateEpochSeconds = Optional.empty(); @Nullable Optional desktopAppJoinUrl = Optional.empty(); @Nullable Optional externalDisplayId = Optional.empty(); @Nullable Optional title = Optional.empty(); @Nullable List users = Collections.emptyList(); @JsonProperty public void setExternalUniqueId(String externalUniqueId) { this.externalUniqueId = externalUniqueId; } @JsonProperty public void setId(String id) { this.id = id; } @JsonProperty("start_date") public void setStartDateEpochSeconds(Optional startDateEpochSeconds) { this.startDateEpochSeconds = startDateEpochSeconds; } @JsonProperty public void setDesktopAppJoinUrl(Optional desktopAppJoinUrl) { this.desktopAppJoinUrl = desktopAppJoinUrl; } @JsonProperty public void setExternalDisplayId(Optional externalDisplayId) { this.externalDisplayId = externalDisplayId; } @JsonProperty public void setTitle(Optional title) { this.title = title; } @JsonProperty @JsonDeserialize(contentUsing = SlackOrExternalUserDeserializer.class) public void setUsers(List users) { this.users = users; } @Override public String getExternalUniqueId() { throw new UnsupportedOperationException(); } @Override public String getId() { throw new UnsupportedOperationException(); } @Override public Optional getStartDateEpochSeconds() { throw new UnsupportedOperationException(); } @JsonIgnore @Override public Optional getStartDate() { throw new UnsupportedOperationException(); } @Override public Optional getDesktopAppJoinUrl() { throw new UnsupportedOperationException(); } @Override public Optional getExternalDisplayId() { throw new UnsupportedOperationException(); } @Override public Optional getTitle() { throw new UnsupportedOperationException(); } @Override public List getUsers() { 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 SlackCall fromJson(Json json) { SlackCall.Builder builder = SlackCall.builder(); if (json.externalUniqueId != null) { builder.setExternalUniqueId(json.externalUniqueId); } if (json.id != null) { builder.setId(json.id); } if (json.startDateEpochSeconds != null) { builder.setStartDateEpochSeconds(json.startDateEpochSeconds); } if (json.desktopAppJoinUrl != null) { builder.setDesktopAppJoinUrl(json.desktopAppJoinUrl); } if (json.externalDisplayId != null) { builder.setExternalDisplayId(json.externalDisplayId); } if (json.title != null) { builder.setTitle(json.title); } if (json.users != null) { builder.addAllUsers(json.users); } return builder.build(); } /** * Creates an immutable copy of a {@link SlackCallIF} 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 SlackCall instance */ public static SlackCall copyOf(SlackCallIF instance) { if (instance instanceof SlackCall) { return (SlackCall) instance; } return SlackCall.builder() .from(instance) .build(); } /** * Creates a builder for {@link SlackCall SlackCall}. *

   * SlackCall.builder()
   *    .setExternalUniqueId(String) // required {@link SlackCallIF#getExternalUniqueId() externalUniqueId}
   *    .setId(String) // required {@link SlackCallIF#getId() id}
   *    .setStartDateEpochSeconds(Integer) // optional {@link SlackCallIF#getStartDateEpochSeconds() startDateEpochSeconds}
   *    .setDesktopAppJoinUrl(String) // optional {@link SlackCallIF#getDesktopAppJoinUrl() desktopAppJoinUrl}
   *    .setExternalDisplayId(String) // optional {@link SlackCallIF#getExternalDisplayId() externalDisplayId}
   *    .setTitle(String) // optional {@link SlackCallIF#getTitle() title}
   *    .addUsers|addAllUsers(com.hubspot.slack.client.models.calls.SlackInternalOrExternalUser) // {@link SlackCallIF#getUsers() users} elements
   *    .build();
   * 
* @return A new SlackCall builder */ public static SlackCall.Builder builder() { return new SlackCall.Builder(); } /** * Builds instances of type {@link SlackCall SlackCall}. * 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 = "SlackCallIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private static final long INIT_BIT_EXTERNAL_UNIQUE_ID = 0x1L; private static final long INIT_BIT_ID = 0x2L; private long initBits = 0x3L; private @Nullable String externalUniqueId; private @Nullable String id; private @Nullable Integer startDateEpochSeconds; private @Nullable String desktopAppJoinUrl; private @Nullable String externalDisplayId; private @Nullable String title; private List users = new ArrayList(); private Builder() { } /** * Fill a builder with attribute values from the provided {@code SlackCallIF} instance. * Regular attribute values will be replaced with those from the given instance. * Absent optional values will not replace present values. * Collection elements and entries will be added, not replaced. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(SlackCallIF instance) { Objects.requireNonNull(instance, "instance"); this.setExternalUniqueId(instance.getExternalUniqueId()); this.setId(instance.getId()); Optional startDateEpochSecondsOptional = instance.getStartDateEpochSeconds(); if (startDateEpochSecondsOptional.isPresent()) { setStartDateEpochSeconds(startDateEpochSecondsOptional); } Optional desktopAppJoinUrlOptional = instance.getDesktopAppJoinUrl(); if (desktopAppJoinUrlOptional.isPresent()) { setDesktopAppJoinUrl(desktopAppJoinUrlOptional); } Optional externalDisplayIdOptional = instance.getExternalDisplayId(); if (externalDisplayIdOptional.isPresent()) { setExternalDisplayId(externalDisplayIdOptional); } Optional titleOptional = instance.getTitle(); if (titleOptional.isPresent()) { setTitle(titleOptional); } addAllUsers(instance.getUsers()); return this; } /** * Initializes the value for the {@link SlackCallIF#getExternalUniqueId() externalUniqueId} attribute. * @param externalUniqueId The value for externalUniqueId * @return {@code this} builder for use in a chained invocation */ public final Builder setExternalUniqueId(String externalUniqueId) { this.externalUniqueId = Objects.requireNonNull(externalUniqueId, "externalUniqueId"); initBits &= ~INIT_BIT_EXTERNAL_UNIQUE_ID; return this; } /** * Initializes the value for the {@link SlackCallIF#getId() id} attribute. * @param id The value for id * @return {@code this} builder for use in a chained invocation */ public final Builder setId(String id) { this.id = Objects.requireNonNull(id, "id"); initBits &= ~INIT_BIT_ID; return this; } /** * Initializes the optional value {@link SlackCallIF#getStartDateEpochSeconds() startDateEpochSeconds} to startDateEpochSeconds. * @param startDateEpochSeconds The value for startDateEpochSeconds, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setStartDateEpochSeconds(@Nullable Integer startDateEpochSeconds) { this.startDateEpochSeconds = startDateEpochSeconds; return this; } /** * Initializes the optional value {@link SlackCallIF#getStartDateEpochSeconds() startDateEpochSeconds} to startDateEpochSeconds. * @param startDateEpochSeconds The value for startDateEpochSeconds * @return {@code this} builder for use in a chained invocation */ public final Builder setStartDateEpochSeconds(Optional startDateEpochSeconds) { this.startDateEpochSeconds = startDateEpochSeconds.orElse(null); return this; } /** * Initializes the optional value {@link SlackCallIF#getDesktopAppJoinUrl() desktopAppJoinUrl} to desktopAppJoinUrl. * @param desktopAppJoinUrl The value for desktopAppJoinUrl, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setDesktopAppJoinUrl(@Nullable String desktopAppJoinUrl) { this.desktopAppJoinUrl = desktopAppJoinUrl; return this; } /** * Initializes the optional value {@link SlackCallIF#getDesktopAppJoinUrl() desktopAppJoinUrl} to desktopAppJoinUrl. * @param desktopAppJoinUrl The value for desktopAppJoinUrl * @return {@code this} builder for use in a chained invocation */ public final Builder setDesktopAppJoinUrl(Optional desktopAppJoinUrl) { this.desktopAppJoinUrl = desktopAppJoinUrl.orElse(null); return this; } /** * Initializes the optional value {@link SlackCallIF#getExternalDisplayId() externalDisplayId} to externalDisplayId. * @param externalDisplayId The value for externalDisplayId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setExternalDisplayId(@Nullable String externalDisplayId) { this.externalDisplayId = externalDisplayId; return this; } /** * Initializes the optional value {@link SlackCallIF#getExternalDisplayId() externalDisplayId} to externalDisplayId. * @param externalDisplayId The value for externalDisplayId * @return {@code this} builder for use in a chained invocation */ public final Builder setExternalDisplayId(Optional externalDisplayId) { this.externalDisplayId = externalDisplayId.orElse(null); return this; } /** * Initializes the optional value {@link SlackCallIF#getTitle() title} to title. * @param title The value for title, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setTitle(@Nullable String title) { this.title = title; return this; } /** * Initializes the optional value {@link SlackCallIF#getTitle() title} to title. * @param title The value for title * @return {@code this} builder for use in a chained invocation */ public final Builder setTitle(Optional title) { this.title = title.orElse(null); return this; } /** * Adds one element to {@link SlackCallIF#getUsers() users} list. * @param element A users element * @return {@code this} builder for use in a chained invocation */ public final Builder addUsers(SlackInternalOrExternalUser element) { this.users.add(Objects.requireNonNull(element, "users element")); return this; } /** * Adds elements to {@link SlackCallIF#getUsers() users} list. * @param elements An array of users elements * @return {@code this} builder for use in a chained invocation */ public final Builder addUsers(SlackInternalOrExternalUser... elements) { for (SlackInternalOrExternalUser element : elements) { this.users.add(Objects.requireNonNull(element, "users element")); } return this; } /** * Sets or replaces all elements for {@link SlackCallIF#getUsers() users} list. * @param elements An iterable of users elements * @return {@code this} builder for use in a chained invocation */ public final Builder setUsers(Iterable elements) { this.users.clear(); return addAllUsers(elements); } /** * Adds elements to {@link SlackCallIF#getUsers() users} list. * @param elements An iterable of users elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllUsers(Iterable elements) { for (SlackInternalOrExternalUser element : elements) { this.users.add(Objects.requireNonNull(element, "users element")); } return this; } /** * Builds a new {@link SlackCall SlackCall}. * @return An immutable instance of SlackCall * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public SlackCall build() { checkRequiredAttributes(); return new SlackCall( externalUniqueId, id, startDateEpochSeconds, desktopAppJoinUrl, externalDisplayId, title, createUnmodifiableList(true, users)); } private boolean externalUniqueIdIsSet() { return (initBits & INIT_BIT_EXTERNAL_UNIQUE_ID) == 0; } private boolean idIsSet() { return (initBits & INIT_BIT_ID) == 0; } private void checkRequiredAttributes() { if (initBits != 0) { throw new InvalidImmutableStateException(formatRequiredAttributesMessage()); } } private String formatRequiredAttributesMessage() { List attributes = new ArrayList<>(); if (!externalUniqueIdIsSet()) attributes.add("externalUniqueId"); if (!idIsSet()) attributes.add("id"); return "Cannot build SlackCall, 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