Package org.codehaus.groovy.ast
Class ClassHelper
- java.lang.Object
- 
- org.codehaus.groovy.ast.ClassHelper
 
- 
 public class ClassHelper extends java.lang.ObjectThis class is a Helper for ClassNode and classes handling ClassNodes. It does contain a set of predefined ClassNodes for the most used types and some code for cached ClassNode creation and basic ClassNode handling
- 
- 
Field Summary
 - 
Constructor SummaryConstructors Constructor Description ClassHelper()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static MethodNodefindSAM(ClassNode type)Returns the single abstract method of a class node, if it is a SAM type, or null otherwise.static ClassNodegetNextSuperClass(ClassNode clazz, ClassNode goalClazz)Returns a super class or interface for a given class depending on a given target.static ClassNodegetUnwrapper(ClassNode cn)static ClassNodegetWrapper(ClassNode cn)Creates a ClassNode containing the wrapper of a ClassNode of primitive type.static booleanisCachedType(ClassNode type)static booleanisNumberType(ClassNode cn)static booleanisPrimitiveType(ClassNode cn)Test to determine if a ClassNode is a primitive type.static booleanisSAMType(ClassNode type)static booleanisStaticConstantInitializerType(ClassNode cn)Test to determine if a ClassNode is a type belongs to the list of types which are allowed to initialize constants directly in bytecode instead of using <cinit>static ClassNodemake(java.lang.Class c)Creates a ClassNode using a given class.static ClassNode[]make(java.lang.Class[] classes)Creates an array of ClassNodes using an array of classes.static ClassNodemake(java.lang.Class c, boolean includeGenerics)static ClassNodemake(java.lang.String name)Creates a ClassNode using a given class.static ClassNodemakeCached(java.lang.Class c)static ClassNodemakeReference()static ClassNodemakeWithoutCaching(java.lang.Class c)static ClassNodemakeWithoutCaching(java.lang.Class c, boolean includeGenerics)static ClassNodemakeWithoutCaching(java.lang.String name)Creates a ClassNode using a given class.
 
- 
- 
- 
Field Detail- 
DYNAMIC_TYPEpublic static final ClassNode DYNAMIC_TYPE 
 - 
OBJECT_TYPEpublic static final ClassNode OBJECT_TYPE 
 - 
VOID_TYPEpublic static final ClassNode VOID_TYPE 
 - 
CLOSURE_TYPEpublic static final ClassNode CLOSURE_TYPE 
 - 
GSTRING_TYPEpublic static final ClassNode GSTRING_TYPE 
 - 
LIST_TYPEpublic static final ClassNode LIST_TYPE 
 - 
MAP_TYPEpublic static final ClassNode MAP_TYPE 
 - 
RANGE_TYPEpublic static final ClassNode RANGE_TYPE 
 - 
PATTERN_TYPEpublic static final ClassNode PATTERN_TYPE 
 - 
STRING_TYPEpublic static final ClassNode STRING_TYPE 
 - 
SCRIPT_TYPEpublic static final ClassNode SCRIPT_TYPE 
 - 
REFERENCE_TYPEpublic static final ClassNode REFERENCE_TYPE 
 - 
BINDING_TYPEpublic static final ClassNode BINDING_TYPE 
 - 
THROWABLE_TYPEpublic static final ClassNode THROWABLE_TYPE 
 - 
boolean_TYPEpublic static final ClassNode boolean_TYPE 
 - 
char_TYPEpublic static final ClassNode char_TYPE 
 - 
byte_TYPEpublic static final ClassNode byte_TYPE 
 - 
int_TYPEpublic static final ClassNode int_TYPE 
 - 
long_TYPEpublic static final ClassNode long_TYPE 
 - 
short_TYPEpublic static final ClassNode short_TYPE 
 - 
double_TYPEpublic static final ClassNode double_TYPE 
 - 
float_TYPEpublic static final ClassNode float_TYPE 
 - 
Byte_TYPEpublic static final ClassNode Byte_TYPE 
 - 
Short_TYPEpublic static final ClassNode Short_TYPE 
 - 
Integer_TYPEpublic static final ClassNode Integer_TYPE 
 - 
Long_TYPEpublic static final ClassNode Long_TYPE 
 - 
Character_TYPEpublic static final ClassNode Character_TYPE 
 - 
Float_TYPEpublic static final ClassNode Float_TYPE 
 - 
Double_TYPEpublic static final ClassNode Double_TYPE 
 - 
Boolean_TYPEpublic static final ClassNode Boolean_TYPE 
 - 
BigInteger_TYPEpublic static final ClassNode BigInteger_TYPE 
 - 
BigDecimal_TYPEpublic static final ClassNode BigDecimal_TYPE 
 - 
Number_TYPEpublic static final ClassNode Number_TYPE 
 - 
void_WRAPPER_TYPEpublic static final ClassNode void_WRAPPER_TYPE 
 - 
METACLASS_TYPEpublic static final ClassNode METACLASS_TYPE 
 - 
Iterator_TYPEpublic static final ClassNode Iterator_TYPE 
 - 
Enum_Typepublic static final ClassNode Enum_Type 
 - 
Annotation_TYPEpublic static final ClassNode Annotation_TYPE 
 - 
