Class ReferenceNode
java.lang.Object
com.google.auto.value.processor.escapevelocity.Node
com.google.auto.value.processor.escapevelocity.ExpressionNode
com.google.auto.value.processor.escapevelocity.ReferenceNode
- Direct Known Subclasses:
ReferenceNode.IndexReferenceNode
,ReferenceNode.MemberReferenceNode
,ReferenceNode.MethodReferenceNode
,ReferenceNode.PlainReferenceNode
A node in the parse tree that is a reference. A reference is anything beginning with
$
,
such as $x
or $x[$i].foo($j)
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
A node in the parse tree that is an indexing of a reference, like$x[0]
or$x.foo[$i]
.(package private) static class
A node in the parse tree that is a reference to a property of another reference, like$x.foo
or$x[$i].foo
.(package private) static class
A node in the parse tree representing a method reference, like$list.size()
.(package private) static class
A node in the parse tree that is a plain reference such as$x
.Nested classes/interfaces inherited from class com.google.auto.value.processor.escapevelocity.ExpressionNode
ExpressionNode.BinaryExpressionNode, ExpressionNode.NotExpressionNode
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Method
private static final Method
private static final String
Fields inherited from class com.google.auto.value.processor.escapevelocity.Node
lineNumber, resourceName
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static boolean
classIsExported
(Class<?> c) private static boolean
classIsPublic
(Class<?> c) Returns whether the given class is public as seen from this class.(package private) Object
invokeMethod
(Method method, Object target, List<Object> argValues) Invoke the given method on the given target with the given arguments.private static String
packageNameOf
(Class<?> c) (package private) static Method
visibleMethod
(Method method, Class<?> in) Returns a Method with the same name and parameter types as the given one, but that is in a public class or interface.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, evaluate, evaluationException, evaluationException
-
Field Details
-
THIS_PACKAGE
-
CLASS_GET_MODULE_METHOD
-
MODULE_IS_EXPORTED_METHOD
-
-
Constructor Details
-
ReferenceNode
ReferenceNode(String resourceName, int lineNumber)
-
-
Method Details
-
invokeMethod
Invoke the given method on the given target with the given arguments. The method is expected to be public, but the class it is in might not be. In that case we will search up the hierarchy for an ancestor that is public and has the same method, and use that to invoke the method. Otherwise we would get anIllegalAccessException
. More than one ancestor might define the method, but it doesn't matter which one we invoke since ultimately the code that will run will be the same. -
packageNameOf
-
visibleMethod
Returns a Method with the same name and parameter types as the given one, but that is in a public class or interface. This might be the given method, or it might be a method in a superclass or superinterface.- Returns:
- a public method in a public class or interface, or null if none was found.
-
classIsPublic
Returns whether the given class is public as seen from this class. Prior to Java 9, a class was either public or not public. But with the introduction of modules in Java 9, a class can be marked public and yet not be visible, if it is not exported from the module it appears in. So, on Java 9, we perform an additional check on classc
, which is effectivelyc.getModule().isExported(c.getPackageName())
. We use reflection so that the code can compile on earlier Java versions. -
classIsExported
-