public class TransformerCast extends Object implements Expression
Transformable.as(Class) on the given selfExpression and also provides the expected type at
compile time.
As currently generics aren't supported, .as() would yield Object.class as type which isn't satisfying. As we use .as() as cast operator, we simply overload this behavior, if the selfExpression is known to be a Transformable.
| Constructor and Description |
|---|
TransformerCast(Expression selfExpression,
Class<?> type)
Creates a new invokation and compile time cast for the given expression with the given type.
|
| Modifier and Type | Method and Description |
|---|---|
Expression |
copy()
Creates a deep copy of the expression which can be modified without affecting the original expression.
|
Object |
eval(LocalRenderContext ctx)
Evaluates the expression into an object using the given context.
|
Class<?> |
getType()
Returns the Java class of the objects yielded by this expression.
|
boolean |
isConstant()
Determines if the expression is constant.
|
Expression |
propagateVisitor(ExpressionVisitor visitor)
Visits all child nodes and then the node itself.
|
Expression |
reduce()
Reduces and optimizes the expression if possible.
|
public TransformerCast(Expression selfExpression, Class<?> type)
selfExpression - the expression to casttype - the expected typepublic Expression propagateVisitor(ExpressionVisitor visitor)
ExpressionpropagateVisitor in interface Expressionvisitor - the visitor to invoke for all child nodes and on the node itselfpublic Expression reduce()
Expressionreduce in interface Expressionpublic Expression copy()
Expressioncopy in interface Expressionpublic boolean isConstant()
ExpressionisConstant in interface Expressionpublic Object eval(LocalRenderContext ctx)
Expressioneval in interface Expressionctx - the current rendering contextpublic Class<?> getType()
ExpressiongetType in interface ExpressionCopyright © 2018. All rights reserved.