
com.hubspot.slack.client.methods.params.calls.CallsAddParams Maven / Gradle / Ivy
package com.hubspot.slack.client.methods.params.calls;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.models.calls.SlackInternalOrExternalUser;
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 CallsAddParamsIF}.
*
* Use the builder to create immutable instances:
* {@code CallsAddParams.builder()}.
*/
@Generated(from = "CallsAddParamsIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class CallsAddParams implements CallsAddParamsIF {
private final String externalUniqueId;
private final String joinUrl;
private final @Nullable String createdBy;
private final @Nullable Integer dateStart;
private final @Nullable String desktopAppJoinUrl;
private final @Nullable String externalDisplayId;
private final @Nullable String title;
private final List users;
private CallsAddParams(
String externalUniqueId,
String joinUrl,
@Nullable String createdBy,
@Nullable Integer dateStart,
@Nullable String desktopAppJoinUrl,
@Nullable String externalDisplayId,
@Nullable String title,
List users) {
this.externalUniqueId = externalUniqueId;
this.joinUrl = joinUrl;
this.createdBy = createdBy;
this.dateStart = dateStart;
this.desktopAppJoinUrl = desktopAppJoinUrl;
this.externalDisplayId = externalDisplayId;
this.title = title;
this.users = users;
}
/**
* @return The value of the {@code externalUniqueId} attribute
*/
@JsonProperty
@Override
public String getExternalUniqueId() {
return externalUniqueId;
}
/**
* @return The value of the {@code joinUrl} attribute
*/
@JsonProperty
@Override
public String getJoinUrl() {
return joinUrl;
}
/**
* @return The value of the {@code createdBy} attribute
*/
@JsonProperty
@Override
public Optional getCreatedBy() {
return Optional.ofNullable(createdBy);
}
/**
* @return The value of the {@code dateStart} attribute
*/
@JsonProperty
@Override
public Optional getDateStart() {
return Optional.ofNullable(dateStart);
}
/**
* @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
@Override
public List getUsers() {
return users;
}
/**
* Copy the current immutable object by setting a value for the {@link CallsAddParamsIF#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 CallsAddParams withExternalUniqueId(String value) {
String newValue = Objects.requireNonNull(value, "externalUniqueId");
if (this.externalUniqueId.equals(newValue)) return this;
return new CallsAddParams(
newValue,
this.joinUrl,
this.createdBy,
this.dateStart,
this.desktopAppJoinUrl,
this.externalDisplayId,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting a value for the {@link CallsAddParamsIF#getJoinUrl() joinUrl} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for joinUrl
* @return A modified copy of the {@code this} object
*/
public final CallsAddParams withJoinUrl(String value) {
String newValue = Objects.requireNonNull(value, "joinUrl");
if (this.joinUrl.equals(newValue)) return this;
return new CallsAddParams(
this.externalUniqueId,
newValue,
this.createdBy,
this.dateStart,
this.desktopAppJoinUrl,
this.externalDisplayId,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link CallsAddParamsIF#getCreatedBy() createdBy} attribute.
* @param value The value for createdBy, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final CallsAddParams withCreatedBy(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.createdBy, newValue)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
newValue,
this.dateStart,
this.desktopAppJoinUrl,
this.externalDisplayId,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting an optional value for the {@link CallsAddParamsIF#getCreatedBy() createdBy} 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 createdBy
* @return A modified copy of {@code this} object
*/
public final CallsAddParams withCreatedBy(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.createdBy, value)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
value,
this.dateStart,
this.desktopAppJoinUrl,
this.externalDisplayId,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link CallsAddParamsIF#getDateStart() dateStart} attribute.
* @param value The value for dateStart, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final CallsAddParams withDateStart(@Nullable Integer value) {
@Nullable Integer newValue = value;
if (Objects.equals(this.dateStart, newValue)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
newValue,
this.desktopAppJoinUrl,
this.externalDisplayId,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting an optional value for the {@link CallsAddParamsIF#getDateStart() dateStart} 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 dateStart
* @return A modified copy of {@code this} object
*/
public final CallsAddParams withDateStart(Optional optional) {
@Nullable Integer value = optional.orElse(null);
if (Objects.equals(this.dateStart, value)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
value,
this.desktopAppJoinUrl,
this.externalDisplayId,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link CallsAddParamsIF#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 CallsAddParams withDesktopAppJoinUrl(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.desktopAppJoinUrl, newValue)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
this.dateStart,
newValue,
this.externalDisplayId,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting an optional value for the {@link CallsAddParamsIF#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 CallsAddParams withDesktopAppJoinUrl(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.desktopAppJoinUrl, value)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
this.dateStart,
value,
this.externalDisplayId,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link CallsAddParamsIF#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 CallsAddParams withExternalDisplayId(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.externalDisplayId, newValue)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
this.dateStart,
this.desktopAppJoinUrl,
newValue,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting an optional value for the {@link CallsAddParamsIF#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 CallsAddParams withExternalDisplayId(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.externalDisplayId, value)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
this.dateStart,
this.desktopAppJoinUrl,
value,
this.title,
this.users);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link CallsAddParamsIF#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 CallsAddParams withTitle(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.title, newValue)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
this.dateStart,
this.desktopAppJoinUrl,
this.externalDisplayId,
newValue,
this.users);
}
/**
* Copy the current immutable object by setting an optional value for the {@link CallsAddParamsIF#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 CallsAddParams withTitle(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.title, value)) return this;
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
this.dateStart,
this.desktopAppJoinUrl,
this.externalDisplayId,
value,
this.users);
}
/**
* Copy the current immutable object with elements that replace the content of {@link CallsAddParamsIF#getUsers() users}.
* @param elements The elements to set
* @return A modified copy of {@code this} object
*/
public final CallsAddParams withUsers(SlackInternalOrExternalUser... elements) {
List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false));
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
this.dateStart,
this.desktopAppJoinUrl,
this.externalDisplayId,
this.title,
newValue);
}
/**
* Copy the current immutable object with elements that replace the content of {@link CallsAddParamsIF#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 CallsAddParams withUsers(Iterable extends SlackInternalOrExternalUser> elements) {
if (this.users == elements) return this;
List newValue = createUnmodifiableList(false, createSafeList(elements, true, false));
return new CallsAddParams(
this.externalUniqueId,
this.joinUrl,
this.createdBy,
this.dateStart,
this.desktopAppJoinUrl,
this.externalDisplayId,
this.title,
newValue);
}
/**
* This instance is equal to all instances of {@code CallsAddParams} 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 CallsAddParams
&& equalTo(0, (CallsAddParams) another);
}
private boolean equalTo(int synthetic, CallsAddParams another) {
return externalUniqueId.equals(another.externalUniqueId)
&& joinUrl.equals(another.joinUrl)
&& Objects.equals(createdBy, another.createdBy)
&& Objects.equals(dateStart, another.dateStart)
&& 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 joinUrl}, {@code createdBy}, {@code dateStart}, {@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) + joinUrl.hashCode();
h += (h << 5) + Objects.hashCode(createdBy);
h += (h << 5) + Objects.hashCode(dateStart);
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 CallsAddParams} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("CallsAddParams{");
builder.append("externalUniqueId=").append(externalUniqueId);
builder.append(", ");
builder.append("joinUrl=").append(joinUrl);
if (createdBy != null) {
builder.append(", ");
builder.append("createdBy=").append(createdBy);
}
if (dateStart != null) {
builder.append(", ");
builder.append("dateStart=").append(dateStart);
}
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 = "CallsAddParamsIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements CallsAddParamsIF {
@Nullable String externalUniqueId;
@Nullable String joinUrl;
@Nullable Optional createdBy = Optional.empty();
@Nullable Optional dateStart = 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 setJoinUrl(String joinUrl) {
this.joinUrl = joinUrl;
}
@JsonProperty
public void setCreatedBy(Optional createdBy) {
this.createdBy = createdBy;
}
@JsonProperty
public void setDateStart(Optional dateStart) {
this.dateStart = dateStart;
}
@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
public void setUsers(List users) {
this.users = users;
}
@Override
public String getExternalUniqueId() { throw new UnsupportedOperationException(); }
@Override
public String getJoinUrl() { throw new UnsupportedOperationException(); }
@Override
public Optional getCreatedBy() { throw new UnsupportedOperationException(); }
@Override
public Optional getDateStart() { 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 CallsAddParams fromJson(Json json) {
CallsAddParams.Builder builder = CallsAddParams.builder();
if (json.externalUniqueId != null) {
builder.setExternalUniqueId(json.externalUniqueId);
}
if (json.joinUrl != null) {
builder.setJoinUrl(json.joinUrl);
}
if (json.createdBy != null) {
builder.setCreatedBy(json.createdBy);
}
if (json.dateStart != null) {
builder.setDateStart(json.dateStart);
}
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 CallsAddParamsIF} 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 CallsAddParams instance
*/
public static CallsAddParams copyOf(CallsAddParamsIF instance) {
if (instance instanceof CallsAddParams) {
return (CallsAddParams) instance;
}
return CallsAddParams.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link CallsAddParams CallsAddParams}.
*
* CallsAddParams.builder()
* .setExternalUniqueId(String) // required {@link CallsAddParamsIF#getExternalUniqueId() externalUniqueId}
* .setJoinUrl(String) // required {@link CallsAddParamsIF#getJoinUrl() joinUrl}
* .setCreatedBy(String) // optional {@link CallsAddParamsIF#getCreatedBy() createdBy}
* .setDateStart(Integer) // optional {@link CallsAddParamsIF#getDateStart() dateStart}
* .setDesktopAppJoinUrl(String) // optional {@link CallsAddParamsIF#getDesktopAppJoinUrl() desktopAppJoinUrl}
* .setExternalDisplayId(String) // optional {@link CallsAddParamsIF#getExternalDisplayId() externalDisplayId}
* .setTitle(String) // optional {@link CallsAddParamsIF#getTitle() title}
* .addUsers|addAllUsers(com.hubspot.slack.client.models.calls.SlackInternalOrExternalUser) // {@link CallsAddParamsIF#getUsers() users} elements
* .build();
*
* @return A new CallsAddParams builder
*/
public static CallsAddParams.Builder builder() {
return new CallsAddParams.Builder();
}
/**
* Builds instances of type {@link CallsAddParams CallsAddParams}.
* 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 = "CallsAddParamsIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_EXTERNAL_UNIQUE_ID = 0x1L;
private static final long INIT_BIT_JOIN_URL = 0x2L;
private long initBits = 0x3L;
private @Nullable String externalUniqueId;
private @Nullable String joinUrl;
private @Nullable String createdBy;
private @Nullable Integer dateStart;
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 CallsAddParamsIF} 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(CallsAddParamsIF instance) {
Objects.requireNonNull(instance, "instance");
this.setExternalUniqueId(instance.getExternalUniqueId());
this.setJoinUrl(instance.getJoinUrl());
Optional createdByOptional = instance.getCreatedBy();
if (createdByOptional.isPresent()) {
setCreatedBy(createdByOptional);
}
Optional dateStartOptional = instance.getDateStart();
if (dateStartOptional.isPresent()) {
setDateStart(dateStartOptional);
}
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 CallsAddParamsIF#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 CallsAddParamsIF#getJoinUrl() joinUrl} attribute.
* @param joinUrl The value for joinUrl
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setJoinUrl(String joinUrl) {
this.joinUrl = Objects.requireNonNull(joinUrl, "joinUrl");
initBits &= ~INIT_BIT_JOIN_URL;
return this;
}
/**
* Initializes the optional value {@link CallsAddParamsIF#getCreatedBy() createdBy} to createdBy.
* @param createdBy The value for createdBy, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setCreatedBy(@Nullable String createdBy) {
this.createdBy = createdBy;
return this;
}
/**
* Initializes the optional value {@link CallsAddParamsIF#getCreatedBy() createdBy} to createdBy.
* @param createdBy The value for createdBy
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setCreatedBy(Optional createdBy) {
this.createdBy = createdBy.orElse(null);
return this;
}
/**
* Initializes the optional value {@link CallsAddParamsIF#getDateStart() dateStart} to dateStart.
* @param dateStart The value for dateStart, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setDateStart(@Nullable Integer dateStart) {
this.dateStart = dateStart;
return this;
}
/**
* Initializes the optional value {@link CallsAddParamsIF#getDateStart() dateStart} to dateStart.
* @param dateStart The value for dateStart
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setDateStart(Optional dateStart) {
this.dateStart = dateStart.orElse(null);
return this;
}
/**
* Initializes the optional value {@link CallsAddParamsIF#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 CallsAddParamsIF#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 CallsAddParamsIF#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 CallsAddParamsIF#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 CallsAddParamsIF#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 CallsAddParamsIF#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 CallsAddParamsIF#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 CallsAddParamsIF#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 CallsAddParamsIF#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 extends SlackInternalOrExternalUser> elements) {
this.users.clear();
return addAllUsers(elements);
}
/**
* Adds elements to {@link CallsAddParamsIF#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 extends SlackInternalOrExternalUser> elements) {
for (SlackInternalOrExternalUser element : elements) {
this.users.add(Objects.requireNonNull(element, "users element"));
}
return this;
}
/**
* Builds a new {@link CallsAddParams CallsAddParams}.
* @return An immutable instance of CallsAddParams
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public CallsAddParams build() {
checkRequiredAttributes();
return new CallsAddParams(
externalUniqueId,
joinUrl,
createdBy,
dateStart,
desktopAppJoinUrl,
externalDisplayId,
title,
createUnmodifiableList(true, users));
}
private boolean externalUniqueIdIsSet() {
return (initBits & INIT_BIT_EXTERNAL_UNIQUE_ID) == 0;
}
private boolean joinUrlIsSet() {
return (initBits & INIT_BIT_JOIN_URL) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!externalUniqueIdIsSet()) attributes.add("externalUniqueId");
if (!joinUrlIsSet()) attributes.add("joinUrl");
return "Cannot build CallsAddParams, some of required attributes are not set " + attributes;
}
}
private static List createSafeList(Iterable extends T> 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);
}
}
}
}