ClassHelper (groovy 2.4.14 API)
Date: 2018-02-24

Package: org.codehaus.groovy.ast

## [Java] Class ClassHelper

- org.codehaus.groovy.ast.ClassHelper

- This 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

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static ClassNode` | `Annotation_TYPE` |
    `static ClassNode` | `BINDING_TYPE` |
    `static ClassNode` | `BigDecimal_TYPE` |
    `static ClassNode` | `BigInteger_TYPE` |
    `static ClassNode` | `Boolean_TYPE` |
    `static ClassNode` | `Byte_TYPE` |
    `static ClassNode` | `CLASS_Type` |
    `static ClassNode` | `CLOSURE_TYPE` |
    `static ClassNode` | `COMPARABLE_TYPE` |
    `static ClassNode` | `Character_TYPE` |
    `static ClassNode` | `DYNAMIC_TYPE` |
    `static ClassNode` | `Double_TYPE` |
    `static ClassNode` | `ELEMENT_TYPE_TYPE` |
    `protected static ClassNode[]` | `EMPTY_TYPE_ARRAY` |
    `static ClassNode` | `Enum_Type` |
    `static ClassNode` | `Float_TYPE` |
    `static ClassNode` | `GENERATED_CLOSURE_Type` |
    `static ClassNode` | `GROOVY_INTERCEPTABLE_TYPE` |
    `static ClassNode` | `GROOVY_OBJECT_SUPPORT_TYPE` |
    `static ClassNode` | `GROOVY_OBJECT_TYPE` |
    `static ClassNode` | `GSTRING_TYPE` |
    `static ClassNode` | `Integer_TYPE` |
    `static ClassNode` | `Iterator_TYPE` |
    `static ClassNode` | `LIST_TYPE` |
    `static ClassNode` | `Long_TYPE` |
    `static ClassNode` | `MAP_TYPE` |
    `static ClassNode` | `METACLASS_TYPE` |
    `static ClassNode` | `Number_TYPE` |
    `static String` | `OBJECT` |
    `static ClassNode` | `OBJECT_TYPE` |
    `static ClassNode` | `PATTERN_TYPE` |
    `static ClassNode` | `RANGE_TYPE` |
    `static ClassNode` | `REFERENCE_TYPE` |
    `static ClassNode` | `SCRIPT_TYPE` |
    `static ClassNode` | `STRING_TYPE` |
    `static ClassNode` | `Short_TYPE` |
    `static ClassNode` | `VOID_TYPE` |
    `static ClassNode` | `boolean_TYPE` |
    `static ClassNode` | `byte_TYPE` |
    `static ClassNode` | `char_TYPE` |
    `static ClassNode` | `double_TYPE` |
    `static ClassNode` | `float_TYPE` |
    `static ClassNode` | `int_TYPE` |
    `static ClassNode` | `long_TYPE` |
    `static ClassNode` | `short_TYPE` |
    `static ClassNode` | `void_WRAPPER_TYPE` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static MethodNode` | `findSAM(ClassNode type)` Returns the single abstract method of a class node, if it is a SAM type, or null otherwise.
    `` | `static ClassNode` | `getNextSuperClass(ClassNode clazz, ClassNode goalClazz)` Returns a super class or interface for a given class depending on a given target.
    `` | `static ClassNode` | `getUnwrapper(ClassNode cn)`
    `` | `static ClassNode` | `getWrapper(ClassNode cn)` Creates a ClassNode containing the wrapper of a ClassNode of primitive type.
    `` | `static boolean` | `isCachedType(ClassNode type)`
    `` | `static boolean` | `isNumberType(ClassNode cn)`
    `` | `static boolean` | `isPrimitiveType(ClassNode cn)` Test to determine if a ClassNode is a primitive type.
    `` | `static boolean` | `isSAMType(ClassNode type)`
    `` | `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>
    `` | `static ClassNode[]` | `make(Class[] classes)` Creates an array of ClassNodes using an array of classes.
    `` | `static ClassNode` | `make(Class c)` Creates a ClassNode using a given class.
    `` | `static ClassNode` | `make(Class c, boolean includeGenerics)`
    `` | `static ClassNode` | `make(String name)` Creates a ClassNode using a given class.
    `` | `static ClassNode` | `makeCached(Class c)`
    `` | `static ClassNode` | `makeReference()`
    `` | `static ClassNode` | `makeWithoutCaching(Class c)`
    `` | `static ClassNode` | `makeWithoutCaching(Class c, boolean includeGenerics)`
    `` | `static ClassNode` | `makeWithoutCaching(String name)` Creates a ClassNode using a given class.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll`

