/** * Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getMinValue() minValue} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for minValue * @return A modified copy of the {@code this} object */ public final ImmutableRandomNumberVariable withMinValue(int value) { if (this.minValue == value) return this; return new ImmutableRandomNumberVariable( value, this.maxValue, this.name, this.description, this.order, this.policy, this.scope, this.noValuesLeftBehavior); }
/** * 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); }
/** * 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 ImmutableRandomNumberVariable.builder() .from(instance) .build(); }
private void parseRandomParameter(Wini.Section paramSection, String paramName) { Variable.VariablePolicy pol = getPolicy(MethodUtils.normalizeString(leftBrace, rightBrace, paramSection.get("GenerateNewVal")), paramName); RandomNumberVariable variable = ImmutableRandomNumberVariable.builder().name(paramName).minValue( Integer.parseInt(MethodUtils.normalizeString(leftBrace, rightBrace, paramSection.get("MinValue")))).maxValue( Integer.parseInt(MethodUtils.normalizeString(leftBrace, rightBrace, paramSection.get("MaxValue")))).scope( VariableScope.LOCAL).policy(pol).build(); variables.put(paramName, variable); }
/** * Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getMaxValue() maxValue} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for maxValue * @return A modified copy of the {@code this} object */ public final ImmutableRandomNumberVariable withMaxValue(int value) { if (this.maxValue == value) return this; return new ImmutableRandomNumberVariable( this.minValue, value, this.name, this.description, this.order, this.policy, this.scope, this.noValuesLeftBehavior); }
/** * Copy the current immutable object by setting a value for the {@link RandomNumberVariable#getPolicy() policy} attribute. * A value equality check is used to prevent copying of the same value by returning {@code this}. * @param value A new value for policy * @return A modified copy of the {@code this} object */ public final ImmutableRandomNumberVariable withPolicy(Variable.VariablePolicy value) { if (this.policy == value) return this; Variable.VariablePolicy newValue = Objects.requireNonNull(value, "policy"); return new ImmutableRandomNumberVariable( this.minValue, this.maxValue, this.name, this.description, this.order, newValue, this.scope, this.noValuesLeftBehavior); }
/** * 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.VariableScope value) { if (this.scope == value) return this; Variable.VariableScope newValue = Objects.requireNonNull(value, "scope"); return new ImmutableRandomNumberVariable( this.minValue, this.maxValue, this.name, this.description, this.order, this.policy, newValue, this.noValuesLeftBehavior); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link RandomNumberVariable#getOrder() order} attribute. * @param value The value for order * @return A modified copy of {@code this} object */ public final ImmutableRandomNumberVariable withOrder(Variable.VariableOrder value) { @Nullable Variable.VariableOrder newValue = Objects.requireNonNull(value, "order"); if (this.order == newValue) return this; return new ImmutableRandomNumberVariable( this.minValue, this.maxValue, this.name, this.description, newValue, this.policy, this.scope, this.noValuesLeftBehavior); }
/** * Copy the current immutable object by setting a <i>present</i> value for the optional {@link RandomNumberVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} attribute. * @param value The value for noValuesLeftBehavior * @return A modified copy of {@code this} object */ public final ImmutableRandomNumberVariable withNoValuesLeftBehavior(Variable.VariableNoValuesLeftBehavior value) { @Nullable Variable.VariableNoValuesLeftBehavior newValue = Objects.requireNonNull(value, "noValuesLeftBehavior"); if (this.noValuesLeftBehavior == newValue) return this; return new ImmutableRandomNumberVariable( this.minValue, this.maxValue, this.name, this.description, this.order, this.policy, this.scope, newValue); }
/** * 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 * @return A modified copy of the {@code this} object */ public final ImmutableRandomNumberVariable withName(String value) { if (this.name.equals(value)) return this; String newValue = Objects.requireNonNull(value, "name"); return new ImmutableRandomNumberVariable( this.minValue, this.maxValue, newValue, this.description, this.order, this.policy, this.scope, this.noValuesLeftBehavior); }
/** * Copy the current immutable object by setting a <i>present</i> 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.minValue, this.maxValue, this.name, newValue, this.order, this.policy, this.scope, this.noValuesLeftBehavior); }
/** * Copy the current immutable object by setting an optional value for the {@link RandomNumberVariable#getOrder() order} 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 order * @return A modified copy of {@code this} object */ public final ImmutableRandomNumberVariable withOrder(Optional<? extends Variable.VariableOrder> optional) { @Nullable Variable.VariableOrder value = optional.orElse(null); if (Objects.equals(this.order, value)) return this; return new ImmutableRandomNumberVariable( this.minValue, this.maxValue, this.name, this.description, value, this.policy, this.scope, this.noValuesLeftBehavior); }
/** * Copy the current immutable object by setting an optional value for the {@link RandomNumberVariable#getNoValuesLeftBehavior() noValuesLeftBehavior} 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 noValuesLeftBehavior * @return A modified copy of {@code this} object */ public final ImmutableRandomNumberVariable withNoValuesLeftBehavior(Optional<? extends Variable.VariableNoValuesLeftBehavior> optional) { @Nullable Variable.VariableNoValuesLeftBehavior value = optional.orElse(null); if (Objects.equals(this.noValuesLeftBehavior, value)) return this; return new ImmutableRandomNumberVariable( this.minValue, this.maxValue, this.name, this.description, this.order, this.policy, this.scope, value); }
/** * 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<String> optional) { @Nullable String value = optional.orElse(null); if (Objects.equals(this.description, value)) return this; return new ImmutableRandomNumberVariable( this.minValue, this.maxValue, this.name, value, this.order, this.policy, this.scope, this.noValuesLeftBehavior); }
/** * 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() { if (initBits != 0) { throw new IllegalStateException(formatRequiredAttributesMessage()); } return new ImmutableRandomNumberVariable(minValue, maxValue, name, description, order, policy, scope, noValuesLeftBehavior); }