Class ImmutableConditionalValue<T>

    • Method Detail

      • getValue

        @Nullable
        public T getValue()
        Specified by:
        getValue in interface ConditionalValue<T>
        Returns:
        The value of the value attribute
      • getFallbackValue

        @Nullable
        public T getFallbackValue()
        Specified by:
        getFallbackValue in interface ConditionalValue<T>
        Returns:
        The value of the fallbackValue attribute
      • withWhen

        public final ImmutableConditionalValue<T> withWhen​(Expression value)
        Copy the current immutable object by setting a value for the when attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for when
        Returns:
        A modified copy of the this object
      • withValue

        public final ImmutableConditionalValue<T> withValue​(@Nullable
                                                            T value)
        Copy the current immutable object by setting a value for the value attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for value (can be null)
        Returns:
        A modified copy of the this object
      • withFallbackValue

        public final ImmutableConditionalValue<T> withFallbackValue​(@Nullable
                                                                    T value)
        Copy the current immutable object by setting a value for the fallbackValue attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for fallbackValue (can be null)
        Returns:
        A modified copy of the this object
      • withValueType

        public final ImmutableConditionalValue<T> withValueType​(ValueType value)
        Copy the current immutable object by setting a value for the valueType attribute. A shallow reference equality check is used to prevent copying of the same value by returning this.
        Parameters:
        value - A new value for valueType
        Returns:
        A modified copy of the this object
      • equals

        public boolean equals​(@Nullable
                              Object another)
        This instance is equal to all instances of ImmutableConditionalValue that have equal attribute values.
        Overrides:
        equals in class Object
        Returns:
        true if this is equal to another instance
      • hashCode

        public int hashCode()
        Computes a hash code from attributes: when, value, fallbackValue, valueType.
        Overrides:
        hashCode in class Object
        Returns:
        hashCode value
      • toString

        public String toString()
        Prints the immutable value ConditionalValue with attribute values.
        Overrides:
        toString in class Object
        Returns:
        A string representation of the value
      • copyOf

        public static <T> ImmutableConditionalValue<T> copyOf​(ConditionalValue<T> instance)
        Creates an immutable copy of a ConditionalValue value. 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 for ImmutableConditionalValue.
         ImmutableConditionalValue.&lt;T&gt;builder()
            .when(io.dialob.program.model.Expression) // required when
            .value(T | null) // nullable value
            .fallbackValue(T | null) // nullable fallbackValue
            .valueType(io.dialob.rule.parser.api.ValueType) // required valueType
            .build();
         
        Type Parameters:
        T - generic parameter T
        Returns:
        A new ImmutableConditionalValue builder