
com.hubspot.slack.client.models.response.dnd.DndSnoozeResponse Maven / Gradle / Ivy
package com.hubspot.slack.client.models.response.dnd;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.models.json.InstantDeserializer;
import com.hubspot.slack.client.models.json.InstantSerializer;
import com.hubspot.slack.client.models.response.*;
import com.hubspot.slack.client.models.response.SlackResponse;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.time.Instant;
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 DndSnoozeResponseIF}.
*
* Use the builder to create immutable instances:
* {@code DndSnoozeResponse.builder()}.
*/
@Generated(from = "DndSnoozeResponseIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class DndSnoozeResponse
implements DndSnoozeResponseIF {
private final boolean ok;
private final @Nullable ResponseMetadata responseMetadata;
private final boolean snoozeEnabled;
private final @Nullable Instant snoozeEnd;
private final @Nullable Integer snoozeRemaining;
private DndSnoozeResponse(
boolean ok,
@Nullable ResponseMetadata responseMetadata,
boolean snoozeEnabled,
@Nullable Instant snoozeEnd,
@Nullable Integer snoozeRemaining) {
this.ok = ok;
this.responseMetadata = responseMetadata;
this.snoozeEnabled = snoozeEnabled;
this.snoozeEnd = snoozeEnd;
this.snoozeRemaining = snoozeRemaining;
}
/**
* @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 snoozeEnabled} attribute
*/
@JsonProperty
@Override
public boolean isSnoozeEnabled() {
return snoozeEnabled;
}
/**
* @return The value of the {@code snoozeEnd} attribute
*/
@JsonProperty("snooze_endtime")
@JsonSerialize(contentUsing = InstantSerializer.class)
@JsonDeserialize(contentUsing = InstantDeserializer.class)
@Override
public Optional getSnoozeEnd() {
return Optional.ofNullable(snoozeEnd);
}
/**
* @return The value of the {@code snoozeRemaining} attribute
*/
@JsonProperty
@Override
public Optional getSnoozeRemaining() {
return Optional.ofNullable(snoozeRemaining);
}
/**
* Copy the current immutable object by setting a value for the {@link DndSnoozeResponseIF#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 DndSnoozeResponse withOk(boolean value) {
if (this.ok == value) return this;
return new DndSnoozeResponse(value, this.responseMetadata, this.snoozeEnabled, this.snoozeEnd, this.snoozeRemaining);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link DndSnoozeResponseIF#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 DndSnoozeResponse withResponseMetadata(@Nullable ResponseMetadata value) {
@Nullable ResponseMetadata newValue = value;
if (this.responseMetadata == newValue) return this;
return new DndSnoozeResponse(this.ok, newValue, this.snoozeEnabled, this.snoozeEnd, this.snoozeRemaining);
}
/**
* Copy the current immutable object by setting an optional value for the {@link DndSnoozeResponseIF#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 DndSnoozeResponse withResponseMetadata(Optional extends ResponseMetadata> optional) {
@Nullable ResponseMetadata value = optional.orElse(null);
if (this.responseMetadata == value) return this;
return new DndSnoozeResponse(this.ok, value, this.snoozeEnabled, this.snoozeEnd, this.snoozeRemaining);
}
/**
* Copy the current immutable object by setting a value for the {@link DndSnoozeResponseIF#isSnoozeEnabled() snoozeEnabled} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for snoozeEnabled
* @return A modified copy of the {@code this} object
*/
public final DndSnoozeResponse withSnoozeEnabled(boolean value) {
if (this.snoozeEnabled == value) return this;
return new DndSnoozeResponse(this.ok, this.responseMetadata, value, this.snoozeEnd, this.snoozeRemaining);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link DndSnoozeResponseIF#getSnoozeEnd() snoozeEnd} attribute.
* @param value The value for snoozeEnd, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final DndSnoozeResponse withSnoozeEnd(@Nullable Instant value) {
@Nullable Instant newValue = value;
if (this.snoozeEnd == newValue) return this;
return new DndSnoozeResponse(this.ok, this.responseMetadata, this.snoozeEnabled, newValue, this.snoozeRemaining);
}
/**
* Copy the current immutable object by setting an optional value for the {@link DndSnoozeResponseIF#getSnoozeEnd() snoozeEnd} 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 snoozeEnd
* @return A modified copy of {@code this} object
*/
@SuppressWarnings("unchecked") // safe covariant cast
public final DndSnoozeResponse withSnoozeEnd(Optional extends Instant> optional) {
@Nullable Instant value = optional.orElse(null);
if (this.snoozeEnd == value) return this;
return new DndSnoozeResponse(this.ok, this.responseMetadata, this.snoozeEnabled, value, this.snoozeRemaining);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link DndSnoozeResponseIF#getSnoozeRemaining() snoozeRemaining} attribute.
* @param value The value for snoozeRemaining, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final DndSnoozeResponse withSnoozeRemaining(@Nullable Integer value) {
@Nullable Integer newValue = value;
if (Objects.equals(this.snoozeRemaining, newValue)) return this;
return new DndSnoozeResponse(this.ok, this.responseMetadata, this.snoozeEnabled, this.snoozeEnd, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link DndSnoozeResponseIF#getSnoozeRemaining() snoozeRemaining} 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 snoozeRemaining
* @return A modified copy of {@code this} object
*/
public final DndSnoozeResponse withSnoozeRemaining(Optional optional) {
@Nullable Integer value = optional.orElse(null);
if (Objects.equals(this.snoozeRemaining, value)) return this;
return new DndSnoozeResponse(this.ok, this.responseMetadata, this.snoozeEnabled, this.snoozeEnd, value);
}
/**
* This instance is equal to all instances of {@code DndSnoozeResponse} 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 DndSnoozeResponse
&& equalTo(0, (DndSnoozeResponse) another);
}
private boolean equalTo(int synthetic, DndSnoozeResponse another) {
return ok == another.ok
&& Objects.equals(responseMetadata, another.responseMetadata)
&& snoozeEnabled == another.snoozeEnabled
&& Objects.equals(snoozeEnd, another.snoozeEnd)
&& Objects.equals(snoozeRemaining, another.snoozeRemaining);
}
/**
* Computes a hash code from attributes: {@code ok}, {@code responseMetadata}, {@code snoozeEnabled}, {@code snoozeEnd}, {@code snoozeRemaining}.
* @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) + Boolean.hashCode(snoozeEnabled);
h += (h << 5) + Objects.hashCode(snoozeEnd);
h += (h << 5) + Objects.hashCode(snoozeRemaining);
return h;
}
/**
* Prints the immutable value {@code DndSnoozeResponse} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("DndSnoozeResponse{");
builder.append("ok=").append(ok);
if (responseMetadata != null) {
builder.append(", ");
builder.append("responseMetadata=").append(responseMetadata);
}
builder.append(", ");
builder.append("snoozeEnabled=").append(snoozeEnabled);
if (snoozeEnd != null) {
builder.append(", ");
builder.append("snoozeEnd=").append(snoozeEnd);
}
if (snoozeRemaining != null) {
builder.append(", ");
builder.append("snoozeRemaining=").append(snoozeRemaining);
}
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 = "DndSnoozeResponseIF", generator = "Immutables")
@Deprecated
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements DndSnoozeResponseIF {
boolean ok;
boolean okIsSet;
@Nullable Optional responseMetadata = Optional.empty();
boolean snoozeEnabled;
boolean snoozeEnabledIsSet;
@Nullable Optional snoozeEnd = Optional.empty();
@Nullable Optional snoozeRemaining = Optional.empty();
@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 setSnoozeEnabled(boolean snoozeEnabled) {
this.snoozeEnabled = snoozeEnabled;
this.snoozeEnabledIsSet = true;
}
@JsonProperty("snooze_endtime")
@JsonSerialize(contentUsing = InstantSerializer.class)
@JsonDeserialize(contentUsing = InstantDeserializer.class)
public void setSnoozeEnd(Optional snoozeEnd) {
this.snoozeEnd = snoozeEnd;
}
@JsonProperty
public void setSnoozeRemaining(Optional snoozeRemaining) {
this.snoozeRemaining = snoozeRemaining;
}
@Override
public boolean isOk() { throw new UnsupportedOperationException(); }
@Override
public Optional getResponseMetadata() { throw new UnsupportedOperationException(); }
@Override
public boolean isSnoozeEnabled() { throw new UnsupportedOperationException(); }
@Override
public Optional getSnoozeEnd() { throw new UnsupportedOperationException(); }
@Override
public Optional getSnoozeRemaining() { 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 DndSnoozeResponse fromJson(Json json) {
DndSnoozeResponse.Builder builder = DndSnoozeResponse.builder();
if (json.okIsSet) {
builder.setOk(json.ok);
}
if (json.responseMetadata != null) {
builder.setResponseMetadata(json.responseMetadata);
}
if (json.snoozeEnabledIsSet) {
builder.setSnoozeEnabled(json.snoozeEnabled);
}
if (json.snoozeEnd != null) {
builder.setSnoozeEnd(json.snoozeEnd);
}
if (json.snoozeRemaining != null) {
builder.setSnoozeRemaining(json.snoozeRemaining);
}
return builder.build();
}
/**
* Creates an immutable copy of a {@link DndSnoozeResponseIF} 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 DndSnoozeResponse instance
*/
public static DndSnoozeResponse copyOf(DndSnoozeResponseIF instance) {
if (instance instanceof DndSnoozeResponse) {
return (DndSnoozeResponse) instance;
}
return DndSnoozeResponse.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link DndSnoozeResponse DndSnoozeResponse}.
*
* DndSnoozeResponse.builder()
* .setOk(boolean) // required {@link DndSnoozeResponseIF#isOk() ok}
* .setResponseMetadata(ResponseMetadata) // optional {@link DndSnoozeResponseIF#getResponseMetadata() responseMetadata}
* .setSnoozeEnabled(boolean) // required {@link DndSnoozeResponseIF#isSnoozeEnabled() snoozeEnabled}
* .setSnoozeEnd(java.time.Instant) // optional {@link DndSnoozeResponseIF#getSnoozeEnd() snoozeEnd}
* .setSnoozeRemaining(Integer) // optional {@link DndSnoozeResponseIF#getSnoozeRemaining() snoozeRemaining}
* .build();
*
* @return A new DndSnoozeResponse builder
*/
public static DndSnoozeResponse.Builder builder() {
return new DndSnoozeResponse.Builder();
}
/**
* Builds instances of type {@link DndSnoozeResponse DndSnoozeResponse}.
* 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 = "DndSnoozeResponseIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_OK = 0x1L;
private static final long INIT_BIT_SNOOZE_ENABLED = 0x2L;
private long initBits = 0x3L;
private boolean ok;
private @Nullable ResponseMetadata responseMetadata;
private boolean snoozeEnabled;
private @Nullable Instant snoozeEnd;
private @Nullable Integer snoozeRemaining;
private Builder() {
}
/**
* 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;
}
/**
* Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.response.dnd.DndSnoozeResponseIF} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(DndSnoozeResponseIF 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 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;
}
}
if (object instanceof DndSnoozeResponseIF) {
DndSnoozeResponseIF instance = (DndSnoozeResponseIF) object;
if ((bits & 0x1L) == 0) {
Optional responseMetadataOptional = instance.getResponseMetadata();
if (responseMetadataOptional.isPresent()) {
setResponseMetadata(responseMetadataOptional);
}
bits |= 0x1L;
}
if ((bits & 0x2L) == 0) {
this.setOk(instance.isOk());
bits |= 0x2L;
}
Optional snoozeRemainingOptional = instance.getSnoozeRemaining();
if (snoozeRemainingOptional.isPresent()) {
setSnoozeRemaining(snoozeRemainingOptional);
}
this.setSnoozeEnabled(instance.isSnoozeEnabled());
Optional snoozeEndOptional = instance.getSnoozeEnd();
if (snoozeEndOptional.isPresent()) {
setSnoozeEnd(snoozeEndOptional);
}
}
}
/**
* Initializes the value for the {@link DndSnoozeResponseIF#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 DndSnoozeResponseIF#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 DndSnoozeResponseIF#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 extends ResponseMetadata> responseMetadata) {
this.responseMetadata = responseMetadata.orElse(null);
return this;
}
/**
* Initializes the value for the {@link DndSnoozeResponseIF#isSnoozeEnabled() snoozeEnabled} attribute.
* @param snoozeEnabled The value for snoozeEnabled
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setSnoozeEnabled(boolean snoozeEnabled) {
this.snoozeEnabled = snoozeEnabled;
initBits &= ~INIT_BIT_SNOOZE_ENABLED;
return this;
}
/**
* Initializes the optional value {@link DndSnoozeResponseIF#getSnoozeEnd() snoozeEnd} to snoozeEnd.
* @param snoozeEnd The value for snoozeEnd, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setSnoozeEnd(@Nullable Instant snoozeEnd) {
this.snoozeEnd = snoozeEnd;
return this;
}
/**
* Initializes the optional value {@link DndSnoozeResponseIF#getSnoozeEnd() snoozeEnd} to snoozeEnd.
* @param snoozeEnd The value for snoozeEnd
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setSnoozeEnd(Optional extends Instant> snoozeEnd) {
this.snoozeEnd = snoozeEnd.orElse(null);
return this;
}
/**
* Initializes the optional value {@link DndSnoozeResponseIF#getSnoozeRemaining() snoozeRemaining} to snoozeRemaining.
* @param snoozeRemaining The value for snoozeRemaining, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setSnoozeRemaining(@Nullable Integer snoozeRemaining) {
this.snoozeRemaining = snoozeRemaining;
return this;
}
/**
* Initializes the optional value {@link DndSnoozeResponseIF#getSnoozeRemaining() snoozeRemaining} to snoozeRemaining.
* @param snoozeRemaining The value for snoozeRemaining
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setSnoozeRemaining(Optional snoozeRemaining) {
this.snoozeRemaining = snoozeRemaining.orElse(null);
return this;
}
/**
* Builds a new {@link DndSnoozeResponse DndSnoozeResponse}.
* @return An immutable instance of DndSnoozeResponse
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public DndSnoozeResponse build() {
checkRequiredAttributes();
return new DndSnoozeResponse(ok, responseMetadata, snoozeEnabled, snoozeEnd, snoozeRemaining);
}
private boolean okIsSet() {
return (initBits & INIT_BIT_OK) == 0;
}
private boolean snoozeEnabledIsSet() {
return (initBits & INIT_BIT_SNOOZE_ENABLED) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!okIsSet()) attributes.add("ok");
if (!snoozeEnabledIsSet()) attributes.add("snoozeEnabled");
return "Cannot build DndSnoozeResponse, some of required attributes are not set " + attributes;
}
}
}