Class ReferenceNode.MethodReferenceNode
- Enclosing class:
ReferenceNode
$list.size().-
Nested Class Summary
Nested classes/interfaces inherited from class ReferenceNode
ReferenceNode.IndexReferenceNode, ReferenceNode.MemberReferenceNode, ReferenceNode.MethodReferenceNode, ReferenceNode.PlainReferenceNodeNested classes/interfaces inherited from class ExpressionNode
ExpressionNode.BinaryExpressionNode, ExpressionNode.NotExpressionNode -
Field Summary
FieldsModifier and TypeFieldDescription(package private) final List<ExpressionNode> (package private) final Stringprivate static final int(package private) final ReferenceNodeprivate static final com.google.common.collect.ImmutableList<Class<?>> Fields inherited from class Node
lineNumber, resourceName -
Constructor Summary
ConstructorsConstructorDescriptionMethodReferenceNode(ReferenceNode lhs, String id, List<ExpressionNode> args) -
Method Summary
Modifier and TypeMethodDescription(package private) static booleancompatibleArgs(Class<?>[] paramTypes, List<Object> argValues) Determines if the given argument list is compatible with the given parameter types.(package private) Objectevaluate(EvaluationContext context) Returns the result of evaluating this node in the given context.private static booleanprimitiveIsCompatible(Class<?> primitive, Object value) (package private) static booleanprimitiveTypeIsAssignmentCompatible(Class<?> to, Class<?> from) Methods inherited from class ReferenceNode
invokeMethod, visibleMethodMethods inherited from class ExpressionNode
intValue, isDefinedAndTrue, isTrueMethods inherited from class Node
cons, emptyNode, evaluationException, evaluationException
-
Field Details
-
lhs
-
id
-
args
-
NUMERICAL_PRIMITIVES
-
INDEX_OF_INT
private static final int INDEX_OF_INT
-
-
Constructor Details
-
MethodReferenceNode
MethodReferenceNode(ReferenceNode lhs, String id, List<ExpressionNode> args)
-
-
Method Details
-
evaluate
Returns the result of evaluating this node in the given context. This result may be used as part of a further operation, for example evaluating2 + 3to 5 in order to set$xto 5 in#set ($x = 2 + 3). Or it may be used directly as part of the template output, for example evaluating replacingnamebyFredinMy name is $name..Evaluating a method expression such as
$x.foo($y)involves looking at the actual types of$xand$y. The type of$xmust have a public methodfoowith a parameter type that is compatible with$y.Currently we don't allow there to be more than one matching method. That is a difference from Velocity, which blithely allows you to invoke
List.remove(int)even though it can't really know that you didn't mean to invokeList.remove(Object)with an Object that just happens to be an Integer.The method to be invoked must be visible in a public class or interface that is either the class of
$xitself or one of its supertypes. Allowing supertypes is important because you may want to invoke a public method likeList.size()on a list whose class is not public, such as the list returned byCollections.singletonList(T). -
compatibleArgs
-
primitiveIsCompatible
-
primitiveTypeIsAssignmentCompatible
-