
com.hubspot.slack.client.methods.params.files.GetUploadUrlExternalParams 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.immutables.validation.InvalidImmutableStateException;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.ArrayList;
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 GetUploadUrlExternalParamsIF}.
*
* Use the builder to create immutable instances:
* {@code GetUploadUrlExternalParams.builder()}.
*/
@Generated(from = "GetUploadUrlExternalParamsIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class GetUploadUrlExternalParams
implements GetUploadUrlExternalParamsIF {
private final String filename;
private final Long length;
private final @Nullable String altText;
private final @Nullable String snippetType;
private GetUploadUrlExternalParams(
String filename,
Long length,
@Nullable String altText,
@Nullable String snippetType) {
this.filename = filename;
this.length = length;
this.altText = altText;
this.snippetType = snippetType;
}
/**
* @return The value of the {@code filename} attribute
*/
@JsonProperty
@Override
public String getFilename() {
return filename;
}
/**
* @return The value of the {@code length} attribute
*/
@JsonProperty
@Override
public Long getLength() {
return length;
}
/**
* @return The value of the {@code altText} attribute
*/
@JsonProperty
@Override
public Optional getAltText() {
return Optional.ofNullable(altText);
}
/**
* @return The value of the {@code snippetType} attribute
*/
@JsonProperty
@Override
public Optional getSnippetType() {
return Optional.ofNullable(snippetType);
}
/**
* Copy the current immutable object by setting a value for the {@link GetUploadUrlExternalParamsIF#getFilename() filename} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for filename
* @return A modified copy of the {@code this} object
*/
public final GetUploadUrlExternalParams withFilename(String value) {
String newValue = Objects.requireNonNull(value, "filename");
if (this.filename.equals(newValue)) return this;
return new GetUploadUrlExternalParams(newValue, this.length, this.altText, this.snippetType);
}
/**
* Copy the current immutable object by setting a value for the {@link GetUploadUrlExternalParamsIF#getLength() length} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for length
* @return A modified copy of the {@code this} object
*/
public final GetUploadUrlExternalParams withLength(Long value) {
Long newValue = Objects.requireNonNull(value, "length");
if (this.length.equals(newValue)) return this;
return new GetUploadUrlExternalParams(this.filename, newValue, this.altText, this.snippetType);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link GetUploadUrlExternalParamsIF#getAltText() altText} attribute.
* @param value The value for altText, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final GetUploadUrlExternalParams withAltText(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.altText, newValue)) return this;
return new GetUploadUrlExternalParams(this.filename, this.length, newValue, this.snippetType);
}
/**
* Copy the current immutable object by setting an optional value for the {@link GetUploadUrlExternalParamsIF#getAltText() altText} 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 altText
* @return A modified copy of {@code this} object
*/
public final GetUploadUrlExternalParams withAltText(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.altText, value)) return this;
return new GetUploadUrlExternalParams(this.filename, this.length, value, this.snippetType);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link GetUploadUrlExternalParamsIF#getSnippetType() snippetType} attribute.
* @param value The value for snippetType, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final GetUploadUrlExternalParams withSnippetType(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.snippetType, newValue)) return this;
return new GetUploadUrlExternalParams(this.filename, this.length, this.altText, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link GetUploadUrlExternalParamsIF#getSnippetType() snippetType} 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 snippetType
* @return A modified copy of {@code this} object
*/
public final GetUploadUrlExternalParams withSnippetType(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.snippetType, value)) return this;
return new GetUploadUrlExternalParams(this.filename, this.length, this.altText, value);
}
/**
* This instance is equal to all instances of {@code GetUploadUrlExternalParams} 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 GetUploadUrlExternalParams
&& equalTo(0, (GetUploadUrlExternalParams) another);
}
private boolean equalTo(int synthetic, GetUploadUrlExternalParams another) {
return filename.equals(another.filename)
&& length.equals(another.length)
&& Objects.equals(altText, another.altText)
&& Objects.equals(snippetType, another.snippetType);
}
/**
* Computes a hash code from attributes: {@code filename}, {@code length}, {@code altText}, {@code snippetType}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + filename.hashCode();
h += (h << 5) + length.hashCode();
h += (h << 5) + Objects.hashCode(altText);
h += (h << 5) + Objects.hashCode(snippetType);
return h;
}
/**
* Prints the immutable value {@code GetUploadUrlExternalParams} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("GetUploadUrlExternalParams{");
builder.append("filename=").append(filename);
builder.append(", ");
builder.append("length=").append(length);
if (altText != null) {
builder.append(", ");
builder.append("altText=").append(altText);
}
if (snippetType != null) {
builder.append(", ");
builder.append("snippetType=").append(snippetType);
}
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 = "GetUploadUrlExternalParamsIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json
implements GetUploadUrlExternalParamsIF {
@Nullable String filename;
@Nullable Long length;
@Nullable Optional altText = Optional.empty();
@Nullable Optional snippetType = Optional.empty();
@JsonProperty
public void setFilename(String filename) {
this.filename = filename;
}
@JsonProperty
public void setLength(Long length) {
this.length = length;
}
@JsonProperty
public void setAltText(Optional altText) {
this.altText = altText;
}
@JsonProperty
public void setSnippetType(Optional snippetType) {
this.snippetType = snippetType;
}
@Override
public String getFilename() { throw new UnsupportedOperationException(); }
@Override
public Long getLength() { throw new UnsupportedOperationException(); }
@Override
public Optional getAltText() { throw new UnsupportedOperationException(); }
@Override
public Optional getSnippetType() { 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 GetUploadUrlExternalParams fromJson(Json json) {
GetUploadUrlExternalParams.Builder builder = GetUploadUrlExternalParams.builder();
if (json.filename != null) {
builder.setFilename(json.filename);
}
if (json.length != null) {
builder.setLength(json.length);
}
if (json.altText != null) {
builder.setAltText(json.altText);
}
if (json.snippetType != null) {
builder.setSnippetType(json.snippetType);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link GetUploadUrlExternalParamsIF} 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 GetUploadUrlExternalParams instance
*/
public static GetUploadUrlExternalParams copyOf(GetUploadUrlExternalParamsIF instance) {
if (instance instanceof GetUploadUrlExternalParams) {
return (GetUploadUrlExternalParams) instance;
}
return GetUploadUrlExternalParams.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link GetUploadUrlExternalParams GetUploadUrlExternalParams}.
*
* GetUploadUrlExternalParams.builder()
* .setFilename(String) // required {@link GetUploadUrlExternalParamsIF#getFilename() filename}
* .setLength(Long) // required {@link GetUploadUrlExternalParamsIF#getLength() length}
* .setAltText(String) // optional {@link GetUploadUrlExternalParamsIF#getAltText() altText}
* .setSnippetType(String) // optional {@link GetUploadUrlExternalParamsIF#getSnippetType() snippetType}
* .build();
*
* @return A new GetUploadUrlExternalParams builder
*/
public static GetUploadUrlExternalParams.Builder builder() {
return new GetUploadUrlExternalParams.Builder();
}
/**
* Builds instances of type {@link GetUploadUrlExternalParams GetUploadUrlExternalParams}.
* 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 = "GetUploadUrlExternalParamsIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_FILENAME = 0x1L;
private static final long INIT_BIT_LENGTH = 0x2L;
private long initBits = 0x3L;
private @Nullable String filename;
private @Nullable Long length;
private @Nullable String altText;
private @Nullable String snippetType;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code GetUploadUrlExternalParamsIF} instance.
* Regular attribute values will be replaced with those from the given instance.
* Absent optional values will not replace present values.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(GetUploadUrlExternalParamsIF instance) {
Objects.requireNonNull(instance, "instance");
this.setFilename(instance.getFilename());
this.setLength(instance.getLength());
Optional altTextOptional = instance.getAltText();
if (altTextOptional.isPresent()) {
setAltText(altTextOptional);
}
Optional snippetTypeOptional = instance.getSnippetType();
if (snippetTypeOptional.isPresent()) {
setSnippetType(snippetTypeOptional);
}
return this;
}
/**
* Initializes the value for the {@link GetUploadUrlExternalParamsIF#getFilename() filename} attribute.
* @param filename The value for filename
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setFilename(String filename) {
this.filename = Objects.requireNonNull(filename, "filename");
initBits &= ~INIT_BIT_FILENAME;
return this;
}
/**
* Initializes the value for the {@link GetUploadUrlExternalParamsIF#getLength() length} attribute.
* @param length The value for length
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setLength(Long length) {
this.length = Objects.requireNonNull(length, "length");
initBits &= ~INIT_BIT_LENGTH;
return this;
}
/**
* Initializes the optional value {@link GetUploadUrlExternalParamsIF#getAltText() altText} to altText.
* @param altText The value for altText, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setAltText(@Nullable String altText) {
this.altText = altText;
return this;
}
/**
* Initializes the optional value {@link GetUploadUrlExternalParamsIF#getAltText() altText} to altText.
* @param altText The value for altText
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setAltText(Optional altText) {
this.altText = altText.orElse(null);
return this;
}
/**
* Initializes the optional value {@link GetUploadUrlExternalParamsIF#getSnippetType() snippetType} to snippetType.
* @param snippetType The value for snippetType, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setSnippetType(@Nullable String snippetType) {
this.snippetType = snippetType;
return this;
}
/**
* Initializes the optional value {@link GetUploadUrlExternalParamsIF#getSnippetType() snippetType} to snippetType.
* @param snippetType The value for snippetType
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setSnippetType(Optional snippetType) {
this.snippetType = snippetType.orElse(null);
return this;
}
/**
* Builds a new {@link GetUploadUrlExternalParams GetUploadUrlExternalParams}.
* @return An immutable instance of GetUploadUrlExternalParams
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public GetUploadUrlExternalParams build() {
checkRequiredAttributes();
return new GetUploadUrlExternalParams(filename, length, altText, snippetType);
}
private boolean filenameIsSet() {
return (initBits & INIT_BIT_FILENAME) == 0;
}
private boolean lengthIsSet() {
return (initBits & INIT_BIT_LENGTH) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!filenameIsSet()) attributes.add("filename");
if (!lengthIsSet()) attributes.add("length");
return "Cannot build GetUploadUrlExternalParams, some of required attributes are not set " + attributes;
}
}
}