
com.hubspot.slack.client.models.blocks.elements.DateTimePicker Maven / Gradle / Ivy
package com.hubspot.slack.client.models.blocks.elements;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.hubspot.immutables.validation.InvalidImmutableStateException;
import com.hubspot.slack.client.models.blocks.objects.ConfirmationDialog;
import com.hubspot.slack.client.models.blocks.objects.Text;
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 DateTimePickerIF}.
*
* Use the builder to create immutable instances:
* {@code DateTimePicker.builder()}.
* Use the static factory method to create immutable instances:
* {@code DateTimePicker.of()}.
*/
@Generated(from = "DateTimePickerIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class DateTimePicker implements DateTimePickerIF {
private transient final String type;
private final String actionId;
private final @Nullable Text placeholder;
private final @Nullable Integer initialDateTime;
private final @Nullable ConfirmationDialog confirmationDialog;
private final @Nullable Boolean focusOnLoad;
private DateTimePicker(String actionId) {
this.actionId = Objects.requireNonNull(actionId, "actionId");
this.placeholder = null;
this.initialDateTime = null;
this.confirmationDialog = null;
this.focusOnLoad = null;
this.type = Objects.requireNonNull(DateTimePickerIF.super.getType(), "type");
}
private DateTimePicker(
String actionId,
@Nullable Text placeholder,
@Nullable Integer initialDateTime,
@Nullable ConfirmationDialog confirmationDialog,
@Nullable Boolean focusOnLoad) {
this.actionId = actionId;
this.placeholder = placeholder;
this.initialDateTime = initialDateTime;
this.confirmationDialog = confirmationDialog;
this.focusOnLoad = focusOnLoad;
this.type = Objects.requireNonNull(DateTimePickerIF.super.getType(), "type");
}
/**
* @return The computed-at-construction value of the {@code type} attribute
*/
@JsonProperty
@Override
public String getType() {
return type;
}
/**
* @return The value of the {@code actionId} attribute
*/
@JsonProperty
@Override
public String getActionId() {
return actionId;
}
/**
* @return The value of the {@code placeholder} attribute
*/
@JsonProperty
@Override
public Optional getPlaceholder() {
return Optional.ofNullable(placeholder);
}
/**
* @return The value of the {@code initialDateTime} attribute
*/
@JsonProperty
@Override
public Optional getInitialDateTime() {
return Optional.ofNullable(initialDateTime);
}
/**
* @return The value of the {@code confirmationDialog} attribute
*/
@JsonProperty("confirm")
@Override
public Optional getConfirmationDialog() {
return Optional.ofNullable(confirmationDialog);
}
/**
* @return The value of the {@code focusOnLoad} attribute
*/
@JsonSetter("focus_on_load")
@JsonProperty("is_focus_on_load")
@Override
public Optional isFocusOnLoad() {
return Optional.ofNullable(focusOnLoad);
}
/**
* Copy the current immutable object by setting a value for the {@link DateTimePickerIF#getActionId() actionId} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for actionId
* @return A modified copy of the {@code this} object
*/
public final DateTimePicker withActionId(String value) {
String newValue = Objects.requireNonNull(value, "actionId");
if (this.actionId.equals(newValue)) return this;
return new DateTimePicker(newValue, this.placeholder, this.initialDateTime, this.confirmationDialog, this.focusOnLoad);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link DateTimePickerIF#getPlaceholder() placeholder} attribute.
* @param value The value for placeholder, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final DateTimePicker withPlaceholder(@Nullable Text value) {
@Nullable Text newValue = value;
if (this.placeholder == newValue) return this;
return new DateTimePicker(this.actionId, newValue, this.initialDateTime, this.confirmationDialog, this.focusOnLoad);
}
/**
* Copy the current immutable object by setting an optional value for the {@link DateTimePickerIF#getPlaceholder() placeholder} 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 placeholder
* @return A modified copy of {@code this} object
*/
@SuppressWarnings("unchecked") // safe covariant cast
public final DateTimePicker withPlaceholder(Optional extends Text> optional) {
@Nullable Text value = optional.orElse(null);
if (this.placeholder == value) return this;
return new DateTimePicker(this.actionId, value, this.initialDateTime, this.confirmationDialog, this.focusOnLoad);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link DateTimePickerIF#getInitialDateTime() initialDateTime} attribute.
* @param value The value for initialDateTime, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final DateTimePicker withInitialDateTime(@Nullable Integer value) {
@Nullable Integer newValue = value;
if (Objects.equals(this.initialDateTime, newValue)) return this;
return new DateTimePicker(this.actionId, this.placeholder, newValue, this.confirmationDialog, this.focusOnLoad);
}
/**
* Copy the current immutable object by setting an optional value for the {@link DateTimePickerIF#getInitialDateTime() initialDateTime} 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 initialDateTime
* @return A modified copy of {@code this} object
*/
public final DateTimePicker withInitialDateTime(Optional optional) {
@Nullable Integer value = optional.orElse(null);
if (Objects.equals(this.initialDateTime, value)) return this;
return new DateTimePicker(this.actionId, this.placeholder, value, this.confirmationDialog, this.focusOnLoad);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link DateTimePickerIF#getConfirmationDialog() confirmationDialog} attribute.
* @param value The value for confirmationDialog, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final DateTimePicker withConfirmationDialog(@Nullable ConfirmationDialog value) {
@Nullable ConfirmationDialog newValue = value;
if (this.confirmationDialog == newValue) return this;
return new DateTimePicker(this.actionId, this.placeholder, this.initialDateTime, newValue, this.focusOnLoad);
}
/**
* Copy the current immutable object by setting an optional value for the {@link DateTimePickerIF#getConfirmationDialog() confirmationDialog} 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 confirmationDialog
* @return A modified copy of {@code this} object
*/
@SuppressWarnings("unchecked") // safe covariant cast
public final DateTimePicker withConfirmationDialog(Optional extends ConfirmationDialog> optional) {
@Nullable ConfirmationDialog value = optional.orElse(null);
if (this.confirmationDialog == value) return this;
return new DateTimePicker(this.actionId, this.placeholder, this.initialDateTime, value, this.focusOnLoad);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link DateTimePickerIF#isFocusOnLoad() focusOnLoad} attribute.
* @param value The value for focusOnLoad, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final DateTimePicker withFocusOnLoad(@Nullable Boolean value) {
@Nullable Boolean newValue = value;
if (Objects.equals(this.focusOnLoad, newValue)) return this;
return new DateTimePicker(this.actionId, this.placeholder, this.initialDateTime, this.confirmationDialog, newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link DateTimePickerIF#isFocusOnLoad() focusOnLoad} 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 focusOnLoad
* @return A modified copy of {@code this} object
*/
public final DateTimePicker withFocusOnLoad(Optional optional) {
@Nullable Boolean value = optional.orElse(null);
if (Objects.equals(this.focusOnLoad, value)) return this;
return new DateTimePicker(this.actionId, this.placeholder, this.initialDateTime, this.confirmationDialog, value);
}
/**
* This instance is equal to all instances of {@code DateTimePicker} 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 DateTimePicker
&& equalTo(0, (DateTimePicker) another);
}
private boolean equalTo(int synthetic, DateTimePicker another) {
return type.equals(another.type)
&& actionId.equals(another.actionId)
&& Objects.equals(placeholder, another.placeholder)
&& Objects.equals(initialDateTime, another.initialDateTime)
&& Objects.equals(confirmationDialog, another.confirmationDialog)
&& Objects.equals(focusOnLoad, another.focusOnLoad);
}
/**
* Computes a hash code from attributes: {@code type}, {@code actionId}, {@code placeholder}, {@code initialDateTime}, {@code confirmationDialog}, {@code focusOnLoad}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + type.hashCode();
h += (h << 5) + actionId.hashCode();
h += (h << 5) + Objects.hashCode(placeholder);
h += (h << 5) + Objects.hashCode(initialDateTime);
h += (h << 5) + Objects.hashCode(confirmationDialog);
h += (h << 5) + Objects.hashCode(focusOnLoad);
return h;
}
/**
* Prints the immutable value {@code DateTimePicker} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("DateTimePicker{");
builder.append("type=").append(type);
builder.append(", ");
builder.append("actionId=").append(actionId);
if (placeholder != null) {
builder.append(", ");
builder.append("placeholder=").append(placeholder);
}
if (initialDateTime != null) {
builder.append(", ");
builder.append("initialDateTime=").append(initialDateTime);
}
if (confirmationDialog != null) {
builder.append(", ");
builder.append("confirmationDialog=").append(confirmationDialog);
}
if (focusOnLoad != null) {
builder.append(", ");
builder.append("focusOnLoad=").append(focusOnLoad);
}
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 = "DateTimePickerIF", generator = "Immutables")
@Deprecated
@JsonTypeInfo(use=JsonTypeInfo.Id.NONE)
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements DateTimePickerIF {
@Nullable String actionId;
@Nullable Optional placeholder = Optional.empty();
@Nullable Optional initialDateTime = Optional.empty();
@Nullable Optional confirmationDialog = Optional.empty();
@Nullable Optional focusOnLoad = Optional.empty();
@JsonProperty
public void setActionId(String actionId) {
this.actionId = actionId;
}
@JsonProperty
public void setPlaceholder(Optional placeholder) {
this.placeholder = placeholder;
}
@JsonProperty
public void setInitialDateTime(Optional initialDateTime) {
this.initialDateTime = initialDateTime;
}
@JsonProperty("confirm")
public void setConfirmationDialog(Optional confirmationDialog) {
this.confirmationDialog = confirmationDialog;
}
@JsonSetter("focus_on_load")
@JsonProperty("is_focus_on_load")
public void setFocusOnLoad(Optional focusOnLoad) {
this.focusOnLoad = focusOnLoad;
}
@JsonIgnore
@Override
public String getType() { throw new UnsupportedOperationException(); }
@Override
public String getActionId() { throw new UnsupportedOperationException(); }
@Override
public Optional getPlaceholder() { throw new UnsupportedOperationException(); }
@Override
public Optional getInitialDateTime() { throw new UnsupportedOperationException(); }
@Override
public Optional getConfirmationDialog() { throw new UnsupportedOperationException(); }
@Override
public Optional isFocusOnLoad() { 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 DateTimePicker fromJson(Json json) {
DateTimePicker.Builder builder = DateTimePicker.builder();
if (json.actionId != null) {
builder.setActionId(json.actionId);
}
if (json.placeholder != null) {
builder.setPlaceholder(json.placeholder);
}
if (json.initialDateTime != null) {
builder.setInitialDateTime(json.initialDateTime);
}
if (json.confirmationDialog != null) {
builder.setConfirmationDialog(json.confirmationDialog);
}
if (json.focusOnLoad != null) {
builder.setFocusOnLoad(json.focusOnLoad);
}
return builder.build();
}
/**
* Construct a new immutable {@code DateTimePicker} instance.
* @param actionId The value for the {@code actionId} attribute
* @return An immutable DateTimePicker instance
*/
public static DateTimePicker of(String actionId) {
return new DateTimePicker(actionId);
}
/**
* Creates an immutable copy of a {@link DateTimePickerIF} 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 DateTimePicker instance
*/
public static DateTimePicker copyOf(DateTimePickerIF instance) {
if (instance instanceof DateTimePicker) {
return (DateTimePicker) instance;
}
return DateTimePicker.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link DateTimePicker DateTimePicker}.
*
* DateTimePicker.builder()
* .setActionId(String) // required {@link DateTimePickerIF#getActionId() actionId}
* .setPlaceholder(com.hubspot.slack.client.models.blocks.objects.Text) // optional {@link DateTimePickerIF#getPlaceholder() placeholder}
* .setInitialDateTime(Integer) // optional {@link DateTimePickerIF#getInitialDateTime() initialDateTime}
* .setConfirmationDialog(com.hubspot.slack.client.models.blocks.objects.ConfirmationDialog) // optional {@link DateTimePickerIF#getConfirmationDialog() confirmationDialog}
* .setFocusOnLoad(Boolean) // optional {@link DateTimePickerIF#isFocusOnLoad() focusOnLoad}
* .build();
*
* @return A new DateTimePicker builder
*/
public static DateTimePicker.Builder builder() {
return new DateTimePicker.Builder();
}
/**
* Builds instances of type {@link DateTimePicker DateTimePicker}.
* 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 = "DateTimePickerIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_ACTION_ID = 0x1L;
private long initBits = 0x1L;
private @Nullable String actionId;
private @Nullable Text placeholder;
private @Nullable Integer initialDateTime;
private @Nullable ConfirmationDialog confirmationDialog;
private @Nullable Boolean focusOnLoad;
private Builder() {
}
/**
* Fill a builder with attribute values from the provided {@code com.hubspot.slack.client.models.blocks.elements.HasActionId} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(HasActionId 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.blocks.elements.DateTimePickerIF} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(DateTimePickerIF 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 HasActionId) {
HasActionId instance = (HasActionId) object;
if ((bits & 0x1L) == 0) {
this.setActionId(instance.getActionId());
bits |= 0x1L;
}
}
if (object instanceof DateTimePickerIF) {
DateTimePickerIF instance = (DateTimePickerIF) object;
Optional focusOnLoadOptional = instance.isFocusOnLoad();
if (focusOnLoadOptional.isPresent()) {
setFocusOnLoad(focusOnLoadOptional);
}
if ((bits & 0x1L) == 0) {
this.setActionId(instance.getActionId());
bits |= 0x1L;
}
Optional initialDateTimeOptional = instance.getInitialDateTime();
if (initialDateTimeOptional.isPresent()) {
setInitialDateTime(initialDateTimeOptional);
}
Optional confirmationDialogOptional = instance.getConfirmationDialog();
if (confirmationDialogOptional.isPresent()) {
setConfirmationDialog(confirmationDialogOptional);
}
Optional placeholderOptional = instance.getPlaceholder();
if (placeholderOptional.isPresent()) {
setPlaceholder(placeholderOptional);
}
}
}
/**
* Initializes the value for the {@link DateTimePickerIF#getActionId() actionId} attribute.
* @param actionId The value for actionId
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setActionId(String actionId) {
this.actionId = Objects.requireNonNull(actionId, "actionId");
initBits &= ~INIT_BIT_ACTION_ID;
return this;
}
/**
* Initializes the optional value {@link DateTimePickerIF#getPlaceholder() placeholder} to placeholder.
* @param placeholder The value for placeholder, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setPlaceholder(@Nullable Text placeholder) {
this.placeholder = placeholder;
return this;
}
/**
* Initializes the optional value {@link DateTimePickerIF#getPlaceholder() placeholder} to placeholder.
* @param placeholder The value for placeholder
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setPlaceholder(Optional extends Text> placeholder) {
this.placeholder = placeholder.orElse(null);
return this;
}
/**
* Initializes the optional value {@link DateTimePickerIF#getInitialDateTime() initialDateTime} to initialDateTime.
* @param initialDateTime The value for initialDateTime, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setInitialDateTime(@Nullable Integer initialDateTime) {
this.initialDateTime = initialDateTime;
return this;
}
/**
* Initializes the optional value {@link DateTimePickerIF#getInitialDateTime() initialDateTime} to initialDateTime.
* @param initialDateTime The value for initialDateTime
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setInitialDateTime(Optional initialDateTime) {
this.initialDateTime = initialDateTime.orElse(null);
return this;
}
/**
* Initializes the optional value {@link DateTimePickerIF#getConfirmationDialog() confirmationDialog} to confirmationDialog.
* @param confirmationDialog The value for confirmationDialog, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setConfirmationDialog(@Nullable ConfirmationDialog confirmationDialog) {
this.confirmationDialog = confirmationDialog;
return this;
}
/**
* Initializes the optional value {@link DateTimePickerIF#getConfirmationDialog() confirmationDialog} to confirmationDialog.
* @param confirmationDialog The value for confirmationDialog
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setConfirmationDialog(Optional extends ConfirmationDialog> confirmationDialog) {
this.confirmationDialog = confirmationDialog.orElse(null);
return this;
}
/**
* Initializes the optional value {@link DateTimePickerIF#isFocusOnLoad() focusOnLoad} to focusOnLoad.
* @param focusOnLoad The value for focusOnLoad, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setFocusOnLoad(@Nullable Boolean focusOnLoad) {
this.focusOnLoad = focusOnLoad;
return this;
}
/**
* Initializes the optional value {@link DateTimePickerIF#isFocusOnLoad() focusOnLoad} to focusOnLoad.
* @param focusOnLoad The value for focusOnLoad
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setFocusOnLoad(Optional focusOnLoad) {
this.focusOnLoad = focusOnLoad.orElse(null);
return this;
}
/**
* Builds a new {@link DateTimePicker DateTimePicker}.
* @return An immutable instance of DateTimePicker
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public DateTimePicker build() {
checkRequiredAttributes();
return new DateTimePicker(actionId, placeholder, initialDateTime, confirmationDialog, focusOnLoad);
}
private boolean actionIdIsSet() {
return (initBits & INIT_BIT_ACTION_ID) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!actionIdIsSet()) attributes.add("actionId");
return "Cannot build DateTimePicker, some of required attributes are not set " + attributes;
}
}
}