
com.hubspot.slack.client.models.response.files.FilesInfoResponse Maven / Gradle / Ivy
package com.hubspot.slack.client.models.response.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 com.hubspot.slack.client.models.files.SlackFile;
import com.hubspot.slack.client.models.response.*;
import com.hubspot.slack.client.models.response.SlackResponse;
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 FilesInfoResponseIF}.
*
* Use the builder to create immutable instances:
* {@code FilesInfoResponse.builder()}.
*/
@Generated(from = "FilesInfoResponseIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class FilesInfoResponse
implements FilesInfoResponseIF {
private final boolean ok;
private final @Nullable ResponseMetadata responseMetadata;
private final SlackFile file;
private FilesInfoResponse(
boolean ok,
@Nullable ResponseMetadata responseMetadata,
SlackFile file) {
this.ok = ok;
this.responseMetadata = responseMetadata;
this.file = file;
}
/**
* @return The value of the {@code ok} attribute
*/
@JsonProperty
@Override
public boolean isOk() {
return ok;
}
/**
* @return The value of the {@code responseMetadata} attribute
*/
@JsonProperty("response_metadata")
@Override
public Optional getResponseMetadata() {
return Optional.ofNullable(responseMetadata);
}
/**
* @return The value of the {@code file} attribute
*/
@JsonProperty
@Override
public SlackFile getFile() {
return file;
}
/**
* Copy the current immutable object by setting a value for the {@link FilesInfoResponseIF#isOk() ok} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for ok
* @return A modified copy of the {@code this} object
*/
public final FilesInfoResponse withOk(boolean value) {
if (this.ok == value) return this;
return new FilesInfoResponse(value, this.responseMetadata, this.file);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link FilesInfoResponseIF#getResponseMetadata() responseMetadata} attribute.
* @param value The value for responseMetadata, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final FilesInfoResponse withResponseMetadata(@Nullable ResponseMetadata value) {
@Nullable ResponseMetadata newValue = value;
if (this.responseMetadata == newValue) return this;
return new FilesInfoResponse(this.ok, newValue, this.file);
}
/**
* Copy the current immutable object by setting an optional value for the {@link FilesInfoResponseIF#getResponseMetadata() responseMetadata} 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 responseMetadata
* @return A modified copy of {@code this} object
*/
@SuppressWarnings("unchecked") // safe covariant cast
public final FilesInfoResponse withResponseMetadata(Optional optional) {
@Nullable ResponseMetadata value = optional.orElse(null);
if (this.responseMetadata == value) return this;
return new FilesInfoResponse(this.ok, value, this.file);
}
/**
* Copy the current immutable object by setting a value for the {@link FilesInfoResponseIF#getFile() file} attribute.
* A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for file
* @return A modified copy of the {@code this} object
*/
public final FilesInfoResponse withFile(SlackFile value) {
if (this.file == value) return this;
SlackFile newValue = Objects.requireNonNull(value, "file");
return new FilesInfoResponse(this.ok, this.responseMetadata, newValue);
}
/**
* This instance is equal to all instances of {@code FilesInfoResponse} 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 FilesInfoResponse
&& equalTo(0, (FilesInfoResponse) another);
}
private boolean equalTo(int synthetic, FilesInfoResponse another) {
return ok == another.ok
&& Objects.equals(responseMetadata, another.responseMetadata)
&& file.equals(another.file);
}
/**
* Computes a hash code from attributes: {@code ok}, {@code responseMetadata}, {@code file}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Boolean.hashCode(ok);
h += (h << 5) + Objects.hashCode(responseMetadata);
h += (h << 5) + file.hashCode();
return h;
}
/**
* Prints the immutable value {@code FilesInfoResponse} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("FilesInfoResponse{");
builder.append("ok=").append(ok);
if (responseMetadata != null) {
builder.append(", ");
builder.append("responseMetadata=").append(responseMetadata);
}
builder.append(", ");
builder.append("file=").append(file);
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 = "FilesInfoResponseIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements FilesInfoResponseIF {
boolean ok;
boolean okIsSet;
@Nullable Optional responseMetadata = Optional.empty();
@Nullable SlackFile file;
@JsonProperty
public void setOk(boolean ok) {
this.ok = ok;
this.okIsSet = true;
}
@JsonProperty("response_metadata")
public void setResponseMetadata(Optional responseMetadata) {
this.responseMetadata = responseMetadata;
}
@JsonProperty
public void setFile(SlackFile file) {
this.file = file;
}
@Override
public boolean isOk() { throw new UnsupportedOperationException(); }
@Override
public Optional getResponseMetadata() { throw new UnsupportedOperationException(); }
@Override
public SlackFile getFile() { 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 FilesInfoResponse fromJson(Json json) {
FilesInfoResponse.Builder builder = FilesInfoResponse.builder();
if (json.okIsSet) {
builder.setOk(json.ok);
}
if (json.responseMetadata != null) {
builder.setResponseMetadata(json.responseMetadata);
}
if (json.file != null) {
builder.setFile(json.file);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link FilesInfoResponseIF} 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 FilesInfoResponse instance
*/
public static FilesInfoResponse copyOf(FilesInfoResponseIF instance) {
if (instance instanceof FilesInfoResponse) {
return (FilesInfoResponse) instance;
}
return FilesInfoResponse.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link FilesInfoResponse FilesInfoResponse}.
*
* FilesInfoResponse.builder()
* .setOk(boolean) // required {@link FilesInfoResponseIF#isOk() ok}
* .setResponseMetadata(ResponseMetadata) // optional {@link FilesInfoResponseIF#getResponseMetadata() responseMetadata}
* .setFile(com.hubspot.slack.client.models.files.SlackFile) // required {@link FilesInfoResponseIF#getFile() file}
* .build();
*
* @return A new FilesInfoResponse builder
*/
public static FilesInfoResponse.Builder builder() {
return new FilesInfoResponse.Builder();
}
/**
* Builds instances of type {@link FilesInfoResponse FilesInfoResponse}.
* 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 = "FilesInfoResponseIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_OK = 0x1L;
private static final long INIT_BIT_FILE = 0x2L;
private long initBits = 0x3L;
private boolean ok;
private @Nullable ResponseMetadata responseMetadata;
private @Nullable SlackFile file;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.response.files.FilesInfoResponseIF} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(FilesInfoResponseIF 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.models.response.SlackResponse} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(SlackResponse 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 FilesInfoResponseIF) {
FilesInfoResponseIF instance = (FilesInfoResponseIF) object;
if ((bits & 0x2L) == 0) {
this.setOk(instance.isOk());
bits |= 0x2L;
}
this.setFile(instance.getFile());
if ((bits & 0x1L) == 0) {
Optional responseMetadataOptional = instance.getResponseMetadata();
if (responseMetadataOptional.isPresent()) {
setResponseMetadata(responseMetadataOptional);
}
bits |= 0x1L;
}
}
if (object instanceof SlackResponse) {
SlackResponse instance = (SlackResponse) object;
if ((bits & 0x2L) == 0) {
this.setOk(instance.isOk());
bits |= 0x2L;
}
if ((bits & 0x1L) == 0) {
Optional responseMetadataOptional = instance.getResponseMetadata();
if (responseMetadataOptional.isPresent()) {
setResponseMetadata(responseMetadataOptional);
}
bits |= 0x1L;
}
}
}
/**
* Initializes the value for the {@link FilesInfoResponseIF#isOk() ok} attribute.
* @param ok The value for ok
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setOk(boolean ok) {
this.ok = ok;
initBits &= ~INIT_BIT_OK;
return this;
}
/**
* Initializes the optional value {@link FilesInfoResponseIF#getResponseMetadata() responseMetadata} to responseMetadata.
* @param responseMetadata The value for responseMetadata, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setResponseMetadata(@Nullable ResponseMetadata responseMetadata) {
this.responseMetadata = responseMetadata;
return this;
}
/**
* Initializes the optional value {@link FilesInfoResponseIF#getResponseMetadata() responseMetadata} to responseMetadata.
* @param responseMetadata The value for responseMetadata
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setResponseMetadata(Optional responseMetadata) {
this.responseMetadata = responseMetadata.orElse(null);
return this;
}
/**
* Initializes the value for the {@link FilesInfoResponseIF#getFile() file} attribute.
* @param file The value for file
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setFile(SlackFile file) {
this.file = Objects.requireNonNull(file, "file");
initBits &= ~INIT_BIT_FILE;
return this;
}
/**
* Builds a new {@link FilesInfoResponse FilesInfoResponse}.
* @return An immutable instance of FilesInfoResponse
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public FilesInfoResponse build() {
checkRequiredAttributes();
return new FilesInfoResponse(ok, responseMetadata, file);
}
private boolean okIsSet() {
return (initBits & INIT_BIT_OK) == 0;
}
private boolean fileIsSet() {
return (initBits & INIT_BIT_FILE) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!okIsSet()) attributes.add("ok");
if (!fileIsSet()) attributes.add("file");
return "Cannot build FilesInfoResponse, some of required attributes are not set " + attributes;
}
}
}