ClassHelper (Groovy 5.0.6)

Package: org.codehaus.groovy.ast

## [Java] Class ClassHelper

- org.codehaus.groovy.ast.ClassHelper

-     public class ClassHelper
      extends Object

  Helper for ClassNode and classes handling them. Contains a set of pre-defined instances for the most used types and some code for cached node creation and basic handling.

- - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static ClassNode` | `DYNAMIC_TYPE` |
    `protected static ClassNode[]` | `EMPTY_TYPE_ARRAY` |
    `static String` | `OBJECT` |
    `static ClassNode` | `OBJECT_TYPE` |
    `static Class[]` | `TUPLE_CLASSES` |

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static ClassNode` | `dynamicType()`
    `` | `public static MethodNode` | `findSAM(ClassNode type)` Returns the single abstract method of a class node, if it is a SAM type, or null otherwise.
    `` | `public static ClassNode` | `getNextSuperClass(ClassNode source, ClassNode target)` Returns a super class or interface for a given class depending on supplied target.
    `` | `public static ClassNode` | `getUnwrapper(ClassNode cn)`
    `` | `public static ClassNode` | `getWrapper(ClassNode cn)` Creates a ClassNode containing the wrapper of a ClassNode of primitive type.
    `` | `public static boolean` | `isBigDecimalType(ClassNode type)`
    `` | `public static boolean` | `isBigIntegerType(ClassNode type)`
    `` | `public static boolean` | `isCachedType(ClassNode type)`
    `` | `public static boolean` | `isClassType(ClassNode type)`
    `` | `public static boolean` | `isDynamicTyped(ClassNode type)`
    `` | `public static boolean` | `isFunctionalInterface(ClassNode type)`
    `` | `public static boolean` | `isGStringType(ClassNode type)`
    `` | `public static boolean` | `isGeneratedFunction(ClassNode type)` Checks if the type is a generated function, i.e. closure or lambda.
    `` | `public static boolean` | `isGroovyObjectType(ClassNode type)`
    `` | `public static boolean` | `isNumberType(ClassNode cn)`
    `` | `public static boolean` | `isObjectType(ClassNode type)`
    `` | `public static boolean` | `isPrimitiveBoolean(ClassNode type)`
    `` | `public static boolean` | `isPrimitiveByte(ClassNode type)`
    `` | `public static boolean` | `isPrimitiveChar(ClassNode type)`
    `` | `public static boolean` | `isPrimitiveDouble(ClassNode type)`
    `` | `public static boolean` | `isPrimitiveFloat(ClassNode type)`
    `` | `public static boolean` | `isPrimitiveInt(ClassNode type)`
    `` | `public static boolean` | `isPrimitiveLong(ClassNode type)`
    `` | `public static boolean` | `isPrimitiveShort(ClassNode type)`
    `` | `public static boolean` | `isPrimitiveType(ClassNode cn)` Test to determine if a ClassNode is a primitive type.
    `` | `public static boolean` | `isPrimitiveVoid(ClassNode type)`
    `` | `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>
    `` | `public static boolean` | `isStringType(ClassNode type)`
    `` | `public static boolean` | `isWrapperBoolean(ClassNode type)`
    `` | `public static boolean` | `isWrapperByte(ClassNode type)`
    `` | `public static boolean` | `isWrapperCharacter(ClassNode type)`
    `` | `public static boolean` | `isWrapperDouble(ClassNode type)`
    `` | `public static boolean` | `isWrapperFloat(ClassNode type)`
    `` | `public static boolean` | `isWrapperInteger(ClassNode type)`
    `` | `public static boolean` | `isWrapperLong(ClassNode type)`
    `` | `public static boolean` | `isWrapperShort(ClassNode type)`
    `` | `public static boolean` | `isWrapperVoid(ClassNode type)`
    `` | `public static ClassNode[]` | `make(Class[] classes)` Creates an array of ClassNodes using an array of classes.
    `` | `public static ClassNode` | `make(Class c)` Creates a ClassNode using a given class.
    `` | `public static ClassNode` | `make(Class c, boolean includeGenerics)`
    `` | `public static ClassNode` | `make(String name)` Creates a ClassNode using a given class.
    `` | `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.

  - ### Inherited Methods Summary

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

- - ### Field Detail

    - #### @Deprecated
      public static final ClassNode DYNAMIC_TYPE

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

    - #### public static final String OBJECT

    - #### public static final ClassNode OBJECT_TYPE

    - #### public static final Class[] TUPLE_CLASSES

  - ### Method Detail

    - #### public static ClassNode dynamicType()

    - #### 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 source, ClassNode target)

      Returns a super class or interface for a given class depending on supplied target. If the target is not a super class or interface, then null will be returned. For a non-primitive array type -- if the target is also an array -- returns an array of the component type's 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 isBigDecimalType(ClassNode type)

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

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

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

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

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

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

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

      Checks if the type is a generated function, i.e. closure or lambda.

      Since:
        3.0.0

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

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

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

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

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

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

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

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

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

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

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

    - #### 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 isPrimitiveVoid(ClassNode type)

    - #### 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 boolean isStringType(ClassNode type)

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

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

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

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

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

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

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

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

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

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