Class ReferenceNode.MethodReferenceNode
- Enclosing class:
ReferenceNode
$list.size()
.-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.auto.value.processor.escapevelocity.ReferenceNode
ReferenceNode.IndexReferenceNode, ReferenceNode.MemberReferenceNode, ReferenceNode.MethodReferenceNode, ReferenceNode.PlainReferenceNode
Nested classes/interfaces inherited from class com.google.auto.value.processor.escapevelocity.ExpressionNode
ExpressionNode.BinaryExpressionNode, ExpressionNode.NotExpressionNode
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final List
<ExpressionNode> (package private) final String
private static final int
(package private) final ReferenceNode
private static final com.google.common.collect.ImmutableList
<Class<?>> Fields inherited from class com.google.auto.value.processor.escapevelocity.Node
lineNumber, resourceName
-
Constructor Summary
ConstructorsConstructorDescriptionMethodReferenceNode
(ReferenceNode lhs, String id, List<ExpressionNode> args) -
Method Summary
Modifier and TypeMethodDescription(package private) static boolean
compatibleArgs
(Class<?>[] paramTypes, List<Object> argValues) Determines if the given argument list is compatible with the given parameter types.(package private) Object
evaluate
(EvaluationContext context) Returns the result of evaluating this node in the given context.private static boolean
primitiveIsCompatible
(Class<?> primitive, Object value) (package private) static boolean
primitiveTypeIsAssignmentCompatible
(Class<?> to, Class<?> from) Methods inherited from class com.google.auto.value.processor.escapevelocity.ReferenceNode
invokeMethod, visibleMethod
Methods inherited from class com.google.auto.value.processor.escapevelocity.ExpressionNode
intValue, isDefinedAndTrue, isTrue
Methods inherited from class com.google.auto.value.processor.escapevelocity.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 + 3
to 5 in order to set$x
to 5 in#set ($x = 2 + 3)
. Or it may be used directly as part of the template output, for example evaluating replacingname
byFred
inMy name is $name.
.Evaluating a method expression such as
$x.foo($y)
involves looking at the actual types of$x
and$y
. The type of$x
must have a public methodfoo
with 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
$x
itself 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
Determines if the given argument list is compatible with the given parameter types. This includes anInteger
argument being compatible with a parameter of typeint
orlong
, for example. -
primitiveIsCompatible
-
primitiveTypeIsAssignmentCompatible
-