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