- - ### Field Detail

    - #### public static final ClassNode Annotation_TYPE

    - #### public static final ClassNode BINDING_TYPE

    - #### public static final ClassNode BigDecimal_TYPE

    - #### public static final ClassNode BigInteger_TYPE

    - #### public static final ClassNode Boolean_TYPE

    - #### public static final ClassNode Byte_TYPE

    - #### public static final ClassNode CLASS_Type

    - #### public static final ClassNode CLOSURE_TYPE

    - #### public static final ClassNode COMPARABLE_TYPE

    - #### public static final ClassNode Character_TYPE

    - #### public static final ClassNode DYNAMIC_TYPE

    - #### public static final ClassNode Double_TYPE

    - #### public static final ClassNode ELEMENT_TYPE_TYPE

    - #### protected static final ClassNode[] EMPTY_TYPE_ARRAY

    - #### public static final ClassNode Enum_Type

    - #### public static final ClassNode Float_TYPE

    - #### public static final ClassNode GENERATED_CLOSURE_Type

    - #### public static final ClassNode GROOVY_INTERCEPTABLE_TYPE

    - #### public static final ClassNode GROOVY_OBJECT_SUPPORT_TYPE

    - #### public static final ClassNode GROOVY_OBJECT_TYPE

    - #### public static final ClassNode GSTRING_TYPE

    - #### public static final ClassNode Integer_TYPE

    - #### public static final ClassNode Iterator_TYPE

    - #### public static final ClassNode LIST_TYPE

    - #### public static final ClassNode Long_TYPE

    - #### public static final ClassNode MAP_TYPE

    - #### public static final ClassNode METACLASS_TYPE

    - #### public static final ClassNode Number_TYPE

    - #### public static final String OBJECT

    - #### public static final ClassNode OBJECT_TYPE

    - #### public static final ClassNode PATTERN_TYPE

    - #### public static final ClassNode RANGE_TYPE

    - #### public static final ClassNode REFERENCE_TYPE

    - #### public static final ClassNode SCRIPT_TYPE

    - #### public static final ClassNode STRING_TYPE

    - #### public static final ClassNode Short_TYPE

    - #### public static final ClassNode VOID_TYPE

    - #### public static final ClassNode boolean_TYPE

    - #### public static final ClassNode byte_TYPE

    - #### public static final ClassNode char_TYPE

    - #### public static final ClassNode double_TYPE

    - #### public static final ClassNode float_TYPE

    - #### public static final ClassNode int_TYPE

    - #### public static final ClassNode long_TYPE

    - #### public static final ClassNode short_TYPE

    - #### public static final ClassNode void_WRAPPER_TYPE

  - ### Method Detail

    - #### public 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

    - #### public 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

    - #### public static ClassNode getUnwrapper(ClassNode cn)

    - #### public 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)

    - #### public static boolean isCachedType(ClassNode type)

    - #### public static boolean isNumberType(ClassNode cn)

    - #### public 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)

    - #### public static boolean isSAMType(ClassNode type)

    - #### public 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)

    - #### public static ClassNode[] make(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)

    - #### public static ClassNode make(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

    - #### public static ClassNode make(Class c, boolean includeGenerics)

    - #### public static ClassNode make(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

    - #### public static ClassNode makeCached(Class c)

    - #### public static ClassNode makeReference()

    - #### public static ClassNode makeWithoutCaching(Class c)

    - #### public static ClassNode makeWithoutCaching(Class c, boolean includeGenerics)

    - #### public static ClassNode makeWithoutCaching(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)