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

com.hubspot.slack.client.methods.params.files.CompleteUploadExternalParams Maven / Gradle / Ivy

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

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
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 CompleteUploadExternalParamsIF}.
 * 

* Use the builder to create immutable instances: * {@code CompleteUploadExternalParams.builder()}. */ @Generated(from = "CompleteUploadExternalParamsIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class CompleteUploadExternalParams implements CompleteUploadExternalParamsIF { private final List files; private final @Nullable String channelId; private final @Nullable String threadTs; private final @Nullable String initialComment; private CompleteUploadExternalParams( List files, @Nullable String channelId, @Nullable String threadTs, @Nullable String initialComment) { this.files = files; this.channelId = channelId; this.threadTs = threadTs; this.initialComment = initialComment; } /** * @return The value of the {@code files} attribute */ @JsonProperty @Override public List getFiles() { return files; } /** * @return The value of the {@code channelId} attribute */ @JsonProperty @Override public Optional getChannelId() { return Optional.ofNullable(channelId); } /** * @return The value of the {@code threadTs} attribute */ @JsonProperty @Override public Optional getThreadTs() { return Optional.ofNullable(threadTs); } /** * @return The value of the {@code initialComment} attribute */ @JsonProperty @Override public Optional getInitialComment() { return Optional.ofNullable(initialComment); } /** * Copy the current immutable object with elements that replace the content of {@link CompleteUploadExternalParamsIF#getFiles() files}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final CompleteUploadExternalParams withFiles(FileInfo... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return new CompleteUploadExternalParams(newValue, this.channelId, this.threadTs, this.initialComment); } /** * Copy the current immutable object with elements that replace the content of {@link CompleteUploadExternalParamsIF#getFiles() files}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of files elements to set * @return A modified copy of {@code this} object */ public final CompleteUploadExternalParams withFiles(Iterable elements) { if (this.files == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new CompleteUploadExternalParams(newValue, this.channelId, this.threadTs, this.initialComment); } /** * Copy the current immutable object by setting a present value for the optional {@link CompleteUploadExternalParamsIF#getChannelId() channelId} attribute. * @param value The value for channelId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final CompleteUploadExternalParams withChannelId(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.channelId, newValue)) return this; return new CompleteUploadExternalParams(this.files, newValue, this.threadTs, this.initialComment); } /** * Copy the current immutable object by setting an optional value for the {@link CompleteUploadExternalParamsIF#getChannelId() channelId} 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 channelId * @return A modified copy of {@code this} object */ public final CompleteUploadExternalParams withChannelId(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.channelId, value)) return this; return new CompleteUploadExternalParams(this.files, value, this.threadTs, this.initialComment); } /** * Copy the current immutable object by setting a present value for the optional {@link CompleteUploadExternalParamsIF#getThreadTs() threadTs} attribute. * @param value The value for threadTs, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final CompleteUploadExternalParams withThreadTs(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.threadTs, newValue)) return this; return new CompleteUploadExternalParams(this.files, this.channelId, newValue, this.initialComment); } /** * Copy the current immutable object by setting an optional value for the {@link CompleteUploadExternalParamsIF#getThreadTs() threadTs} 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 threadTs * @return A modified copy of {@code this} object */ public final CompleteUploadExternalParams withThreadTs(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.threadTs, value)) return this; return new CompleteUploadExternalParams(this.files, this.channelId, value, this.initialComment); } /** * Copy the current immutable object by setting a present value for the optional {@link CompleteUploadExternalParamsIF#getInitialComment() initialComment} attribute. * @param value The value for initialComment, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final CompleteUploadExternalParams withInitialComment(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.initialComment, newValue)) return this; return new CompleteUploadExternalParams(this.files, this.channelId, this.threadTs, newValue); } /** * Copy the current immutable object by setting an optional value for the {@link CompleteUploadExternalParamsIF#getInitialComment() initialComment} 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 initialComment * @return A modified copy of {@code this} object */ public final CompleteUploadExternalParams withInitialComment(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.initialComment, value)) return this; return new CompleteUploadExternalParams(this.files, this.channelId, this.threadTs, value); } /** * This instance is equal to all instances of {@code CompleteUploadExternalParams} 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 CompleteUploadExternalParams && equalTo(0, (CompleteUploadExternalParams) another); } private boolean equalTo(int synthetic, CompleteUploadExternalParams another) { return files.equals(another.files) && Objects.equals(channelId, another.channelId) && Objects.equals(threadTs, another.threadTs) && Objects.equals(initialComment, another.initialComment); } /** * Computes a hash code from attributes: {@code files}, {@code channelId}, {@code threadTs}, {@code initialComment}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + files.hashCode(); h += (h << 5) + Objects.hashCode(channelId); h += (h << 5) + Objects.hashCode(threadTs); h += (h << 5) + Objects.hashCode(initialComment); return h; } /** * Prints the immutable value {@code CompleteUploadExternalParams} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("CompleteUploadExternalParams{"); builder.append("files=").append(files); if (channelId != null) { builder.append(", "); builder.append("channelId=").append(channelId); } if (threadTs != null) { builder.append(", "); builder.append("threadTs=").append(threadTs); } if (initialComment != null) { builder.append(", "); builder.append("initialComment=").append(initialComment); } 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 = "CompleteUploadExternalParamsIF", generator = "Immutables") @Deprecated @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements CompleteUploadExternalParamsIF { @Nullable List files = Collections.emptyList(); @Nullable Optional channelId = Optional.empty(); @Nullable Optional threadTs = Optional.empty(); @Nullable Optional initialComment = Optional.empty(); @JsonProperty public void setFiles(List files) { this.files = files; } @JsonProperty public void setChannelId(Optional channelId) { this.channelId = channelId; } @JsonProperty public void setThreadTs(Optional threadTs) { this.threadTs = threadTs; } @JsonProperty public void setInitialComment(Optional initialComment) { this.initialComment = initialComment; } @Override public List getFiles() { throw new UnsupportedOperationException(); } @Override public Optional getChannelId() { throw new UnsupportedOperationException(); } @Override public Optional getThreadTs() { throw new UnsupportedOperationException(); } @Override public Optional getInitialComment() { 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 CompleteUploadExternalParams fromJson(Json json) { CompleteUploadExternalParams.Builder builder = CompleteUploadExternalParams.builder(); if (json.files != null) { builder.addAllFiles(json.files); } if (json.channelId != null) { builder.setChannelId(json.channelId); } if (json.threadTs != null) { builder.setThreadTs(json.threadTs); } if (json.initialComment != null) { builder.setInitialComment(json.initialComment); } return builder.build(); } /** * Creates an immutable copy of a {@link CompleteUploadExternalParamsIF} 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 CompleteUploadExternalParams instance */ public static CompleteUploadExternalParams copyOf(CompleteUploadExternalParamsIF instance) { if (instance instanceof CompleteUploadExternalParams) { return (CompleteUploadExternalParams) instance; } return CompleteUploadExternalParams.builder() .from(instance) .build(); } /** * Creates a builder for {@link CompleteUploadExternalParams CompleteUploadExternalParams}. *

   * CompleteUploadExternalParams.builder()
   *    .addFiles|addAllFiles(FileInfo) // {@link CompleteUploadExternalParamsIF#getFiles() files} elements
   *    .setChannelId(String) // optional {@link CompleteUploadExternalParamsIF#getChannelId() channelId}
   *    .setThreadTs(String) // optional {@link CompleteUploadExternalParamsIF#getThreadTs() threadTs}
   *    .setInitialComment(String) // optional {@link CompleteUploadExternalParamsIF#getInitialComment() initialComment}
   *    .build();
   * 
* @return A new CompleteUploadExternalParams builder */ public static CompleteUploadExternalParams.Builder builder() { return new CompleteUploadExternalParams.Builder(); } /** * Builds instances of type {@link CompleteUploadExternalParams CompleteUploadExternalParams}. * 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 = "CompleteUploadExternalParamsIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private List files = new ArrayList(); private @Nullable String channelId; private @Nullable String threadTs; private @Nullable String initialComment; private Builder() { } /** * Fill a builder with attribute values from the provided {@code CompleteUploadExternalParamsIF} 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(CompleteUploadExternalParamsIF instance) { Objects.requireNonNull(instance, "instance"); addAllFiles(instance.getFiles()); Optional channelIdOptional = instance.getChannelId(); if (channelIdOptional.isPresent()) { setChannelId(channelIdOptional); } Optional threadTsOptional = instance.getThreadTs(); if (threadTsOptional.isPresent()) { setThreadTs(threadTsOptional); } Optional initialCommentOptional = instance.getInitialComment(); if (initialCommentOptional.isPresent()) { setInitialComment(initialCommentOptional); } return this; } /** * Adds one element to {@link CompleteUploadExternalParamsIF#getFiles() files} list. * @param element A files element * @return {@code this} builder for use in a chained invocation */ public final Builder addFiles(FileInfo element) { this.files.add(Objects.requireNonNull(element, "files element")); return this; } /** * Adds elements to {@link CompleteUploadExternalParamsIF#getFiles() files} list. * @param elements An array of files elements * @return {@code this} builder for use in a chained invocation */ public final Builder addFiles(FileInfo... elements) { for (FileInfo element : elements) { this.files.add(Objects.requireNonNull(element, "files element")); } return this; } /** * Sets or replaces all elements for {@link CompleteUploadExternalParamsIF#getFiles() files} list. * @param elements An iterable of files elements * @return {@code this} builder for use in a chained invocation */ public final Builder setFiles(Iterable elements) { this.files.clear(); return addAllFiles(elements); } /** * Adds elements to {@link CompleteUploadExternalParamsIF#getFiles() files} list. * @param elements An iterable of files elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllFiles(Iterable elements) { for (FileInfo element : elements) { this.files.add(Objects.requireNonNull(element, "files element")); } return this; } /** * Initializes the optional value {@link CompleteUploadExternalParamsIF#getChannelId() channelId} to channelId. * @param channelId The value for channelId, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setChannelId(@Nullable String channelId) { this.channelId = channelId; return this; } /** * Initializes the optional value {@link CompleteUploadExternalParamsIF#getChannelId() channelId} to channelId. * @param channelId The value for channelId * @return {@code this} builder for use in a chained invocation */ public final Builder setChannelId(Optional channelId) { this.channelId = channelId.orElse(null); return this; } /** * Initializes the optional value {@link CompleteUploadExternalParamsIF#getThreadTs() threadTs} to threadTs. * @param threadTs The value for threadTs, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setThreadTs(@Nullable String threadTs) { this.threadTs = threadTs; return this; } /** * Initializes the optional value {@link CompleteUploadExternalParamsIF#getThreadTs() threadTs} to threadTs. * @param threadTs The value for threadTs * @return {@code this} builder for use in a chained invocation */ public final Builder setThreadTs(Optional threadTs) { this.threadTs = threadTs.orElse(null); return this; } /** * Initializes the optional value {@link CompleteUploadExternalParamsIF#getInitialComment() initialComment} to initialComment. * @param initialComment The value for initialComment, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setInitialComment(@Nullable String initialComment) { this.initialComment = initialComment; return this; } /** * Initializes the optional value {@link CompleteUploadExternalParamsIF#getInitialComment() initialComment} to initialComment. * @param initialComment The value for initialComment * @return {@code this} builder for use in a chained invocation */ public final Builder setInitialComment(Optional initialComment) { this.initialComment = initialComment.orElse(null); return this; } /** * Builds a new {@link CompleteUploadExternalParams CompleteUploadExternalParams}. * @return An immutable instance of CompleteUploadExternalParams * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public CompleteUploadExternalParams build() { return new CompleteUploadExternalParams(createUnmodifiableList(true, files), channelId, threadTs, initialComment); } } 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