com.neotys.neoload.model.v3.project.variable.ImmutableRandomNumberVariable Maven / Gradle / Ivy
package com.neotys.neoload.model.v3.project.variable;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.common.base.MoreObjects;
import com.google.common.collect.Lists;
import com.google.common.primitives.Booleans;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.neotys.neoload.model.v3.project.Element;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Optional;
import javax.annotation.CheckReturnValue;
import javax.annotation.Generated;
import javax.annotation.Nullable;
import javax.annotation.ParametersAreNonnullByDefault;
import javax.annotation.concurrent.Immutable;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Immutable implementation of {@link RandomNumberVariable}.
*
* Use the builder to create immutable instances:
* {@code new RandomNumberVariable.Builder()}.
*/
@SuppressWarnings({"all"})
@ParametersAreNonnullByDefault
@Generated({"Immutables.generator", "RandomNumberVariable"})
@Immutable
@CheckReturnValue
public final class ImmutableRandomNumberVariable
implements RandomNumberVariable {
private final int min;
private final int max;
private final boolean isPredictable;
private final Variable.ChangePolicy changePolicy;
private final Variable.Scope scope;
private final Variable.Order order;
private final Variable.OutOfValue outOfValue;
private final String name;
private final @Nullable String description;
private ImmutableRandomNumberVariable(ImmutableRandomNumberVariable.Builder builder) {
this.min = builder.min;
this.max = builder.max;
this.name = builder.name;
this.description = builder.description;
if (builder.isPredictableIsSet()) {
initShim.isPredictable(builder.isPredictable);
}
if (builder.changePolicy != null) {
initShim.changePolicy(builder.changePolicy);
}
if (builder.scope != null) {
initShim.scope(builder.scope);
}
if (builder.order != null) {
initShim.order(builder.order);
}
if (builder.outOfValue != null) {
initShim.outOfValue(builder.outOfValue);
}
this.isPredictable = initShim.isPredictable();
this.changePolicy = initShim.getChangePolicy();
this.scope = initShim.getScope();
this.order = initShim.getOrder();
this.outOfValue = initShim.getOutOfValue();
this.initShim = null;
}
private ImmutableRandomNumberVariable(
int min,
int max,
boolean isPredictable,
Variable.ChangePolicy changePolicy,
Variable.Scope scope,
Variable.Order order,
Variable.OutOfValue outOfValue,
String name,
@Nullable String description) {
this.min = min;
this.max = max;
this.isPredictable = isPredictable;
this.changePolicy = changePolicy;
this.scope = scope;
this.order = order;
this.outOfValue = outOfValue;
this.name = name;
this.description = description;
this.initShim = null;
}
private static final int STAGE_INITIALIZING = -1;
private static final int STAGE_UNINITIALIZED = 0;
private static final int STAGE_INITIALIZED = 1;
private transient volatile InitShim initShim = new InitShim();
private final class InitShim {
private boolean isPredictable;
private int isPredictableBuildStage;
boolean isPredictable() {
if (isPredictableBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (isPredictableBuildStage == STAGE_UNINITIALIZED) {
isPredictableBuildStage = STAGE_INITIALIZING;
this.isPredictable = isPredictableInitialize();
isPredictableBuildStage = STAGE_INITIALIZED;
}
return this.isPredictable;
}
void isPredictable(boolean isPredictable) {
this.isPredictable = isPredictable;
isPredictableBuildStage = STAGE_INITIALIZED;
}
private Variable.ChangePolicy changePolicy;
private int changePolicyBuildStage;
Variable.ChangePolicy getChangePolicy() {
if (changePolicyBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (changePolicyBuildStage == STAGE_UNINITIALIZED) {
changePolicyBuildStage = STAGE_INITIALIZING;
this.changePolicy = Objects.requireNonNull(getChangePolicyInitialize(), "changePolicy");
changePolicyBuildStage = STAGE_INITIALIZED;
}
return this.changePolicy;
}
void changePolicy(Variable.ChangePolicy changePolicy) {
this.changePolicy = changePolicy;
changePolicyBuildStage = STAGE_INITIALIZED;
}
private Variable.Scope scope;
private int scopeBuildStage;
Variable.Scope getScope() {
if (scopeBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (scopeBuildStage == STAGE_UNINITIALIZED) {
scopeBuildStage = STAGE_INITIALIZING;
this.scope = Objects.requireNonNull(getScopeInitialize(), "scope");
scopeBuildStage = STAGE_INITIALIZED;
}
return this.scope;
}
void scope(Variable.Scope scope) {
this.scope = scope;
scopeBuildStage = STAGE_INITIALIZED;
}
private Variable.Order order;
private int orderBuildStage;
Variable.Order getOrder() {
if (orderBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (orderBuildStage == STAGE_UNINITIALIZED) {
orderBuildStage = STAGE_INITIALIZING;
this.order = Objects.requireNonNull(getOrderInitialize(), "order");
orderBuildStage = STAGE_INITIALIZED;
}
return this.order;
}
void order(Variable.Order order) {
this.order = order;
orderBuildStage = STAGE_INITIALIZED;
}
private Variable.OutOfValue outOfValue;
private int outOfValueBuildStage;
Variable.OutOfValue getOutOfValue() {
if (outOfValueBuildStage == STAGE_INITIALIZING) throw new IllegalStateException(formatInitCycleMessage());
if (outOfValueBuildStage == STAGE_UNINITIALIZED) {
outOfValueBuildStage = STAGE_INITIALIZING;
this.outOfValue = Objects.requireNonNull(getOutOfValueInitialize(), "outOfValue");
outOfValueBuildStage = STAGE_INITIALIZED;
}
return this.outOfValue;
}
void outOfValue(Variable.OutOfValue outOfValue) {
this.outOfValue = outOfValue;
outOfValueBuildStage = STAGE_INITIALIZED;
}
private String formatInitCycleMessage() {
ArrayList attributes = Lists.newArrayList();
if (isPredictableBuildStage == STAGE_INITIALIZING) attributes.add("isPredictable");
if (changePolicyBuildStage == STAGE_INITIALIZING) attributes.add("changePolicy");
if (scopeBuildStage == STAGE_INITIALIZING) attributes.add("scope");
if (orderBuildStage == STAGE_INITIALIZING) attributes.add("order");
if (outOfValueBuildStage == STAGE_INITIALIZING) attributes.add("outOfValue");
return "Cannot build RandomNumberVariable, attribute initializers form cycle" + attributes;
}
}
private boolean isPredictableInitialize() {
return RandomNumberVariable.super.isPredictable();
}
private Variable.ChangePolicy getChangePolicyInitialize() {
return RandomNumberVariable.super.getChangePolicy();
}
private Variable.Scope getScopeInitialize() {
return RandomNumberVariable.super.getScope();
}
private Variable.Order getOrderInitialize() {
return RandomNumberVariable.super.getOrder();
}
private Variable.OutOfValue getOutOfValueInitialize() {
return RandomNumberVariable.super.getOutOfValue();
}
/**
* @return The value of the {@code min} attribute
*/
@JsonProperty("min")
@Override
public int getMin() {
return min;
}
/**
* @return The value of the {@code max} attribute
*/
@JsonProperty("max")
@Override
public int getMax() {
return max;
}
/**
* @return The value of the {@code isPredictable} attribute
*/
@JsonProperty("predictable")
@Override
public boolean isPredictable() {
InitShim shim = this.initShim;
return shim != null
? shim.isPredictable()
: this.isPredictable;
}
/**
* @return The value of the {@code changePolicy} attribute
*/
@JsonProperty("change_policy")
@Override
public Variable.ChangePolicy getChangePolicy() {
InitShim shim = this.initShim;
return shim != null
? shim.getChangePolicy()
: this.changePolicy;
}
/**
* @return The value of the {@code scope} attribute
*/
@JsonProperty("scope")
@Override
public Variable.Scope getScope() {
InitShim shim = this.initShim;
return shim != null
? shim.getScope()
: this.scope;
}
/**
* @return The value of the {@code order} attribute
*/
@JsonProperty("order")
@Override
public Variable.Order getOrder() {
InitShim shim = this.initShim;
return shim != null
? shim.getOrder()
: this.order;
}
/**
* @return The value of the {@code outOfValue} attribute
*/
@JsonProperty("out_of_value")
@Override
public Variable.OutOfValue getOutOfValue() {
InitShim shim = this.initShim;
return shim != null
? shim.getOutOfValue()
: this.outOfValue;
}
/**
* @return The value of the {@code name} attribute
*/
@JsonProperty("name")
@Override
public String getName() {
return name;
}
/**
* @return The value of the {@code description} attribute
*/
@JsonProperty("description")
@Override
public Optional getDescription() {
return Optional.ofNullable(description);
}
/**
* Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getMin() min} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for min
* @return A modified copy of the {@code this} object
*/
public final ImmutableRandomNumberVariable withMin(int value) {
if (this.min == value) return this;
return new ImmutableRandomNumberVariable(
value,
this.max,
this.isPredictable,
this.changePolicy,
this.scope,
this.order,
this.outOfValue,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getMax() max} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for max
* @return A modified copy of the {@code this} object
*/
public final ImmutableRandomNumberVariable withMax(int value) {
if (this.max == value) return this;
return new ImmutableRandomNumberVariable(
this.min,
value,
this.isPredictable,
this.changePolicy,
this.scope,
this.order,
this.outOfValue,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link RandomNumberVariable#isPredictable() isPredictable} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for isPredictable
* @return A modified copy of the {@code this} object
*/
public final ImmutableRandomNumberVariable withIsPredictable(boolean value) {
if (this.isPredictable == value) return this;
return new ImmutableRandomNumberVariable(
this.min,
this.max,
value,
this.changePolicy,
this.scope,
this.order,
this.outOfValue,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getChangePolicy() changePolicy} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for changePolicy
* @return A modified copy of the {@code this} object
*/
public final ImmutableRandomNumberVariable withChangePolicy(Variable.ChangePolicy value) {
if (this.changePolicy == value) return this;
Variable.ChangePolicy newValue = Objects.requireNonNull(value, "changePolicy");
return new ImmutableRandomNumberVariable(
this.min,
this.max,
this.isPredictable,
newValue,
this.scope,
this.order,
this.outOfValue,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getScope() scope} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for scope
* @return A modified copy of the {@code this} object
*/
public final ImmutableRandomNumberVariable withScope(Variable.Scope value) {
if (this.scope == value) return this;
Variable.Scope newValue = Objects.requireNonNull(value, "scope");
return new ImmutableRandomNumberVariable(
this.min,
this.max,
this.isPredictable,
this.changePolicy,
newValue,
this.order,
this.outOfValue,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getOrder() order} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for order
* @return A modified copy of the {@code this} object
*/
public final ImmutableRandomNumberVariable withOrder(Variable.Order value) {
if (this.order == value) return this;
Variable.Order newValue = Objects.requireNonNull(value, "order");
return new ImmutableRandomNumberVariable(
this.min,
this.max,
this.isPredictable,
this.changePolicy,
this.scope,
newValue,
this.outOfValue,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getOutOfValue() outOfValue} attribute.
* A value equality check is used to prevent copying of the same value by returning {@code this}.
* @param value A new value for outOfValue
* @return A modified copy of the {@code this} object
*/
public final ImmutableRandomNumberVariable withOutOfValue(Variable.OutOfValue value) {
if (this.outOfValue == value) return this;
Variable.OutOfValue newValue = Objects.requireNonNull(value, "outOfValue");
return new ImmutableRandomNumberVariable(
this.min,
this.max,
this.isPredictable,
this.changePolicy,
this.scope,
this.order,
newValue,
this.name,
this.description);
}
/**
* Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getName() name} attribute.
* An equals check used to prevent copying of the same value by returning {@code this}.
* @param value A new value for name (can be {@code null})
* @return A modified copy of the {@code this} object
*/
public final ImmutableRandomNumberVariable withName(String value) {
if (Objects.equals(this.name, value)) return this;
return new ImmutableRandomNumberVariable(
this.min,
this.max,
this.isPredictable,
this.changePolicy,
this.scope,
this.order,
this.outOfValue,
value,
this.description);
}
/**
* Copy the current immutable object by setting a present value for the optional {@link RandomNumberVariable#getDescription() description} attribute.
* @param value The value for description
* @return A modified copy of {@code this} object
*/
public final ImmutableRandomNumberVariable withDescription(String value) {
@Nullable String newValue = Objects.requireNonNull(value, "description");
if (Objects.equals(this.description, newValue)) return this;
return new ImmutableRandomNumberVariable(
this.min,
this.max,
this.isPredictable,
this.changePolicy,
this.scope,
this.order,
this.outOfValue,
this.name,
newValue);
}
/**
* Copy the current immutable object by setting an optional value for the {@link RandomNumberVariable#getDescription() description} 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 description
* @return A modified copy of {@code this} object
*/
public final ImmutableRandomNumberVariable withDescription(Optional optional) {
@Nullable String value = optional.orElse(null);
if (Objects.equals(this.description, value)) return this;
return new ImmutableRandomNumberVariable(
this.min,
this.max,
this.isPredictable,
this.changePolicy,
this.scope,
this.order,
this.outOfValue,
this.name,
value);
}
/**
* This instance is equal to all instances of {@code ImmutableRandomNumberVariable} 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 ImmutableRandomNumberVariable
&& equalTo((ImmutableRandomNumberVariable) another);
}
private boolean equalTo(ImmutableRandomNumberVariable another) {
return min == another.min
&& max == another.max
&& isPredictable == another.isPredictable
&& changePolicy.equals(another.changePolicy)
&& scope.equals(another.scope)
&& order.equals(another.order)
&& outOfValue.equals(another.outOfValue)
&& Objects.equals(name, another.name)
&& Objects.equals(description, another.description);
}
/**
* Computes a hash code from attributes: {@code min}, {@code max}, {@code isPredictable}, {@code changePolicy}, {@code scope}, {@code order}, {@code outOfValue}, {@code name}, {@code description}.
* @return hashCode value
*/
@Override
public int hashCode() {
int h = 5381;
h += (h << 5) + min;
h += (h << 5) + max;
h += (h << 5) + Booleans.hashCode(isPredictable);
h += (h << 5) + changePolicy.hashCode();
h += (h << 5) + scope.hashCode();
h += (h << 5) + order.hashCode();
h += (h << 5) + outOfValue.hashCode();
h += (h << 5) + Objects.hashCode(name);
h += (h << 5) + Objects.hashCode(description);
return h;
}
/**
* Prints the immutable value {@code RandomNumberVariable} with attribute values.
* @return A string representation of the value
*/
@Override
public String toString() {
return MoreObjects.toStringHelper("RandomNumberVariable")
.omitNullValues()
.add("min", min)
.add("max", max)
.add("isPredictable", isPredictable)
.add("changePolicy", changePolicy)
.add("scope", scope)
.add("order", order)
.add("outOfValue", outOfValue)
.add("name", name)
.add("description", description)
.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
*/
@Deprecated
@JsonDeserialize
@JsonTypeInfo(use=JsonTypeInfo.Id.NONE)
@JsonAutoDetect(fieldVisibility = JsonAutoDetect.Visibility.NONE)
static final class Json implements RandomNumberVariable {
int min;
boolean minIsSet;
int max;
boolean maxIsSet;
boolean isPredictable;
boolean isPredictableIsSet;
@Nullable Variable.ChangePolicy changePolicy;
@Nullable Variable.Scope scope;
@Nullable Variable.Order order;
@Nullable Variable.OutOfValue outOfValue;
@Nullable String name;
Optional description = Optional.empty();
@JsonProperty("min")
public void setMin(int min) {
this.min = min;
this.minIsSet = true;
}
@JsonProperty("max")
public void setMax(int max) {
this.max = max;
this.maxIsSet = true;
}
@JsonProperty("predictable")
public void setIsPredictable(boolean isPredictable) {
this.isPredictable = isPredictable;
this.isPredictableIsSet = true;
}
@JsonProperty("change_policy")
public void setChangePolicy(Variable.ChangePolicy changePolicy) {
this.changePolicy = changePolicy;
}
@JsonProperty("scope")
public void setScope(Variable.Scope scope) {
this.scope = scope;
}
@JsonProperty("order")
public void setOrder(Variable.Order order) {
this.order = order;
}
@JsonProperty("out_of_value")
public void setOutOfValue(Variable.OutOfValue outOfValue) {
this.outOfValue = outOfValue;
}
@JsonProperty("name")
public void setName(String name) {
this.name = name;
}
@JsonProperty("description")
public void setDescription(Optional description) {
this.description = description;
}
@Override
public Element withName(String of) { throw new UnsupportedOperationException(); }
@Override
public int getMin() { throw new UnsupportedOperationException(); }
@Override
public int getMax() { throw new UnsupportedOperationException(); }
@Override
public boolean isPredictable() { throw new UnsupportedOperationException(); }
@Override
public Variable.ChangePolicy getChangePolicy() { throw new UnsupportedOperationException(); }
@Override
public Variable.Scope getScope() { throw new UnsupportedOperationException(); }
@Override
public Variable.Order getOrder() { throw new UnsupportedOperationException(); }
@Override
public Variable.OutOfValue getOutOfValue() { throw new UnsupportedOperationException(); }
@Override
public String getName() { throw new UnsupportedOperationException(); }
@Override
public Optional getDescription() { 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 ImmutableRandomNumberVariable fromJson(Json json) {
RandomNumberVariable.Builder builder = new RandomNumberVariable.Builder();
if (json.minIsSet) {
builder.min(json.min);
}
if (json.maxIsSet) {
builder.max(json.max);
}
if (json.isPredictableIsSet) {
builder.isPredictable(json.isPredictable);
}
if (json.changePolicy != null) {
builder.changePolicy(json.changePolicy);
}
if (json.scope != null) {
builder.scope(json.scope);
}
if (json.order != null) {
builder.order(json.order);
}
if (json.outOfValue != null) {
builder.outOfValue(json.outOfValue);
}
if (json.name != null) {
builder.name(json.name);
}
if (json.description != null) {
builder.description(json.description);
}
return (ImmutableRandomNumberVariable) builder.build();
}
/**
* Creates an immutable copy of a {@link RandomNumberVariable} 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 RandomNumberVariable instance
*/
public static ImmutableRandomNumberVariable copyOf(RandomNumberVariable instance) {
if (instance instanceof ImmutableRandomNumberVariable) {
return (ImmutableRandomNumberVariable) instance;
}
return new RandomNumberVariable.Builder()
.from(instance)
.build();
}
/**
* Builds instances of type {@link ImmutableRandomNumberVariable ImmutableRandomNumberVariable}.
* 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.
*/
@NotThreadSafe
public static class Builder {
private static final long OPT_BIT_IS_PREDICTABLE = 0x1L;
private long optBits;
private int min;
private int max;
private boolean isPredictable;
private @Nullable Variable.ChangePolicy changePolicy;
private @Nullable Variable.Scope scope;
private @Nullable Variable.Order order;
private @Nullable Variable.OutOfValue outOfValue;
private @Nullable String name;
private @Nullable String description;
/**
* Creates a builder for {@link ImmutableRandomNumberVariable ImmutableRandomNumberVariable} instances.
*/
public Builder() {
if (!(this instanceof RandomNumberVariable.Builder)) {
throw new UnsupportedOperationException("Use: new RandomNumberVariable.Builder()");
}
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.Element} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final RandomNumberVariable.Builder from(Element instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (RandomNumberVariable.Builder) this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.variable.Variable} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final RandomNumberVariable.Builder from(Variable instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (RandomNumberVariable.Builder) this;
}
/**
* Fill a builder with attribute values from the provided {@code com.neotys.neoload.model.v3.project.variable.RandomNumberVariable} instance.
* @param instance The instance from which to copy values
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
public final RandomNumberVariable.Builder from(RandomNumberVariable instance) {
Objects.requireNonNull(instance, "instance");
from((Object) instance);
return (RandomNumberVariable.Builder) this;
}
private void from(Object object) {
if (object instanceof Element) {
Element instance = (Element) object;
String nameValue = instance.getName();
if (nameValue != null) {
name(nameValue);
}
Optional descriptionOptional = instance.getDescription();
if (descriptionOptional.isPresent()) {
description(descriptionOptional);
}
}
if (object instanceof Variable) {
Variable instance = (Variable) object;
changePolicy(instance.getChangePolicy());
scope(instance.getScope());
outOfValue(instance.getOutOfValue());
order(instance.getOrder());
}
if (object instanceof RandomNumberVariable) {
RandomNumberVariable instance = (RandomNumberVariable) object;
max(instance.getMax());
min(instance.getMin());
isPredictable(instance.isPredictable());
}
}
/**
* Initializes the value for the {@link RandomNumberVariable#getMin() min} attribute.
* @param min The value for min
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("min")
public final RandomNumberVariable.Builder min(int min) {
this.min = min;
return (RandomNumberVariable.Builder) this;
}
/**
* Initializes the value for the {@link RandomNumberVariable#getMax() max} attribute.
* @param max The value for max
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("max")
public final RandomNumberVariable.Builder max(int max) {
this.max = max;
return (RandomNumberVariable.Builder) this;
}
/**
* Initializes the value for the {@link RandomNumberVariable#isPredictable() isPredictable} attribute.
* If not set, this attribute will have a default value as returned by the initializer of {@link RandomNumberVariable#isPredictable() isPredictable}.
* @param isPredictable The value for isPredictable
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("predictable")
public final RandomNumberVariable.Builder isPredictable(boolean isPredictable) {
this.isPredictable = isPredictable;
optBits |= OPT_BIT_IS_PREDICTABLE;
return (RandomNumberVariable.Builder) this;
}
/**
* Initializes the value for the {@link RandomNumberVariable#getChangePolicy() changePolicy} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link RandomNumberVariable#getChangePolicy() changePolicy}.
* @param changePolicy The value for changePolicy
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("change_policy")
public final RandomNumberVariable.Builder changePolicy(Variable.ChangePolicy changePolicy) {
this.changePolicy = Objects.requireNonNull(changePolicy, "changePolicy");
return (RandomNumberVariable.Builder) this;
}
/**
* Initializes the value for the {@link RandomNumberVariable#getScope() scope} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link RandomNumberVariable#getScope() scope}.
* @param scope The value for scope
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("scope")
public final RandomNumberVariable.Builder scope(Variable.Scope scope) {
this.scope = Objects.requireNonNull(scope, "scope");
return (RandomNumberVariable.Builder) this;
}
/**
* Initializes the value for the {@link RandomNumberVariable#getOrder() order} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link RandomNumberVariable#getOrder() order}.
* @param order The value for order
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("order")
public final RandomNumberVariable.Builder order(Variable.Order order) {
this.order = Objects.requireNonNull(order, "order");
return (RandomNumberVariable.Builder) this;
}
/**
* Initializes the value for the {@link RandomNumberVariable#getOutOfValue() outOfValue} attribute.
*
If not set, this attribute will have a default value as returned by the initializer of {@link RandomNumberVariable#getOutOfValue() outOfValue}.
* @param outOfValue The value for outOfValue
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("out_of_value")
public final RandomNumberVariable.Builder outOfValue(Variable.OutOfValue outOfValue) {
this.outOfValue = Objects.requireNonNull(outOfValue, "outOfValue");
return (RandomNumberVariable.Builder) this;
}
/**
* Initializes the value for the {@link RandomNumberVariable#getName() name} attribute.
* @param name The value for name (can be {@code null})
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("name")
public final RandomNumberVariable.Builder name(String name) {
this.name = name;
return (RandomNumberVariable.Builder) this;
}
/**
* Initializes the optional value {@link RandomNumberVariable#getDescription() description} to description.
* @param description The value for description
* @return {@code this} builder for chained invocation
*/
@CanIgnoreReturnValue
public final RandomNumberVariable.Builder description(String description) {
this.description = Objects.requireNonNull(description, "description");
return (RandomNumberVariable.Builder) this;
}
/**
* Initializes the optional value {@link RandomNumberVariable#getDescription() description} to description.
* @param description The value for description
* @return {@code this} builder for use in a chained invocation
*/
@CanIgnoreReturnValue
@JsonProperty("description")
public final RandomNumberVariable.Builder description(Optional description) {
this.description = description.orElse(null);
return (RandomNumberVariable.Builder) this;
}
/**
* Builds a new {@link ImmutableRandomNumberVariable ImmutableRandomNumberVariable}.
* @return An immutable instance of RandomNumberVariable
* @throws java.lang.IllegalStateException if any required attributes are missing
*/
public ImmutableRandomNumberVariable build() {
return new ImmutableRandomNumberVariable(this);
}
private boolean isPredictableIsSet() {
return (optBits & OPT_BIT_IS_PREDICTABLE) != 0;
}
}
}