public class ClassNodeUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
static void |
addDeclaredMethodsFromAllInterfaces(ClassNode cNode,
java.util.Map<java.lang.String,MethodNode> methodsMap)
Adds methods from interfaces and parent interfaces.
|
static void |
addDeclaredMethodsFromInterfaces(ClassNode cNode,
java.util.Map<java.lang.String,MethodNode> methodsMap)
Add in methods from all interfaces.
|
static java.lang.String |
formatTypeName(ClassNode cNode)
Formats a type name into a human readable version.
|
static java.util.Map<java.lang.String,MethodNode> |
getDeclaredMethodsFromInterfaces(ClassNode cNode)
Get methods from all interfaces.
|
static java.util.Map<java.lang.String,MethodNode> |
getDeclaredMethodsFromSuper(ClassNode cNode)
Add methods from the super class.
|
static java.lang.String |
getPropNameForAccessor(java.lang.String accessorName)
Returns the property name, e.g.
|
static PropertyNode |
getStaticProperty(ClassNode cNode,
java.lang.String propName)
Detect whether a static property with the given name is within the class
or a super class.
|
static boolean |
hasExplicitConstructor(AbstractASTTransformation xform,
ClassNode cNode)
Determine if an explicit (non-generated) constructor is in the class.
|
static boolean |
hasNoArgConstructor(ClassNode cNode) |
static boolean |
hasPossibleStaticMethod(ClassNode cNode,
java.lang.String name,
Expression arguments,
boolean trySpread)
Returns true if the given method has a possibly matching static method with the given name and arguments.
|
static boolean |
hasPossibleStaticProperty(ClassNode cNode,
java.lang.String methodName)
Return true if we have a static accessor
|
static boolean |
hasStaticProperty(ClassNode cNode,
java.lang.String propName) |
static boolean |
isInnerClass(ClassNode cNode)
Detect whether a given ClassNode is a inner class (non-static).
|
static boolean |
isValidAccessorName(java.lang.String accessorName)
Detect whether the given accessor name starts with "get", "set" or "is" followed by at least one character.
|
static boolean |
samePackageName(ClassNode first,
ClassNode second)
Determine if the given ClassNode values have the same package name.
|
public static java.lang.String formatTypeName(ClassNode cNode)
cNode
- the type to formatpublic static java.util.Map<java.lang.String,MethodNode> getDeclaredMethodsFromSuper(ClassNode cNode)
cNode
- The ClassNodepublic static void addDeclaredMethodsFromInterfaces(ClassNode cNode, java.util.Map<java.lang.String,MethodNode> methodsMap)
cNode
- The ClassNodemethodsMap
- A map of existing methods to alterpublic static java.util.Map<java.lang.String,MethodNode> getDeclaredMethodsFromInterfaces(ClassNode cNode)
cNode
- The ClassNodepublic static void addDeclaredMethodsFromAllInterfaces(ClassNode cNode, java.util.Map<java.lang.String,MethodNode> methodsMap)
cNode
- The ClassNodemethodsMap
- A map of existing methods to alterpublic static boolean hasPossibleStaticMethod(ClassNode cNode, java.lang.String name, Expression arguments, boolean trySpread)
cNode
- the ClassNode of interestname
- the name of the method of interestarguments
- the arguments to match againsttrySpread
- whether to try to account for SpreadExpressions within the argumentspublic static boolean hasPossibleStaticProperty(ClassNode cNode, java.lang.String methodName)
public static java.lang.String getPropNameForAccessor(java.lang.String accessorName)
accessorName
- the accessor name of interest, e.g. getAgepublic static boolean isValidAccessorName(java.lang.String accessorName)
accessorName
- the accessor name of interest, e.g. getAgepublic static boolean hasStaticProperty(ClassNode cNode, java.lang.String propName)
public static PropertyNode getStaticProperty(ClassNode cNode, java.lang.String propName)
cNode
- the ClassNode of interestpropName
- the property namepublic static boolean isInnerClass(ClassNode cNode)
cNode
- the ClassNode of interestpublic static boolean hasNoArgConstructor(ClassNode cNode)
public static boolean hasExplicitConstructor(AbstractASTTransformation xform, ClassNode cNode)
xform
- if non null, add an error if an explicit constructor is foundcNode
- the type of the containing classpublic static boolean samePackageName(ClassNode first, ClassNode second)
first
- a ClassNodesecond
- a ClassNodejava.lang.NullPointerException
- if either of the given nodes are null