
com.hubspot.slack.client.models.blocks.SlackFileObject Maven / Gradle / Ivy
package com.hubspot.slack.client.models.blocks;
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.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 SlackFileObjectIF}.
*
* Use the builder to create immutable instances:
* {@code SlackFileObject.builder()}.
*/
@Generated(from = "SlackFileObjectIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class SlackFileObject implements SlackFileObjectIF {
private final @Nullable String url;
private final @Nullable String id;
private SlackFileObject(@Nullable String url, @Nullable String id) {
this.url = url;
this.id = id;
}
/**
* @return The value of the {@code url} attribute
*/
@JsonProperty
@Override
public Optional getUrl() {
return Optional.ofNullable(url);
}
/**
* @return The value of the {@code id} attribute
*/
@JsonProperty
@Override
public Optional getId() {
return Optional.ofNullable(id);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link SlackFileObjectIF#getUrl() url} attribute.
* @param value The value for url, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final SlackFileObject withUrl(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.url, newValue)) return this;
return new SlackFileObject(newValue, this.id);
}
/**
* Copy the current immutable object by setting an optional value for the {@link SlackFileObjectIF#getUrl() url} 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 url
* @return A modified copy of {@code this} object
*/
public final SlackFileObject withUrl(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.url, value)) return this;
return new SlackFileObject(value, this.id);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link SlackFileObjectIF#getId() id} attribute.
* @param value The value for id, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final SlackFileObject withId(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.id, newValue)) return this;
return new SlackFileObject(this.url, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link SlackFileObjectIF#getId() id} 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 id
* @return A modified copy of {@code this} object
*/
public final SlackFileObject withId(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.id, value)) return this;
return new SlackFileObject(this.url, value);
}
/**
* This instance is equal to all instances of {@code SlackFileObject} 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 SlackFileObject
&& equalTo(0, (SlackFileObject) another);
}
private boolean equalTo(int synthetic, SlackFileObject another) {
return Objects.equals(url, another.url)
&& Objects.equals(id, another.id);
}
/**
* Computes a hash code from attributes: {@code url}, {@code id}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + Objects.hashCode(url);
h += (h << 5) + Objects.hashCode(id);
return h;
}
/**
* Prints the immutable value {@code SlackFileObject} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("SlackFileObject{");
if (url != null) {
builder.append("url=").append(url);
}
if (id != null) {
if (builder.length() > 16) builder.append(", ");
builder.append("id=").append(id);
}
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 = "SlackFileObjectIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements SlackFileObjectIF {
@Nullable Optional url = Optional.empty();
@Nullable Optional id = Optional.empty();
@JsonProperty
public void setUrl(Optional url) {
this.url = url;
}
@JsonProperty
public void setId(Optional id) {
this.id = id;
}
@Override
public Optional getUrl() { throw new UnsupportedOperationException(); }
@Override
public Optional getId() { 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 SlackFileObject fromJson(Json json) {
SlackFileObject.Builder builder = SlackFileObject.builder();
if (json.url != null) {
builder.setUrl(json.url);
}
if (json.id != null) {
builder.setId(json.id);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link SlackFileObjectIF} 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 SlackFileObject instance
*/
public static SlackFileObject copyOf(SlackFileObjectIF instance) {
if (instance instanceof SlackFileObject) {
return (SlackFileObject) instance;
}
return SlackFileObject.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link SlackFileObject SlackFileObject}.
*
* SlackFileObject.builder()
* .setUrl(String) // optional {@link SlackFileObjectIF#getUrl() url}
* .setId(String) // optional {@link SlackFileObjectIF#getId() id}
* .build();
*
* @return A new SlackFileObject builder
*/
public static SlackFileObject.Builder builder() {
return new SlackFileObject.Builder();
}
/**
* Builds instances of type {@link SlackFileObject SlackFileObject}.
* 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 = "SlackFileObjectIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private @Nullable String url;
private @Nullable String id;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code SlackFileObjectIF} 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(SlackFileObjectIF instance) {
Objects.requireNonNull(instance, "instance");
Optional urlOptional = instance.getUrl();
if (urlOptional.isPresent()) {
setUrl(urlOptional);
}
Optional idOptional = instance.getId();
if (idOptional.isPresent()) {
setId(idOptional);
}
return this;
}
/**
* Initializes the optional value {@link SlackFileObjectIF#getUrl() url} to url.
* @param url The value for url, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setUrl(@Nullable String url) {
this.url = url;
return this;
}
/**
* Initializes the optional value {@link SlackFileObjectIF#getUrl() url} to url.
* @param url The value for url
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setUrl(Optional url) {
this.url = url.orElse(null);
return this;
}
/**
* Initializes the optional value {@link SlackFileObjectIF#getId() id} to id.
* @param id The value for id, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setId(@Nullable String id) {
this.id = id;
return this;
}
/**
* Initializes the optional value {@link SlackFileObjectIF#getId() id} to id.
* @param id The value for id
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setId(Optional id) {
this.id = id.orElse(null);
return this;
}
/**
* Builds a new {@link SlackFileObject SlackFileObject}.
* @return An immutable instance of SlackFileObject
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public SlackFileObject build() {
return new SlackFileObject(url, id);
}
}
}