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

com.hubspot.slack.client.methods.params.files.FilesUploadParams 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 com.hubspot.slack.client.models.files.SlackFileType;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.File;
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 FilesUploadParamsIF}.
 * 

* Use the builder to create immutable instances: * {@code FilesUploadParams.builder()}. */ @Generated(from = "FilesUploadParamsIF", generator = "Immutables") @SuppressWarnings({"all"}) @SuppressFBWarnings @ParametersAreNonnullByDefault @javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor") @Immutable public final class FilesUploadParams implements FilesUploadParamsIF { private final List channels; private final @Nullable String content; private final @Nullable File file; private final @Nullable String filename; private final @Nullable SlackFileType filetype; private final @Nullable String initialComment; private final @Nullable String threadTs; private final @Nullable String title; private FilesUploadParams( List channels, @Nullable String content, @Nullable File file, @Nullable String filename, @Nullable SlackFileType filetype, @Nullable String initialComment, @Nullable String threadTs, @Nullable String title) { this.channels = channels; this.content = content; this.file = file; this.filename = filename; this.filetype = filetype; this.initialComment = initialComment; this.threadTs = threadTs; this.title = title; } /** * @return The value of the {@code channels} attribute */ @JsonProperty @Override public List getChannels() { return channels; } /** * @return The value of the {@code content} attribute */ @JsonProperty @Override public Optional getContent() { return Optional.ofNullable(content); } /** * @return The value of the {@code file} attribute */ @JsonProperty @Override public Optional getFile() { return Optional.ofNullable(file); } /** * @return The value of the {@code filename} attribute */ @JsonProperty @Override public Optional getFilename() { return Optional.ofNullable(filename); } /** * @return The value of the {@code filetype} attribute */ @JsonProperty @Override public Optional getFiletype() { return Optional.ofNullable(filetype); } /** * @return The value of the {@code initialComment} attribute */ @JsonProperty @Override public Optional getInitialComment() { return Optional.ofNullable(initialComment); } /** * @return The value of the {@code threadTs} attribute */ @JsonProperty @Override public Optional getThreadTs() { return Optional.ofNullable(threadTs); } /** * @return The value of the {@code title} attribute */ @JsonProperty @Override public Optional getTitle() { return Optional.ofNullable(title); } /** * Copy the current immutable object with elements that replace the content of {@link FilesUploadParamsIF#getChannels() channels}. * @param elements The elements to set * @return A modified copy of {@code this} object */ public final FilesUploadParams withChannels(String... elements) { List newValue = createUnmodifiableList(false, createSafeList(Arrays.asList(elements), true, false)); return validate(new FilesUploadParams( newValue, this.content, this.file, this.filename, this.filetype, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object with elements that replace the content of {@link FilesUploadParamsIF#getChannels() channels}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of channels elements to set * @return A modified copy of {@code this} object */ public final FilesUploadParams withChannels(Iterable elements) { if (this.channels == elements) return this; List newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return validate(new FilesUploadParams( newValue, this.content, this.file, this.filename, this.filetype, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object by setting a present value for the optional {@link FilesUploadParamsIF#getContent() content} attribute. * @param value The value for content, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final FilesUploadParams withContent(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.content, newValue)) return this; return validate(new FilesUploadParams( this.channels, newValue, this.file, this.filename, this.filetype, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object by setting an optional value for the {@link FilesUploadParamsIF#getContent() content} 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 content * @return A modified copy of {@code this} object */ public final FilesUploadParams withContent(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.content, value)) return this; return validate(new FilesUploadParams( this.channels, value, this.file, this.filename, this.filetype, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object by setting a present value for the optional {@link FilesUploadParamsIF#getFile() file} attribute. * @param value The value for file, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final FilesUploadParams withFile(@Nullable File value) { @Nullable File newValue = value; if (this.file == newValue) return this; return validate(new FilesUploadParams( this.channels, this.content, newValue, this.filename, this.filetype, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object by setting an optional value for the {@link FilesUploadParamsIF#getFile() file} attribute. * A shallow reference equality check is used on unboxed optional value to prevent copying of the same value by returning {@code this}. * @param optional A value for file * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final FilesUploadParams withFile(Optional optional) { @Nullable File value = optional.orElse(null); if (this.file == value) return this; return validate(new FilesUploadParams( this.channels, this.content, value, this.filename, this.filetype, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object by setting a present value for the optional {@link FilesUploadParamsIF#getFilename() filename} attribute. * @param value The value for filename, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final FilesUploadParams withFilename(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.filename, newValue)) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, newValue, this.filetype, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object by setting an optional value for the {@link FilesUploadParamsIF#getFilename() filename} 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 filename * @return A modified copy of {@code this} object */ public final FilesUploadParams withFilename(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.filename, value)) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, value, this.filetype, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object by setting a present value for the optional {@link FilesUploadParamsIF#getFiletype() filetype} attribute. * @param value The value for filetype, {@code null} is accepted as {@code java.util.Optional.empty()} * @return A modified copy of {@code this} object */ public final FilesUploadParams withFiletype(@Nullable SlackFileType value) { @Nullable SlackFileType newValue = value; if (this.filetype == newValue) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, this.filename, newValue, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object by setting an optional value for the {@link FilesUploadParamsIF#getFiletype() filetype} 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 filetype * @return A modified copy of {@code this} object */ @SuppressWarnings("unchecked") // safe covariant cast public final FilesUploadParams withFiletype(Optional optional) { @Nullable SlackFileType value = optional.orElse(null); if (this.filetype == value) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, this.filename, value, this.initialComment, this.threadTs, this.title)); } /** * Copy the current immutable object by setting a present value for the optional {@link FilesUploadParamsIF#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 FilesUploadParams withInitialComment(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.initialComment, newValue)) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, this.filename, this.filetype, newValue, this.threadTs, this.title)); } /** * Copy the current immutable object by setting an optional value for the {@link FilesUploadParamsIF#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 FilesUploadParams withInitialComment(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.initialComment, value)) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, this.filename, this.filetype, value, this.threadTs, this.title)); } /** * Copy the current immutable object by setting a present value for the optional {@link FilesUploadParamsIF#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 FilesUploadParams withThreadTs(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.threadTs, newValue)) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, this.filename, this.filetype, this.initialComment, newValue, this.title)); } /** * Copy the current immutable object by setting an optional value for the {@link FilesUploadParamsIF#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 FilesUploadParams withThreadTs(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.threadTs, value)) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, this.filename, this.filetype, this.initialComment, value, this.title)); } /** * Copy the current immutable object by setting a present value for the optional {@link FilesUploadParamsIF#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 FilesUploadParams withTitle(@Nullable String value) { @Nullable String newValue = value; if (Objects.equals(this.title, newValue)) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, this.filename, this.filetype, this.initialComment, this.threadTs, newValue)); } /** * Copy the current immutable object by setting an optional value for the {@link FilesUploadParamsIF#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 FilesUploadParams withTitle(Optional optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.title, value)) return this; return validate(new FilesUploadParams( this.channels, this.content, this.file, this.filename, this.filetype, this.initialComment, this.threadTs, value)); } /** * This instance is equal to all instances of {@code FilesUploadParams} 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 FilesUploadParams && equalTo(0, (FilesUploadParams) another); } private boolean equalTo(int synthetic, FilesUploadParams another) { return channels.equals(another.channels) && Objects.equals(content, another.content) && Objects.equals(file, another.file) && Objects.equals(filename, another.filename) && Objects.equals(filetype, another.filetype) && Objects.equals(initialComment, another.initialComment) && Objects.equals(threadTs, another.threadTs) && Objects.equals(title, another.title); } /** * Computes a hash code from attributes: {@code channels}, {@code content}, {@code file}, {@code filename}, {@code filetype}, {@code initialComment}, {@code threadTs}, {@code title}. * @return hashCode value */ @Override public int hashCode() { int h = 5381; h += (h << 5) + channels.hashCode(); h += (h << 5) + Objects.hashCode(content); h += (h << 5) + Objects.hashCode(file); h += (h << 5) + Objects.hashCode(filename); h += (h << 5) + Objects.hashCode(filetype); h += (h << 5) + Objects.hashCode(initialComment); h += (h << 5) + Objects.hashCode(threadTs); h += (h << 5) + Objects.hashCode(title); return h; } /** * Prints the immutable value {@code FilesUploadParams} with attribute values. * @return A string representation of the value */ @Override public String toString() { StringBuilder builder = new StringBuilder("FilesUploadParams{"); builder.append("channels=").append(channels); if (content != null) { builder.append(", "); builder.append("content=").append(content); } if (file != null) { builder.append(", "); builder.append("file=").append(file); } if (filename != null) { builder.append(", "); builder.append("filename=").append(filename); } if (filetype != null) { builder.append(", "); builder.append("filetype=").append(filetype); } if (initialComment != null) { builder.append(", "); builder.append("initialComment=").append(initialComment); } if (threadTs != null) { builder.append(", "); builder.append("threadTs=").append(threadTs); } if (title != null) { builder.append(", "); builder.append("title=").append(title); } 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 = "FilesUploadParamsIF", generator = "Immutables") @Deprecated @JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE) static final class Json implements FilesUploadParamsIF { @Nullable List channels = Collections.emptyList(); @Nullable Optional content = Optional.empty(); @Nullable Optional file = Optional.empty(); @Nullable Optional filename = Optional.empty(); @Nullable Optional filetype = Optional.empty(); @Nullable Optional initialComment = Optional.empty(); @Nullable Optional threadTs = Optional.empty(); @Nullable Optional title = Optional.empty(); @JsonProperty public void setChannels(List channels) { this.channels = channels; } @JsonProperty public void setContent(Optional content) { this.content = content; } @JsonProperty public void setFile(Optional file) { this.file = file; } @JsonProperty public void setFilename(Optional filename) { this.filename = filename; } @JsonProperty public void setFiletype(Optional filetype) { this.filetype = filetype; } @JsonProperty public void setInitialComment(Optional initialComment) { this.initialComment = initialComment; } @JsonProperty public void setThreadTs(Optional threadTs) { this.threadTs = threadTs; } @JsonProperty public void setTitle(Optional title) { this.title = title; } @Override public List getChannels() { throw new UnsupportedOperationException(); } @Override public Optional getContent() { throw new UnsupportedOperationException(); } @Override public Optional getFile() { throw new UnsupportedOperationException(); } @Override public Optional getFilename() { throw new UnsupportedOperationException(); } @Override public Optional getFiletype() { throw new UnsupportedOperationException(); } @Override public Optional getInitialComment() { throw new UnsupportedOperationException(); } @Override public Optional getThreadTs() { throw new UnsupportedOperationException(); } @Override public Optional getTitle() { 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 FilesUploadParams fromJson(Json json) { FilesUploadParams.Builder builder = FilesUploadParams.builder(); if (json.channels != null) { builder.addAllChannels(json.channels); } if (json.content != null) { builder.setContent(json.content); } if (json.file != null) { builder.setFile(json.file); } if (json.filename != null) { builder.setFilename(json.filename); } if (json.filetype != null) { builder.setFiletype(json.filetype); } if (json.initialComment != null) { builder.setInitialComment(json.initialComment); } if (json.threadTs != null) { builder.setThreadTs(json.threadTs); } if (json.title != null) { builder.setTitle(json.title); } return builder.build(); } private static FilesUploadParams validate(FilesUploadParams instance) { instance.hasContent(); return instance; } /** * Creates an immutable copy of a {@link FilesUploadParamsIF} 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 FilesUploadParams instance */ public static FilesUploadParams copyOf(FilesUploadParamsIF instance) { if (instance instanceof FilesUploadParams) { return (FilesUploadParams) instance; } return FilesUploadParams.builder() .from(instance) .build(); } /** * Creates a builder for {@link FilesUploadParams FilesUploadParams}. *

   * FilesUploadParams.builder()
   *    .addChannels|addAllChannels(String) // {@link FilesUploadParamsIF#getChannels() channels} elements
   *    .setContent(String) // optional {@link FilesUploadParamsIF#getContent() content}
   *    .setFile(java.io.File) // optional {@link FilesUploadParamsIF#getFile() file}
   *    .setFilename(String) // optional {@link FilesUploadParamsIF#getFilename() filename}
   *    .setFiletype(com.hubspot.slack.client.models.files.SlackFileType) // optional {@link FilesUploadParamsIF#getFiletype() filetype}
   *    .setInitialComment(String) // optional {@link FilesUploadParamsIF#getInitialComment() initialComment}
   *    .setThreadTs(String) // optional {@link FilesUploadParamsIF#getThreadTs() threadTs}
   *    .setTitle(String) // optional {@link FilesUploadParamsIF#getTitle() title}
   *    .build();
   * 
* @return A new FilesUploadParams builder */ public static FilesUploadParams.Builder builder() { return new FilesUploadParams.Builder(); } /** * Builds instances of type {@link FilesUploadParams FilesUploadParams}. * 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 = "FilesUploadParamsIF", generator = "Immutables") @NotThreadSafe public static final class Builder { private List channels = new ArrayList(); private @Nullable String content; private @Nullable File file; private @Nullable String filename; private @Nullable SlackFileType filetype; private @Nullable String initialComment; private @Nullable String threadTs; private @Nullable String title; private Builder() { } /** * Fill a builder with attribute values from the provided {@code FilesUploadParamsIF} 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(FilesUploadParamsIF instance) { Objects.requireNonNull(instance, "instance"); addAllChannels(instance.getChannels()); Optional contentOptional = instance.getContent(); if (contentOptional.isPresent()) { setContent(contentOptional); } Optional fileOptional = instance.getFile(); if (fileOptional.isPresent()) { setFile(fileOptional); } Optional filenameOptional = instance.getFilename(); if (filenameOptional.isPresent()) { setFilename(filenameOptional); } Optional filetypeOptional = instance.getFiletype(); if (filetypeOptional.isPresent()) { setFiletype(filetypeOptional); } Optional initialCommentOptional = instance.getInitialComment(); if (initialCommentOptional.isPresent()) { setInitialComment(initialCommentOptional); } Optional threadTsOptional = instance.getThreadTs(); if (threadTsOptional.isPresent()) { setThreadTs(threadTsOptional); } Optional titleOptional = instance.getTitle(); if (titleOptional.isPresent()) { setTitle(titleOptional); } return this; } /** * Adds one element to {@link FilesUploadParamsIF#getChannels() channels} list. * @param element A channels element * @return {@code this} builder for use in a chained invocation */ public final Builder addChannels(String element) { this.channels.add(Objects.requireNonNull(element, "channels element")); return this; } /** * Adds elements to {@link FilesUploadParamsIF#getChannels() channels} list. * @param elements An array of channels elements * @return {@code this} builder for use in a chained invocation */ public final Builder addChannels(String... elements) { for (String element : elements) { this.channels.add(Objects.requireNonNull(element, "channels element")); } return this; } /** * Sets or replaces all elements for {@link FilesUploadParamsIF#getChannels() channels} list. * @param elements An iterable of channels elements * @return {@code this} builder for use in a chained invocation */ public final Builder setChannels(Iterable elements) { this.channels.clear(); return addAllChannels(elements); } /** * Adds elements to {@link FilesUploadParamsIF#getChannels() channels} list. * @param elements An iterable of channels elements * @return {@code this} builder for use in a chained invocation */ public final Builder addAllChannels(Iterable elements) { for (String element : elements) { this.channels.add(Objects.requireNonNull(element, "channels element")); } return this; } /** * Initializes the optional value {@link FilesUploadParamsIF#getContent() content} to content. * @param content The value for content, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setContent(@Nullable String content) { this.content = content; return this; } /** * Initializes the optional value {@link FilesUploadParamsIF#getContent() content} to content. * @param content The value for content * @return {@code this} builder for use in a chained invocation */ public final Builder setContent(Optional content) { this.content = content.orElse(null); return this; } /** * Initializes the optional value {@link FilesUploadParamsIF#getFile() file} to file. * @param file The value for file, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setFile(@Nullable File file) { this.file = file; return this; } /** * Initializes the optional value {@link FilesUploadParamsIF#getFile() file} to file. * @param file The value for file * @return {@code this} builder for use in a chained invocation */ public final Builder setFile(Optional file) { this.file = file.orElse(null); return this; } /** * Initializes the optional value {@link FilesUploadParamsIF#getFilename() filename} to filename. * @param filename The value for filename, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setFilename(@Nullable String filename) { this.filename = filename; return this; } /** * Initializes the optional value {@link FilesUploadParamsIF#getFilename() filename} to filename. * @param filename The value for filename * @return {@code this} builder for use in a chained invocation */ public final Builder setFilename(Optional filename) { this.filename = filename.orElse(null); return this; } /** * Initializes the optional value {@link FilesUploadParamsIF#getFiletype() filetype} to filetype. * @param filetype The value for filetype, {@code null} is accepted as {@code java.util.Optional.empty()} * @return {@code this} builder for chained invocation */ public final Builder setFiletype(@Nullable SlackFileType filetype) { this.filetype = filetype; return this; } /** * Initializes the optional value {@link FilesUploadParamsIF#getFiletype() filetype} to filetype. * @param filetype The value for filetype * @return {@code this} builder for use in a chained invocation */ public final Builder setFiletype(Optional filetype) { this.filetype = filetype.orElse(null); return this; } /** * Initializes the optional value {@link FilesUploadParamsIF#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 FilesUploadParamsIF#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; } /** * Initializes the optional value {@link FilesUploadParamsIF#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 FilesUploadParamsIF#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 FilesUploadParamsIF#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 FilesUploadParamsIF#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; } /** * Builds a new {@link FilesUploadParams FilesUploadParams}. * @return An immutable instance of FilesUploadParams * @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing */ public FilesUploadParams build() { return FilesUploadParams.validate(new FilesUploadParams( createUnmodifiableList(true, channels), content, file, filename, filetype, initialComment, threadTs, title)); } } 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