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
abstract class ReferenceNode extends ExpressionNode
A node in the parse tree that is a reference. A reference is anything beginning with$, such as$xor$x[$i].foo($j).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static classReferenceNode.IndexReferenceNodeA node in the parse tree that is an indexing of a reference, like$x[0]or$x.foo[$i].(package private) static classReferenceNode.MemberReferenceNodeA node in the parse tree that is a reference to a property of another reference, like$x.fooor$x[$i].foo.(package private) static classReferenceNode.MethodReferenceNodeA node in the parse tree representing a method reference, like$list.size().(package private) static classReferenceNode.PlainReferenceNodeA 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
Fields Modifier and Type Field Description private static java.lang.reflect.MethodCLASS_GET_MODULE_METHODprivate static java.lang.reflect.MethodMODULE_IS_EXPORTED_METHODprivate static java.lang.StringTHIS_PACKAGE-
Fields inherited from class com.google.auto.value.processor.escapevelocity.Node
lineNumber, resourceName
-
-
Constructor Summary
Constructors Constructor Description ReferenceNode(java.lang.String resourceName, int lineNumber)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private static booleanclassIsExported(java.lang.Class<?> c)private static booleanclassIsPublic(java.lang.Class<?> c)Returns whether the given class is public as seen from this class.(package private) java.lang.ObjectinvokeMethod(java.lang.reflect.Method method, java.lang.Object target, java.util.List<java.lang.Object> argValues)Invoke the given method on the given target with the given arguments.private static java.lang.StringpackageNameOf(java.lang.Class<?> c)(package private) static java.lang.reflect.MethodvisibleMethod(java.lang.reflect.Method method, java.lang.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
-
-
-
-
Method Detail
-
invokeMethod
java.lang.Object invokeMethod(java.lang.reflect.Method method, java.lang.Object target, java.util.List<java.lang.Object> argValues)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
private static java.lang.String packageNameOf(java.lang.Class<?> c)
-
visibleMethod
static java.lang.reflect.Method visibleMethod(java.lang.reflect.Method method, java.lang.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. 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
private static boolean classIsPublic(java.lang.Class<?> c)
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
private static boolean classIsExported(java.lang.Class<?> c)
-
-