Class LeafExpression.Transformed<R,V>

Type Parameters:
R - the type of resources used as inputs.
V - the type of value computed by the expression.
All Implemented Interfaces:
Serializable, Function<R,V>, Expression<R,V>, Optimization.OnExpression<R,V>, FeatureExpression<R,V>, Literal<R,V>
Enclosing class:
LeafExpression<R,V>

static final class LeafExpression.Transformed<R,V> extends LeafExpression.Literal<R,V> implements Optimization.OnExpression<R,V>
A literal value which is the result of transforming another literal.
  • Field Details

    • serialVersionUID

      private static final long serialVersionUID
      For cross-version compatibility.
      See Also:
    • original

      final Expression<R,?> original
      The original expression.
  • Constructor Details

    • Transformed

      Transformed(V value, Expression<R,?> original)
      Creates a new literal holding the given constant value.
  • Method Details

    • optimize

      public Expression<? super R,? extends V> optimize(Optimization optimization)
      Returns the same literal without the reference to the original expression. Since this Transformed instance will not longer be unwrapped, the transformed value will become visible to users.
      Specified by:
      optimize in interface Optimization.OnExpression<R,V>
      Parameters:
      optimization - the simplifications or optimizations to apply on this expression.
      Returns:
      the simplified or optimized expression, or this if no optimization has been applied.
    • toValueType

      public <N> Expression<R,N> toValueType(Class<N> target)
      Converts the transformed value if possible, or the original value as a fallback.
      Specified by:
      toValueType in interface Expression<R,V>
      Overrides:
      toValueType in class LeafExpression.Literal<R,V>
      Type Parameters:
      N - compile-time value of type.
      Parameters:
      target - desired type of expression results.
      Returns:
      expression doing the same operation this this expression but with results of the specified type.
      Throws:
      ClassCastException - if values cannot be provided as instances of the specified class.