Package io.dialob.program.model
Class ImmutableConditionalValue<T>
- java.lang.Object
-
- io.dialob.program.model.ImmutableConditionalValue<T>
-
- All Implemented Interfaces:
ConditionalValue<T>,ProgramNode,Value<T>,Serializable
@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableConditionalValue<T> extends Object implements ConditionalValue<T>
Immutable implementation ofConditionalValue.Use the builder to create immutable instances:
ImmutableConditionalValue.builder().- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableConditionalValue.Builder<T>Builds instances of typeImmutableConditionalValue.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T> ImmutableConditionalValue.Builder<T>builder()Creates a builder forImmutableConditionalValue.static <T> ImmutableConditionalValue<T>copyOf(ConditionalValue<T> instance)Creates an immutable copy of aConditionalValuevalue.booleanequals(Object another)This instance is equal to all instances ofImmutableConditionalValuethat have equal attribute values.TgetFallbackValue()TgetValue()ValueTypegetValueType()ExpressiongetWhen()inthashCode()Computes a hash code from attributes:when,value,fallbackValue,valueType.StringtoString()Prints the immutable valueConditionalValuewith attribute values.ImmutableConditionalValue<T>withFallbackValue(T value)Copy the current immutable object by setting a value for thefallbackValueattribute.ImmutableConditionalValue<T>withValue(T value)Copy the current immutable object by setting a value for thevalueattribute.ImmutableConditionalValue<T>withValueType(ValueType value)Copy the current immutable object by setting a value for thevalueTypeattribute.ImmutableConditionalValue<T>withWhen(Expression value)Copy the current immutable object by setting a value for thewhenattribute.-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.dialob.program.model.ConditionalValue
eval
-
-
-
-
Method Detail
-
getWhen
public Expression getWhen()
- Specified by:
getWhenin interfaceConditionalValue<T>- Returns:
- The value of the
whenattribute
-
getValue
@Nullable public T getValue()
- Specified by:
getValuein interfaceConditionalValue<T>- Returns:
- The value of the
valueattribute
-
getFallbackValue
@Nullable public T getFallbackValue()
- Specified by:
getFallbackValuein interfaceConditionalValue<T>- Returns:
- The value of the
fallbackValueattribute
-
getValueType
public ValueType getValueType()
- Specified by:
getValueTypein interfaceConditionalValue<T>- Specified by:
getValueTypein interfaceValue<T>- Returns:
- The value of the
valueTypeattribute
-
withWhen
public final ImmutableConditionalValue<T> withWhen(Expression value)
Copy the current immutable object by setting a value for thewhenattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for when- Returns:
- A modified copy of the
thisobject
-
withValue
public final ImmutableConditionalValue<T> withValue(@Nullable T value)
Copy the current immutable object by setting a value for thevalueattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for value (can benull)- Returns:
- A modified copy of the
thisobject
-
withFallbackValue
public final ImmutableConditionalValue<T> withFallbackValue(@Nullable T value)
Copy the current immutable object by setting a value for thefallbackValueattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for fallbackValue (can benull)- Returns:
- A modified copy of the
thisobject
-
withValueType
public final ImmutableConditionalValue<T> withValueType(ValueType value)
Copy the current immutable object by setting a value for thevalueTypeattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for valueType- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(@Nullable Object another)This instance is equal to all instances ofImmutableConditionalValuethat have equal attribute values.
-
hashCode
public int hashCode()
Computes a hash code from attributes:when,value,fallbackValue,valueType.
-
toString
public String toString()
Prints the immutable valueConditionalValuewith attribute values.
-
copyOf
public static <T> ImmutableConditionalValue<T> copyOf(ConditionalValue<T> instance)
Creates an immutable copy of aConditionalValuevalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
T- generic parameter T- Parameters:
instance- The instance to copy- Returns:
- A copied immutable ConditionalValue instance
-
builder
public static <T> ImmutableConditionalValue.Builder<T> builder()
Creates a builder forImmutableConditionalValue.ImmutableConditionalValue.<T>builder() .when(io.dialob.program.model.Expression) // requiredwhen.value(T | null) // nullablevalue.fallbackValue(T | null) // nullablefallbackValue.valueType(io.dialob.rule.parser.api.ValueType) // requiredvalueType.build();- Type Parameters:
T- generic parameter T- Returns:
- A new ImmutableConditionalValue builder
-
-