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

com.hubspot.slack.client.methods.params.conversations.ConversationsUserParams Maven / Gradle / Ivy

package com.hubspot.slack.client.methods.params.conversations;

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.hubspot.slack.client.models.conversations.ConversationType;
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.EnumSet;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
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 ConversationsUserParamsIF}.
 * 

* Use the builder to create immutable instances: * {@code ConversationsUserParams.builder()}. */ @Generated(from = "ConversationsUserParamsIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class ConversationsUserParams implements ConversationsUserParamsIF { private final @Nullable Boolean shouldExcludeArchived; private transient final String types; private final Set conversationTypes; private final @Nullable String userId; private final @Nullable String cursor; private final @Nullable Integer limit; private ConversationsUserParams( @Nullable Boolean shouldExcludeArchived, Set conversationTypes, @Nullable String userId, @Nullable String cursor, @Nullable Integer limit) { this.shouldExcludeArchived = shouldExcludeArchived; this.conversationTypes = conversationTypes; this.userId = userId; this.cursor = cursor; this.limit = limit; this.types = Objects.requireNonNull(ConversationsUserParamsIF.super.getTypes(), "types"); } /** * @return The value of the {@code shouldExcludeArchived} attribute */ @JsonProperty("exclude_archived") @Override public Optional shouldExcludeArchived() { return Optional.ofNullable(shouldExcludeArchived); } /** * @return The computed-at-construction value of the {@code types} attribute */ @JsonProperty @Override public String getTypes() { return types; } /** * @return The value of the {@code conversationTypes} attribute */ @JsonProperty @JsonIgnore @Override public Set getConversationTypes() { return conversationTypes; } /** * @return The value of the {@code userId} attribute */ @JsonProperty("user") @Override public Optional getUserId() { return Optional.ofNullable(userId); } /** * @return The value of the {@code cursor} attribute */ @JsonProperty @Override public Optional getCursor() { return Optional.ofNullable(cursor); } /** * @return The value of the {@code limit} attribute */ @JsonProperty @Override public Optional getLimit() { return Optional.ofNullable(limit); } /** * Copy the current immutable object by setting a present value for the optional {@link ConversationsUserParamsIF#shouldExcludeArchived() shouldExcludeArchived} attribute. * @param value The value for shouldExcludeArchived, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ConversationsUserParams withShouldExcludeArchived(@Nullable Boolean value) { @Nullable Boolean newValue = value; if (Objects.equals(this.shouldExcludeArchived, newValue)) return this; return new ConversationsUserParams(newValue, this.conversationTypes, this.userId, this.cursor, this.limit); } /** * Copy the current immutable object by setting an optional value for the {@link ConversationsUserParamsIF#shouldExcludeArchived() shouldExcludeArchived} 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 shouldExcludeArchived * @return A modified copy of {@code this} object */ public final ConversationsUserParams withShouldExcludeArchived(Optional optional) { @Nullable Boolean value = optional.orElse(null); if (Objects.equals(this.shouldExcludeArchived, value)) return this; return new ConversationsUserParams(value, this.conversationTypes, this.userId, this.cursor, this.limit); } /** * Copy the current immutable object with elements that replace the content of {@link ConversationsUserParamsIF#getConversationTypes() conversationTypes}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final ConversationsUserParams withConversationTypes(ConversationType... elements) { Set newValue = createUnmodifiableEnumSet(Arrays.asList(elements)); return new ConversationsUserParams(this.shouldExcludeArchived, newValue, this.userId, this.cursor, this.limit); } /** * Copy the current immutable object with elements that replace the content of {@link ConversationsUserParamsIF#getConversationTypes() conversationTypes}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of conversationTypes elements to set * @return A modified copy of {@code this} object */ public final ConversationsUserParams withConversationTypes(Iterable elements) { if (this.conversationTypes == elements) return this; Set newValue = createUnmodifiableEnumSet(elements); return new ConversationsUserParams(this.shouldExcludeArchived, newValue, this.userId, this.cursor, this.limit); } /** * Copy the current immutable object by setting a present value for the optional {@link ConversationsUserParamsIF#getUserId() userId} attribute. * @param value The value for userId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ConversationsUserParams withUserId(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.userId, newValue)) return this; return new ConversationsUserParams(this.shouldExcludeArchived, this.conversationTypes, newValue, this.cursor, this.limit); } /** * Copy the current immutable object by setting an optional value for the {@link ConversationsUserParamsIF#getUserId() userId} 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 userId * @return A modified copy of {@code this} object */ public final ConversationsUserParams withUserId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.userId, value)) return this; return new ConversationsUserParams(this.shouldExcludeArchived, this.conversationTypes, value, this.cursor, this.limit); } /** * Copy the current immutable object by setting a present value for the optional {@link ConversationsUserParamsIF#getCursor() cursor} attribute. * @param value The value for cursor, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ConversationsUserParams withCursor(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.cursor, newValue)) return this; return new ConversationsUserParams(this.shouldExcludeArchived, this.conversationTypes, this.userId, newValue, this.limit); } /** * Copy the current immutable object by setting an optional value for the {@link ConversationsUserParamsIF#getCursor() cursor} 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 cursor * @return A modified copy of {@code this} object */ public final ConversationsUserParams withCursor(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.cursor, value)) return this; return new ConversationsUserParams(this.shouldExcludeArchived, this.conversationTypes, this.userId, value, this.limit); } /** * Copy the current immutable object by setting a present value for the optional {@link ConversationsUserParamsIF#getLimit() limit} attribute. * @param value The value for limit, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final ConversationsUserParams withLimit(@Nullable Integer value) { @Nullable Integer newValue = value; if (Objects.equals(this.limit, newValue)) return this; return new ConversationsUserParams(this.shouldExcludeArchived, this.conversationTypes, this.userId, this.cursor, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link ConversationsUserParamsIF#getLimit() limit} 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 limit * @return A modified copy of {@code this} object */ public final ConversationsUserParams withLimit(Optional optional) { @Nullable Integer value = optional.orElse(null); if (Objects.equals(this.limit, value)) return this; return new ConversationsUserParams(this.shouldExcludeArchived, this.conversationTypes, this.userId, this.cursor, value); } /** * This instance is equal to all instances of {@code ConversationsUserParams} 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 ConversationsUserParams && equalTo(0, (ConversationsUserParams) another); } private boolean equalTo(int synthetic, ConversationsUserParams another) { return Objects.equals(shouldExcludeArchived, another.shouldExcludeArchived) && types.equals(another.types) && conversationTypes.equals(another.conversationTypes) && Objects.equals(userId, another.userId) && Objects.equals(cursor, another.cursor) && Objects.equals(limit, another.limit); } /** * Computes a hash code from attributes: {@code shouldExcludeArchived}, {@code types}, {@code conversationTypes}, {@code userId}, {@code cursor}, {@code limit}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + Objects.hashCode(shouldExcludeArchived); h += (h << 5) + types.hashCode(); h += (h << 5) + conversationTypes.hashCode(); h += (h << 5) + Objects.hashCode(userId); h += (h << 5) + Objects.hashCode(cursor); h += (h << 5) + Objects.hashCode(limit); return h; } /** * Prints the immutable value {@code ConversationsUserParams} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("ConversationsUserParams{"); if (shouldExcludeArchived != null) { builder.append("shouldExcludeArchived=").append(shouldExcludeArchived); } if (builder.length() > 24) builder.append(", "); builder.append("types=").append(types); builder.append(", "); builder.append("conversationTypes=").append(conversationTypes); if (userId != null) { builder.append(", "); builder.append("userId=").append(userId); } if (cursor != null) { builder.append(", "); builder.append("cursor=").append(cursor); } if (limit != null) { builder.append(", "); builder.append("limit=").append(limit); } 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 = "ConversationsUserParamsIF", generator = "Immutables") @Deprecated @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements ConversationsUserParamsIF { @Nullable Optional shouldExcludeArchived = Optional.empty(); @Nullable Set conversationTypes = Collections.emptySet(); @Nullable Optional userId = Optional.empty(); @Nullable Optional cursor = Optional.empty(); @Nullable Optional limit = Optional.empty(); @JsonProperty("exclude_archived") public void setShouldExcludeArchived(Optional shouldExcludeArchived) { this.shouldExcludeArchived = shouldExcludeArchived; } @JsonProperty @JsonIgnore public void setConversationTypes(Set conversationTypes) { this.conversationTypes = conversationTypes; } @JsonProperty("user") public void setUserId(Optional userId) { this.userId = userId; } @JsonProperty public void setCursor(Optional cursor) { this.cursor = cursor; } @JsonProperty public void setLimit(Optional limit) { this.limit = limit; } @Override public Optional shouldExcludeArchived() { throw new UnsupportedOperationException(); } @JsonIgnore @Override public String getTypes() { throw new UnsupportedOperationException(); } @Override public Set getConversationTypes() { throw new UnsupportedOperationException(); } @Override public Optional getUserId() { throw new UnsupportedOperationException(); } @Override public Optional getCursor() { throw new UnsupportedOperationException(); } @Override public Optional getLimit() { 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 ConversationsUserParams fromJson(Json json) { ConversationsUserParams.Builder builder = ConversationsUserParams.builder(); if (json.shouldExcludeArchived != null) { builder.setShouldExcludeArchived(json.shouldExcludeArchived); } if (json.conversationTypes != null) { builder.addAllConversationTypes(json.conversationTypes); } if (json.userId != null) { builder.setUserId(json.userId); } if (json.cursor != null) { builder.setCursor(json.cursor); } if (json.limit != null) { builder.setLimit(json.limit); } return builder.build(); } /** * Creates an immutable copy of a {@link ConversationsUserParamsIF} 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 ConversationsUserParams instance */ public static ConversationsUserParams copyOf(ConversationsUserParamsIF instance) { if (instance instanceof ConversationsUserParams) { return (ConversationsUserParams) instance; } return ConversationsUserParams.builder() .from(instance) .build(); } /** * Creates a builder for {@link ConversationsUserParams ConversationsUserParams}. *

   * ConversationsUserParams.builder()
   *    .setShouldExcludeArchived(Boolean) // optional {@link ConversationsUserParamsIF#shouldExcludeArchived() shouldExcludeArchived}
   *    .addConversationTypes|addAllConversationTypes(com.hubspot.slack.client.models.conversations.ConversationType) // {@link ConversationsUserParamsIF#getConversationTypes() conversationTypes} elements
   *    .setUserId(String) // optional {@link ConversationsUserParamsIF#getUserId() userId}
   *    .setCursor(String) // optional {@link ConversationsUserParamsIF#getCursor() cursor}
   *    .setLimit(Integer) // optional {@link ConversationsUserParamsIF#getLimit() limit}
   *    .build();
   * 
* @return A new ConversationsUserParams builder */ public static ConversationsUserParams.Builder builder() { return new ConversationsUserParams.Builder(); } /** * Builds instances of type {@link ConversationsUserParams ConversationsUserParams}. * 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 = "ConversationsUserParamsIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private @Nullable Boolean shouldExcludeArchived; private EnumSet conversationTypes = EnumSet.noneOf(ConversationType.class); private @Nullable String userId; private @Nullable String cursor; private @Nullable Integer limit; private Builder() { } /** * Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.methods.params.conversations.BaseConversationsFilter} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(BaseConversationsFilter 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.conversations.ConversationsUserParamsIF} instance. * @param instance The instance from which to copy values * @return {@code this} builder for use in a chained invocation */ public final Builder from(ConversationsUserParamsIF 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 BaseConversationsFilter) { BaseConversationsFilter instance = (BaseConversationsFilter) object; if ((bits & 0x1L) == 0) { Optional shouldExcludeArchivedOptional = instance.shouldExcludeArchived(); if (shouldExcludeArchivedOptional.isPresent()) { setShouldExcludeArchived(shouldExcludeArchivedOptional); } bits |= 0x1L; } if ((bits & 0x2L) == 0) { addAllConversationTypes(instance.getConversationTypes()); bits |= 0x2L; } } if (object instanceof ConversationsUserParamsIF) { ConversationsUserParamsIF instance = (ConversationsUserParamsIF) object; Optional cursorOptional = instance.getCursor(); if (cursorOptional.isPresent()) { setCursor(cursorOptional); } if ((bits & 0x1L) == 0) { Optional shouldExcludeArchivedOptional = instance.shouldExcludeArchived(); if (shouldExcludeArchivedOptional.isPresent()) { setShouldExcludeArchived(shouldExcludeArchivedOptional); } bits |= 0x1L; } if ((bits & 0x2L) == 0) { addAllConversationTypes(instance.getConversationTypes()); bits |= 0x2L; } Optional limitOptional = instance.getLimit(); if (limitOptional.isPresent()) { setLimit(limitOptional); } Optional userIdOptional = instance.getUserId(); if (userIdOptional.isPresent()) { setUserId(userIdOptional); } } } /** * Initializes the optional value {@link ConversationsUserParamsIF#shouldExcludeArchived() shouldExcludeArchived} to shouldExcludeArchived. * @param shouldExcludeArchived The value for shouldExcludeArchived, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setShouldExcludeArchived(@Nullable Boolean shouldExcludeArchived) { this.shouldExcludeArchived = shouldExcludeArchived; return this; } /** * Initializes the optional value {@link ConversationsUserParamsIF#shouldExcludeArchived() shouldExcludeArchived} to shouldExcludeArchived. * @param shouldExcludeArchived The value for shouldExcludeArchived * @return {@code this} builder for use in a chained invocation */ public final Builder setShouldExcludeArchived(Optional shouldExcludeArchived) { this.shouldExcludeArchived = shouldExcludeArchived.orElse(null); return this; } /** * Adds one element to {@link ConversationsUserParamsIF#getConversationTypes() conversationTypes} set. * @param element A conversationTypes element * @return {@code this} builder for use in a chained invocation */ public final Builder addConversationTypes(ConversationType element) { this.conversationTypes.add(Objects.requireNonNull(element, "conversationTypes element")); return this; } /** * Adds elements to {@link ConversationsUserParamsIF#getConversationTypes() conversationTypes} set. * @param elements An array of conversationTypes elements * @return {@code this} builder for use in a chained invocation */ public final Builder addConversationTypes(ConversationType... elements) { for (ConversationType element : elements) { this.conversationTypes.add(Objects.requireNonNull(element, "conversationTypes element")); } return this; } /** * Sets or replaces all elements for {@link ConversationsUserParamsIF#getConversationTypes() conversationTypes} set. * @param elements An iterable of conversationTypes elements * @return {@code this} builder for use in a chained invocation */ public final Builder setConversationTypes(Iterable elements) { this.conversationTypes.clear(); return addAllConversationTypes(elements); } /** * Adds elements to {@link ConversationsUserParamsIF#getConversationTypes() conversationTypes} set. * @param elements An iterable of conversationTypes elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllConversationTypes(Iterable elements) { for (ConversationType element : elements) { this.conversationTypes.add(Objects.requireNonNull(element, "conversationTypes element")); } return this; } /** * Initializes the optional value {@link ConversationsUserParamsIF#getUserId() userId} to userId. * @param userId The value for userId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setUserId(@Nullable String userId) { this.userId = userId; return this; } /** * Initializes the optional value {@link ConversationsUserParamsIF#getUserId() userId} to userId. * @param userId The value for userId * @return {@code this} builder for use in a chained invocation */ public final Builder setUserId(Optional userId) { this.userId = userId.orElse(null); return this; } /** * Initializes the optional value {@link ConversationsUserParamsIF#getCursor() cursor} to cursor. * @param cursor The value for cursor, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setCursor(@Nullable String cursor) { this.cursor = cursor; return this; } /** * Initializes the optional value {@link ConversationsUserParamsIF#getCursor() cursor} to cursor. * @param cursor The value for cursor * @return {@code this} builder for use in a chained invocation */ public final Builder setCursor(Optional cursor) { this.cursor = cursor.orElse(null); return this; } /** * Initializes the optional value {@link ConversationsUserParamsIF#getLimit() limit} to limit. * @param limit The value for limit, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setLimit(@Nullable Integer limit) { this.limit = limit; return this; } /** * Initializes the optional value {@link ConversationsUserParamsIF#getLimit() limit} to limit. * @param limit The value for limit * @return {@code this} builder for use in a chained invocation */ public final Builder setLimit(Optional limit) { this.limit = limit.orElse(null); return this; } /** * Builds a new {@link ConversationsUserParams ConversationsUserParams}. * @return An immutable instance of ConversationsUserParams * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public ConversationsUserParams build() { return new ConversationsUserParams(shouldExcludeArchived, createUnmodifiableEnumSet(conversationTypes), userId, cursor, limit); } } 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; } @SuppressWarnings("unchecked") private static > Set createUnmodifiableEnumSet(Iterable iterable) { if (iterable instanceof EnumSet) { return Collections.unmodifiableSet(EnumSet.copyOf((EnumSet) iterable)); } List list = createSafeList(iterable, true, false); switch(list.size()) { case 0: return Collections.emptySet(); case 1: return Collections.singleton(list.get(0)); default: return Collections.unmodifiableSet(EnumSet.copyOf(list)); } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy