
com.hubspot.slack.client.models.blocks.elements.NumberInput 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.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 NumberInputIF}.
*
* Use the builder to create immutable instances:
* {@code NumberInput.builder()}.
* Use the static factory method to create immutable instances:
* {@code NumberInput.of()}.
*/
@Generated(from = "NumberInputIF", generator = "Immutables")
@SuppressWarnings({"all"})
@SuppressFBWarnings
@ParametersAreNonnullByDefault
@javax.annotation.processing.Generated("org.immutables.processor.ProxyProcessor")
@Immutable
public final class NumberInput implements NumberInputIF {
private transient final String type;
private final String actionId;
private final boolean decimalAllowed;
private final @Nullable Text placeholder;
private final @Nullable String initialValue;
private final @Nullable String minValue;
private final @Nullable String maxValue;
private final @Nullable Boolean focusOnLoad;
private NumberInput(String actionId, boolean decimalAllowed) {
this.actionId = Objects.requireNonNull(actionId, "actionId");
this.decimalAllowed = decimalAllowed;
this.placeholder = null;
this.initialValue = null;
this.minValue = null;
this.maxValue = null;
this.focusOnLoad = null;
this.type = Objects.requireNonNull(NumberInputIF.super.getType(), "type");
}
private NumberInput(
String actionId,
boolean decimalAllowed,
@Nullable Text placeholder,
@Nullable String initialValue,
@Nullable String minValue,
@Nullable String maxValue,
@Nullable Boolean focusOnLoad) {
this.actionId = actionId;
this.decimalAllowed = decimalAllowed;
this.placeholder = placeholder;
this.initialValue = initialValue;
this.minValue = minValue;
this.maxValue = maxValue;
this.focusOnLoad = focusOnLoad;
this.type = Objects.requireNonNull(NumberInputIF.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 decimalAllowed} attribute
*/
@JsonProperty("is_decimal_allowed")
@Override
public boolean isDecimalAllowed() {
return decimalAllowed;
}
/**
* @return The value of the {@code placeholder} attribute
*/
@JsonProperty
@Override
public Optional getPlaceholder() {
return Optional.ofNullable(placeholder);
}
/**
* @return The value of the {@code initialValue} attribute
*/
@JsonProperty
@Override
public Optional getInitialValue() {
return Optional.ofNullable(initialValue);
}
/**
* @return The value of the {@code minValue} attribute
*/
@JsonProperty
@Override
public Optional getMinValue() {
return Optional.ofNullable(minValue);
}
/**
* @return The value of the {@code maxValue} attribute
*/
@JsonProperty
@Override
public Optional getMaxValue() {
return Optional.ofNullable(maxValue);
}
/**
* @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 NumberInputIF#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 NumberInput withActionId(String value) {
String newValue = Objects.requireNonNull(value, "actionId");
if (this.actionId.equals(newValue)) return this;
return validate(new NumberInput(
newValue,
this.decimalAllowed,
this.placeholder,
this.initialValue,
this.minValue,
this.maxValue,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting a value for the {@link NumberInputIF#isDecimalAllowed() decimalAllowed} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for decimalAllowed
* @return A modified copy of the {@code this} object
*/
public final NumberInput withDecimalAllowed(boolean value) {
if (this.decimalAllowed == value) return this;
return validate(new NumberInput(
this.actionId,
value,
this.placeholder,
this.initialValue,
this.minValue,
this.maxValue,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link NumberInputIF#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 NumberInput withPlaceholder(@Nullable Text value) {
@Nullable Text newValue = value;
if (this.placeholder == newValue) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
newValue,
this.initialValue,
this.minValue,
this.maxValue,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting an optional value for the {@link NumberInputIF#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 NumberInput withPlaceholder(Optional extends Text> optional) {
@Nullable Text value = optional.orElse(null);
if (this.placeholder == value) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
value,
this.initialValue,
this.minValue,
this.maxValue,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link NumberInputIF#getInitialValue() initialValue} attribute.
* @param value The value for initialValue, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final NumberInput withInitialValue(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.initialValue, newValue)) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
this.placeholder,
newValue,
this.minValue,
this.maxValue,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting an optional value for the {@link NumberInputIF#getInitialValue() initialValue} 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 initialValue
* @return A modified copy of {@code this} object
*/
public final NumberInput withInitialValue(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.initialValue, value)) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
this.placeholder,
value,
this.minValue,
this.maxValue,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link NumberInputIF#getMinValue() minValue} attribute.
* @param value The value for minValue, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final NumberInput withMinValue(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.minValue, newValue)) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
this.placeholder,
this.initialValue,
newValue,
this.maxValue,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting an optional value for the {@link NumberInputIF#getMinValue() minValue} 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 minValue
* @return A modified copy of {@code this} object
*/
public final NumberInput withMinValue(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.minValue, value)) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
this.placeholder,
this.initialValue,
value,
this.maxValue,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link NumberInputIF#getMaxValue() maxValue} attribute.
* @param value The value for maxValue, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return A modified copy of {@code this} object
*/
public final NumberInput withMaxValue(@Nullable String value) {
@Nullable String newValue = value;
if (Objects.equals(this.maxValue, newValue)) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
this.placeholder,
this.initialValue,
this.minValue,
newValue,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting an optional value for the {@link NumberInputIF#getMaxValue() maxValue} 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 maxValue
* @return A modified copy of {@code this} object
*/
public final NumberInput withMaxValue(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.maxValue, value)) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
this.placeholder,
this.initialValue,
this.minValue,
value,
this.focusOnLoad));
}
/**
* Copy the current immutable object by setting a present value for the optional {@link NumberInputIF#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 NumberInput withFocusOnLoad(@Nullable Boolean value) {
@Nullable Boolean newValue = value;
if (Objects.equals(this.focusOnLoad, newValue)) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
this.placeholder,
this.initialValue,
this.minValue,
this.maxValue,
newValue));
}
/**
* Copy the current immutable object by setting an optional value for the {@link NumberInputIF#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 NumberInput withFocusOnLoad(Optional optional) {
@Nullable Boolean value = optional.orElse(null);
if (Objects.equals(this.focusOnLoad, value)) return this;
return validate(new NumberInput(
this.actionId,
this.decimalAllowed,
this.placeholder,
this.initialValue,
this.minValue,
this.maxValue,
value));
}
/**
* This instance is equal to all instances of {@code NumberInput} 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 NumberInput
&& equalTo(0, (NumberInput) another);
}
private boolean equalTo(int synthetic, NumberInput another) {
return type.equals(another.type)
&& actionId.equals(another.actionId)
&& decimalAllowed == another.decimalAllowed
&& Objects.equals(placeholder, another.placeholder)
&& Objects.equals(initialValue, another.initialValue)
&& Objects.equals(minValue, another.minValue)
&& Objects.equals(maxValue, another.maxValue)
&& Objects.equals(focusOnLoad, another.focusOnLoad);
}
/**
* Computes a hash code from attributes: {@code type}, {@code actionId}, {@code decimalAllowed}, {@code placeholder}, {@code initialValue}, {@code minValue}, {@code maxValue}, {@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) + Boolean.hashCode(decimalAllowed);
h += (h << 5) + Objects.hashCode(placeholder);
h += (h << 5) + Objects.hashCode(initialValue);
h += (h << 5) + Objects.hashCode(minValue);
h += (h << 5) + Objects.hashCode(maxValue);
h += (h << 5) + Objects.hashCode(focusOnLoad);
return h;
}
/**
* Prints the immutable value {@code NumberInput} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder("NumberInput{");
builder.append("type=").append(type);
builder.append(", ");
builder.append("actionId=").append(actionId);
builder.append(", ");
builder.append("decimalAllowed=").append(decimalAllowed);
if (placeholder != null) {
builder.append(", ");
builder.append("placeholder=").append(placeholder);
}
if (initialValue != null) {
builder.append(", ");
builder.append("initialValue=").append(initialValue);
}
if (minValue != null) {
builder.append(", ");
builder.append("minValue=").append(minValue);
}
if (maxValue != null) {
builder.append(", ");
builder.append("maxValue=").append(maxValue);
}
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 = "NumberInputIF", generator = "Immutables")
@Deprecated
@JsonTypeInfo(use=JsonTypeInfo.Id.NONE)
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements NumberInputIF {
@Nullable String actionId;
boolean decimalAllowed;
boolean decimalAllowedIsSet;
@Nullable Optional placeholder = Optional.empty();
@Nullable Optional initialValue = Optional.empty();
@Nullable Optional minValue = Optional.empty();
@Nullable Optional maxValue = Optional.empty();
@Nullable Optional focusOnLoad = Optional.empty();
@JsonProperty
public void setActionId(String actionId) {
this.actionId = actionId;
}
@JsonProperty("is_decimal_allowed")
public void setDecimalAllowed(boolean decimalAllowed) {
this.decimalAllowed = decimalAllowed;
this.decimalAllowedIsSet = true;
}
@JsonProperty
public void setPlaceholder(Optional placeholder) {
this.placeholder = placeholder;
}
@JsonProperty
public void setInitialValue(Optional initialValue) {
this.initialValue = initialValue;
}
@JsonProperty
public void setMinValue(Optional minValue) {
this.minValue = minValue;
}
@JsonProperty
public void setMaxValue(Optional maxValue) {
this.maxValue = maxValue;
}
@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 boolean isDecimalAllowed() { throw new UnsupportedOperationException(); }
@Override
public Optional getPlaceholder() { throw new UnsupportedOperationException(); }
@Override
public Optional getInitialValue() { throw new UnsupportedOperationException(); }
@Override
public Optional getMinValue() { throw new UnsupportedOperationException(); }
@Override
public Optional getMaxValue() { 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 NumberInput fromJson(Json json) {
NumberInput.Builder builder = NumberInput.builder();
if (json.actionId != null) {
builder.setActionId(json.actionId);
}
if (json.decimalAllowedIsSet) {
builder.setDecimalAllowed(json.decimalAllowed);
}
if (json.placeholder != null) {
builder.setPlaceholder(json.placeholder);
}
if (json.initialValue != null) {
builder.setInitialValue(json.initialValue);
}
if (json.minValue != null) {
builder.setMinValue(json.minValue);
}
if (json.maxValue != null) {
builder.setMaxValue(json.maxValue);
}
if (json.focusOnLoad != null) {
builder.setFocusOnLoad(json.focusOnLoad);
}
return builder.build();
}
/**
* Construct a new immutable {@code NumberInput} instance.
* @param actionId The value for the {@code actionId} attribute
* @param decimalAllowed The value for the {@code decimalAllowed} attribute
* @return An immutable NumberInput instance
*/
public static NumberInput of(String actionId, boolean decimalAllowed) {
return validate(new NumberInput(actionId, decimalAllowed));
}
private static NumberInput validate(NumberInput instance) {
instance = (NumberInput) instance.validate();
return instance;
}
/**
* Creates an immutable copy of a {@link NumberInputIF} 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 NumberInput instance
*/
public static NumberInput copyOf(NumberInputIF instance) {
if (instance instanceof NumberInput) {
return (NumberInput) instance;
}
return NumberInput.builder()
.from(instance)
.build();
}
/**
* Creates a builder for {@link NumberInput NumberInput}.
*
* NumberInput.builder()
* .setActionId(String) // required {@link NumberInputIF#getActionId() actionId}
* .setDecimalAllowed(boolean) // required {@link NumberInputIF#isDecimalAllowed() decimalAllowed}
* .setPlaceholder(com.hubspot.slack.client.models.blocks.objects.Text) // optional {@link NumberInputIF#getPlaceholder() placeholder}
* .setInitialValue(String) // optional {@link NumberInputIF#getInitialValue() initialValue}
* .setMinValue(String) // optional {@link NumberInputIF#getMinValue() minValue}
* .setMaxValue(String) // optional {@link NumberInputIF#getMaxValue() maxValue}
* .setFocusOnLoad(Boolean) // optional {@link NumberInputIF#isFocusOnLoad() focusOnLoad}
* .build();
*
* @return A new NumberInput builder
*/
public static NumberInput.Builder builder() {
return new NumberInput.Builder();
}
/**
* Builds instances of type {@link NumberInput NumberInput}.
* 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 = "NumberInputIF", generator = "Immutables")
@NotThreadSafe
public static final class Builder {
private static final long INIT_BIT_ACTION_ID = 0x1L;
private static final long INIT_BIT_DECIMAL_ALLOWED = 0x2L;
private long initBits = 0x3L;
private @Nullable String actionId;
private boolean decimalAllowed;
private @Nullable Text placeholder;
private @Nullable String initialValue;
private @Nullable String minValue;
private @Nullable String maxValue;
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.NumberInputIF} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
public final Builder from(NumberInputIF 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 NumberInputIF) {
NumberInputIF instance = (NumberInputIF) object;
Optional minValueOptional = instance.getMinValue();
if (minValueOptional.isPresent()) {
setMinValue(minValueOptional);
}
Optional maxValueOptional = instance.getMaxValue();
if (maxValueOptional.isPresent()) {
setMaxValue(maxValueOptional);
}
Optional focusOnLoadOptional = instance.isFocusOnLoad();
if (focusOnLoadOptional.isPresent()) {
setFocusOnLoad(focusOnLoadOptional);
}
if ((bits & 0x1L) == 0) {
this.setActionId(instance.getActionId());
bits |= 0x1L;
}
this.setDecimalAllowed(instance.isDecimalAllowed());
Optional placeholderOptional = instance.getPlaceholder();
if (placeholderOptional.isPresent()) {
setPlaceholder(placeholderOptional);
}
Optional initialValueOptional = instance.getInitialValue();
if (initialValueOptional.isPresent()) {
setInitialValue(initialValueOptional);
}
}
}
/**
* Initializes the value for the {@link NumberInputIF#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 value for the {@link NumberInputIF#isDecimalAllowed() decimalAllowed} attribute.
* @param decimalAllowed The value for decimalAllowed
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setDecimalAllowed(boolean decimalAllowed) {
this.decimalAllowed = decimalAllowed;
initBits &= ~INIT_BIT_DECIMAL_ALLOWED;
return this;
}
/**
* Initializes the optional value {@link NumberInputIF#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 NumberInputIF#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 NumberInputIF#getInitialValue() initialValue} to initialValue.
* @param initialValue The value for initialValue, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setInitialValue(@Nullable String initialValue) {
this.initialValue = initialValue;
return this;
}
/**
* Initializes the optional value {@link NumberInputIF#getInitialValue() initialValue} to initialValue.
* @param initialValue The value for initialValue
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setInitialValue(Optional initialValue) {
this.initialValue = initialValue.orElse(null);
return this;
}
/**
* Initializes the optional value {@link NumberInputIF#getMinValue() minValue} to minValue.
* @param minValue The value for minValue, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setMinValue(@Nullable String minValue) {
this.minValue = minValue;
return this;
}
/**
* Initializes the optional value {@link NumberInputIF#getMinValue() minValue} to minValue.
* @param minValue The value for minValue
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setMinValue(Optional minValue) {
this.minValue = minValue.orElse(null);
return this;
}
/**
* Initializes the optional value {@link NumberInputIF#getMaxValue() maxValue} to maxValue.
* @param maxValue The value for maxValue, {@code null} is accepted as {@code java.util.Optional.empty()}
* @return {@code this} builder for chained invocation
*/
public final Builder setMaxValue(@Nullable String maxValue) {
this.maxValue = maxValue;
return this;
}
/**
* Initializes the optional value {@link NumberInputIF#getMaxValue() maxValue} to maxValue.
* @param maxValue The value for maxValue
* @return {@code this} builder for use in a chained invocation
*/
public final Builder setMaxValue(Optional maxValue) {
this.maxValue = maxValue.orElse(null);
return this;
}
/**
* Initializes the optional value {@link NumberInputIF#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 NumberInputIF#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 NumberInput NumberInput}.
* @return An immutable instance of NumberInput
* @throws com.hubspot.immutables.validation.InvalidImmutableStateException if any required attributes are missing
*/
public NumberInput build() {
checkRequiredAttributes();
return NumberInput.validate(new NumberInput(actionId, decimalAllowed, placeholder, initialValue, minValue, maxValue, focusOnLoad));
}
private boolean actionIdIsSet() {
return (initBits & INIT_BIT_ACTION_ID) == 0;
}
private boolean decimalAllowedIsSet() {
return (initBits & INIT_BIT_DECIMAL_ALLOWED) == 0;
}
private void checkRequiredAttributes() {
if (initBits != 0) {
throw new InvalidImmutableStateException(formatRequiredAttributesMessage());
}
}
private String formatRequiredAttributesMessage() {
List attributes = new ArrayList<>();
if (!actionIdIsSet()) attributes.add("actionId");
if (!decimalAllowedIsSet()) attributes.add("decimalAllowed");
return "Cannot build NumberInput, some of required attributes are not set " + attributes;
}
}
}