ELEMENT_TYPE_TYPEpublic static final ClassNode ELEMENT_TYPE_TYPE 
 - 
CLASS_Typepublic static final ClassNode CLASS_Type 
 - 
COMPARABLE_TYPEpublic static final ClassNode COMPARABLE_TYPE 
 - 
GENERATED_CLOSURE_Typepublic static final ClassNode GENERATED_CLOSURE_Type 
 - 
GROOVY_OBJECT_SUPPORT_TYPEpublic static final ClassNode GROOVY_OBJECT_SUPPORT_TYPE 
 - 
GROOVY_OBJECT_TYPEpublic static final ClassNode GROOVY_OBJECT_TYPE 
 - 
GROOVY_INTERCEPTABLE_TYPEpublic static final ClassNode GROOVY_INTERCEPTABLE_TYPE 
 - 
EMPTY_TYPE_ARRAYprotected static final ClassNode[] EMPTY_TYPE_ARRAY 
 - 
OBJECTpublic static final java.lang.String OBJECT - See Also:
- Constant Field Values
 
 
- 
 - 
Method Detail- 
makeCachedpublic static ClassNode makeCached(java.lang.Class c) 
 - 
makepublic static ClassNode[] make(java.lang.Class[] classes) Creates an array of ClassNodes using an array of classes. For each of the given classes a new ClassNode will be created- Parameters:
- classes- an array of classes used to create the ClassNodes
- Returns:
- an array of ClassNodes
- See Also:
- make(Class)
 
 - 
makepublic static ClassNode make(java.lang.Class c) Creates a ClassNode using a given class. A new ClassNode object is only created if the class is not one of the predefined ones- Parameters:
- c- class used to created the ClassNode
- Returns:
- ClassNode instance created from the given class
 
 - 
makepublic static ClassNode make(java.lang.Class c, boolean includeGenerics) 
 - 
makeWithoutCachingpublic static ClassNode makeWithoutCaching(java.lang.Class c) 
 - 
makeWithoutCachingpublic static ClassNode makeWithoutCaching(java.lang.Class c, boolean includeGenerics) 
 - 
makeWithoutCachingpublic static ClassNode makeWithoutCaching(java.lang.String name) Creates a ClassNode using a given class. Unlike make(String) this method will not use the cache to create the ClassNode. This means the ClassNode created from this method using the same name will have a different reference- Parameters:
- name- of the class the ClassNode is representing
- See Also:
- make(String)
 
 - 
makepublic static ClassNode make(java.lang.String name) Creates a ClassNode using a given class. If the name is one of the predefined ClassNodes then the corresponding ClassNode instance will be returned. If the name is null or of length 0 the dynamic type is returned- Parameters:
- name- of the class the ClassNode is representing
 
 - 
getWrapperpublic static ClassNode getWrapper(ClassNode cn) Creates a ClassNode containing the wrapper of a ClassNode of primitive type. Any ClassNode representing a primitive type should be created using the predefined types used in class. The method will check the parameter for known references of ClassNode representing a primitive type. If Reference is found, then a ClassNode will be contained that represents the wrapper class. For example for boolean, the wrapper class is java.lang.Boolean.If the parameter is no primitive type, the redirected ClassNode will be returned - Parameters:
- cn- the ClassNode containing a possible primitive type
- See Also:
- make(Class),- make(String)
 
 - 
isPrimitiveTypepublic static boolean isPrimitiveType(ClassNode cn) Test to determine if a ClassNode is a primitive type. Note: this only works for ClassNodes created using a predefined ClassNode- Parameters:
- cn- the ClassNode containing a possible primitive type
- Returns:
- true if the ClassNode is a primitive type
- See Also:
- make(Class),- make(String)
 
 - 
isStaticConstantInitializerTypepublic static boolean isStaticConstantInitializerType(ClassNode cn) Test to determine if a ClassNode is a type belongs to the list of types which are allowed to initialize constants directly in bytecode instead of using <cinit>Note: this only works for ClassNodes created using a predefined ClassNode - Parameters:
- cn- the ClassNode to be tested
- Returns:
- true if the ClassNode is of int, float, long, double or String type
- See Also:
- make(Class),- make(String)
 
 - 
isNumberTypepublic static boolean isNumberType(ClassNode cn) 
 - 
makeReferencepublic static ClassNode makeReference() 
 - 
isCachedTypepublic static boolean isCachedType(ClassNode type) 
 - 
isSAMTypepublic static boolean isSAMType(ClassNode type) 
 - 
findSAMpublic static MethodNode findSAM(ClassNode type) Returns the single abstract method of a class node, if it is a SAM type, or null otherwise.- Parameters:
- type- a type for which to search for a single abstract method
- Returns:
- the method node if type is a SAM type, null otherwise
 
 - 
getNextSuperClasspublic static ClassNode getNextSuperClass(ClassNode clazz, ClassNode goalClazz) Returns a super class or interface for a given class depending on a given target. If the target is no super class or interface, then null will be returned. For a non-primitive array type, returns an array of the componentType's super class or interface if the target is also an array.- Parameters:
- clazz- the start class
- goalClazz- the goal class
- Returns:
- the next super class or interface
 
 
- 
 
-