public class ClassNodeUtils extends Object
Utility class for working with ClassNodes
| Type Params | Return Type | Name and description | 
|---|---|---|
 | 
                            public static void | 
                            addDeclaredMethodsFromAllInterfaces(ClassNode cNode, Map<String, MethodNode> methodsMap)Adds methods from interfaces and parent interfaces.  | 
                        
 | 
                            public static void | 
                            addDeclaredMethodsFromInterfaces(ClassNode cNode, Map<String, MethodNode> methodsMap)Adds methods from all interfaces.  | 
                        
 | 
                            public static ConstructorNode | 
                            addGeneratedConstructor(ClassNode classNode, int modifiers, Parameter[] parameters, ClassNode[] exceptions, Statement code)Adds a method that is marked as @Generated. | 
                        
 | 
                            public static void | 
                            addGeneratedConstructor(ClassNode classNode, ConstructorNode consNode)Adds a method that is marked as @Generated. | 
                        
 | 
                            public static void | 
                            addGeneratedInnerClass(ClassNode cNode, ClassNode inner)Adds an inner class that is marked as @Generated. | 
                        
 | 
                            public static MethodNode | 
                            addGeneratedMethod(ClassNode cNode, String name, int modifiers, ClassNode returnType, Parameter[] parameters, ClassNode[] exceptions, Statement code)Returns an existing method if one exists or else create a new method and mark it as @Generated. | 
                        
 | 
                            public static void | 
                            addGeneratedMethod(ClassNode cNode, MethodNode mNode)Adds a method and mark it as @Generated. | 
                        
 | 
                            public static void | 
                            addGeneratedMethod(ClassNode cNode, MethodNode mNode, boolean skipChecks)Adds a method and mark it as @Generated. | 
                        
 | 
                            public static String | 
                            formatTypeName(ClassNode cNode)Formats a type name into a human-readable version.  | 
                        
 | 
                            public static Map<String, MethodNode> | 
                            getDeclaredMethodsFromInterfaces(ClassNode cNode)Gets methods from all interfaces.  | 
                        
 | 
                            public static Map<String, MethodNode> | 
                            getDeclaredMethodsFromSuper(ClassNode cNode)Adds methods from the super class.  | 
                        
 | 
                            public static FieldNode | 
                            getField(ClassNode classNode, String fieldName)Searches the class for a field that matches specified name.  | 
                        
 | 
                            public static FieldNode | 
                            getField(ClassNode classNode, String fieldName, Predicate<? super FieldNode> acceptability)Searches the class for a field that matches specified name and test.  | 
                        
 | 
                            public static MethodNode | 
                            getMethod(ClassNode classNode, String methodName, Predicate<? super MethodNode> acceptability)Searches the class for a method that matches specified name and test.  | 
                        
 | 
                            public static String | 
                            getPropNameForAccessor(String accessorName)Returns the property name, e.g. age, given an accessor name, e.g. getAge.  | 
                        
 | 
                            public static PropertyNode | 
                            getStaticProperty(ClassNode cNode, String propName)Detects whether a static property with the given name is within the class or a super class.  | 
                        
 | 
                            public static boolean | 
                            hasExplicitConstructor(AbstractASTTransformation xform, ClassNode cNode)Determines if an explicit (non-generated) constructor is in the class.  | 
                        
 | 
                            public static boolean | 
                            hasNoArgConstructor(ClassNode cNode) | 
                        
 | 
                            public static boolean | 
                            hasPossibleStaticMethod(ClassNode cNode, String name, Expression arguments, boolean trySpread)Returns true if the given method has a possibly matching static method with the given name and arguments.  | 
                        
 | 
                            public static boolean | 
                            hasPossibleStaticProperty(ClassNode cNode, String methodName)Returns true if we have a static accessor  | 
                        
 | 
                            public static boolean | 
                            hasStaticProperty(ClassNode cNode, String propName) | 
                        
 | 
                            public static boolean | 
                            isCompatibleWith(ClassNode source, ClassNode target)Checks if the source ClassNode is compatible with the target ClassNode  | 
                        
 | 
                            public static boolean | 
                            isInnerClass(ClassNode cNode)Detects whether a given ClassNode is an inner class (non-static).  | 
                        
 | 
                            public static boolean | 
                            isSubtype(ClassNode maybeSuperclassOrInterface, ClassNode candidateChild) | 
                        
 | 
                            public static boolean | 
                            isValidAccessorName(String accessorName)Detects whether the given accessor name starts with "get", "set" or "is" followed by at least one character.  | 
                        
 | 
                            public static boolean | 
                            samePackageName(ClassNode first, ClassNode second)Determines if the given ClassNode values have the same package name.  | 
                        
Adds methods from interfaces and parent interfaces. Existing entries in the methods map take precedence. Methods from interfaces visited early take precedence over later ones.
cNode -  The ClassNodemethodsMap -  A map of existing methods to alterAdds methods from all interfaces. Existing entries in the methods map take precedence. Methods from interfaces visited early take precedence over later ones.
cNode -  The ClassNodemethodsMap -  A map of existing methods to alter Adds a method that is marked as @Generated.
      
 Adds a method that is marked as @Generated.
      
 Adds an inner class that is marked as @Generated.
      
 Returns an existing method if one exists or else create a new method and mark it as @Generated.
      
 Adds a method and mark it as @Generated.
      
 Adds a method and mark it as @Generated.
      
Formats a type name into a human-readable version. For arrays, appends "[]" to the formatted type name of the component. For unit class nodes, uses the class node name.
cNode -  the type to formatGets methods from all interfaces. Methods from interfaces visited early take precedence over later ones.
cNode -  The ClassNodeAdds methods from the super class.
cNode -  The ClassNodeSearches the class for a field that matches specified name.
Searches the class for a field that matches specified name and test.
Searches the class for a method that matches specified name and test.
Returns the property name, e.g. age, given an accessor name, e.g. getAge. Returns the original if a valid prefix cannot be removed.
accessorName -  the accessor name of interest, e.g. getAgeDetects whether a static property with the given name is within the class or a super class.
cNode -  the ClassNode of interestpropName -  the property nameDetermines if an explicit (non-generated) constructor is in the class.
xform -  if non-null, add an error if an explicit constructor is foundcNode -  the type of the containing classReturns true if the given method has a possibly matching static method with the given name and arguments. Handles default arguments and optionally spread expressions.
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 argumentstrue if a matching method was found.Returns true if we have a static accessor
Checks if the source ClassNode is compatible with the target ClassNode
Detects whether a given ClassNode is an inner class (non-static).
cNode -  the ClassNode of interestDetects whether the given accessor name starts with "get", "set" or "is" followed by at least one character.
accessorName -  the accessor name of interest, e.g. getAgeDetermines if the given ClassNode values have the same package name.
first -  a ClassNodesecond -  a ClassNode