Class ClassHelper
ClassNode creation and type management. Contains cached instances for
all commonly used Groovy and Java types, plus factory methods for creating ClassNodes efficiently.
Provides:
- Predefined
ClassNodeconstants for primitive types, wrapper types, and common classes - Caching mechanisms to avoid creating duplicate ClassNode instances for the same class
- Factory methods for constructing ClassNodes from Java
Classor String names - Type utility methods for wrapper/unwrapper conversions and type comparisons
- Dynamic type representation for Groovy's dynamic typing system
Performance Note: ClassNodes are cached by reference for all predefined types.
Using make(Class) or make(String) returns cached instances when available,
providing O(1) lookup. Use makeWithoutCaching() only when a unique instance is needed.
Type Categories:
- Cached types: Common Java types (Object, String, Number, etc.) and all primitive types. These are pre-created once and reused for performance.
- Uncached types: Collection types (Map, List, Set) created without caching.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeDeprecated.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.protected static final ClassNode[]EmptyClassNodearray, the same instance asClassNode.EMPTY_ARRAY.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final StringBinary name ofObject, for call sites that need the name as a string.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final Class[]static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields.static final ClassNodeCanonicalClassNodeconstants for the types named by the fields. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ClassNodeProvides the dynamic type representation, used by Groovy for dynamic typing when type information is unknown.static MethodNodeReturns the single abstract method of a class node, if it is a SAM type, or null otherwise.static ClassNodegetNextSuperClass(ClassNode source, ClassNode target) Returns a super class or interface for a given class depending on supplied target.static ClassNodeMaps a wrapperClassNodeto its primitive node.static ClassNodegetWrapper(ClassNode cn) Creates a ClassNode containing the wrapper of a ClassNode of primitive type.static booleanisBigDecimalType(ClassNode type) static booleanisBigIntegerType(ClassNode type) static booleanisCachedType(ClassNode type) Tests whethertypeis identical to an entry in this class's predefinedClassNodetable.static booleanisClassType(ClassNode type) static booleanisDynamicTyped(ClassNode type) Tests whethertypecarries the dynamic-type metadata written bydynamicType().static booleanTests whethertypeis an interface andisSAMType(ClassNode)is true.static booleanisGeneratedFunction(ClassNode type) Checks if the type is a generated function, i.e.static booleanisGroovyObjectType(ClassNode type) static booleanisGStringType(ClassNode type) static booleanTests whethercnredirects to a numeric primitive or the matching wrapper.static booleanisObjectType(ClassNode type) static booleanisPrimitiveBoolean(ClassNode type) static booleanisPrimitiveByte(ClassNode type) static booleanisPrimitiveChar(ClassNode type) static booleanisPrimitiveDouble(ClassNode type) static booleanisPrimitiveFloat(ClassNode type) static booleanisPrimitiveInt(ClassNode type) static booleanisPrimitiveLong(ClassNode type) static booleanisPrimitiveShort(ClassNode type) static booleanTest to determine if a ClassNode is a primitive type.static booleanisPrimitiveVoid(ClassNode type) static booleanTests whetherfindSAM(ClassNode)finds one abstract method ontype.static booleanTest 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 booleanisStringType(ClassNode type) static booleanisWrapperBoolean(ClassNode type) static booleanisWrapperByte(ClassNode type) static booleanisWrapperCharacter(ClassNode type) static booleanisWrapperDouble(ClassNode type) static booleanisWrapperFloat(ClassNode type) static booleanisWrapperInteger(ClassNode type) static booleanisWrapperLong(ClassNode type) static booleanisWrapperShort(ClassNode type) static booleanisWrapperVoid(ClassNode type) static ClassNodeCreates a ClassNode for the given Java class, using caching when available.static ClassNode[]Creates an array of ClassNodes using an array of Java classes, using caching where available.static ClassNodeCreates a ClassNode for the given Java class, optionally including generic type parameters.static ClassNodeCreates a ClassNode for the given class name, returning cached instances for predefined types.static ClassNodemakeCached(Class c) Creates a cachedClassNodefor the given Java class.static ClassNodestatic ClassNodeCreates a new ClassNode for the given Java class without caching.static ClassNodemakeWithoutCaching(Class c, boolean includeGenerics) Creates a new ClassNode for the given Java class without caching, optionally including generic types.static ClassNodemakeWithoutCaching(String name) Creates a new ClassNode for the given class name without caching.
-
Field Details
-
TUPLE_CLASSES
-
OBJECT_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
CLOSURE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
GSTRING_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
RANGE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
PATTERN_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
STRING_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
SCRIPT_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
BINDING_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
THROWABLE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
boolean_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
char_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
byte_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
int_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
long_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
short_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
double_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
float_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Byte_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Short_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Integer_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Long_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Character_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Float_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Double_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Boolean_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
BigInteger_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
BigDecimal_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Number_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
VOID_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
void_WRAPPER_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
METACLASS_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Iterator_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Annotation_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
ELEMENT_TYPE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
AUTOCLOSEABLE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
CLONEABLE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
SERIALIZABLE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
SERIALIZEDLAMBDA_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
SEALED_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
OVERRIDE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
DEPRECATED_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
MAP_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
SET_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
LIST_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
Enum_Type
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
CLASS_Type
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
TUPLE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
STREAM_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
ITERABLE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
REFERENCE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
COLLECTION_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
COMPARABLE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
GROOVY_OBJECT_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
GENERATED_LAMBDA_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
GENERATED_CLOSURE_Type
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
GROOVY_INTERCEPTABLE_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
GROOVY_OBJECT_SUPPORT_TYPE
CanonicalClassNodeconstants for the types named by the fields. Callers reuse these instances instead of allocating a node for each comparison.OBJECT_TYPEthroughDEPRECATED_TYPEare created withmakeCached(Class).MAP_TYPEthroughGROOVY_OBJECT_SUPPORT_TYPEare created withmakeWithoutCaching(Class). The one-argument form of that factory returns the soft-cached node, so those fields are still the single cached instance of their class.VOID_TYPEis primitivevoidandvoid_WRAPPER_TYPEisVoid. -
DYNAMIC_TYPE
Deprecated.usedynamicType()when the type is unknownHistorical alias ofOBJECT_TYPE. The field does not carry the metadata flag thatisDynamicTyped(ClassNode)reads;dynamicType()produces a node that does. -
EMPTY_TYPE_ARRAY
EmptyClassNodearray, the same instance asClassNode.EMPTY_ARRAY. -
OBJECT
Binary name ofObject, for call sites that need the name as a string.- See Also:
-
-
Constructor Details
-
ClassHelper
public ClassHelper()
-
-
Method Details
-
dynamicType
Provides the dynamic type representation, used by Groovy for dynamic typing when type information is unknown. Returns a ClassNode marked with metadata indicating it represents a dynamic type.- Returns:
- a ClassNode representing the dynamic type (Object with metadata flag)
- See Also:
-
makeCached
Creates a cachedClassNodefor the given Java class. Cached instances are reused across the compilation unit, reducing memory overhead. If the cache does not contain an entry, a new ClassNode is created, cached, and returned.- Parameters:
c- the Java class to create a ClassNode for- Returns:
- a cached ClassNode for the given class
-
make
Creates an array of ClassNodes using an array of Java classes, using caching where available. Each class is converted to a ClassNode viamake(Class).- Parameters:
classes- the Java classes to convert to ClassNodes- Returns:
- an array of ClassNodes corresponding to the input classes, preserving order
- See Also:
-
make
Creates a ClassNode for the given Java class, using caching when available. Predefined types (like Integer, String, etc.) return cached instances. For first-time requests of non-predefined types, a new ClassNode is created viamakeWithoutCaching(Class).- Parameters:
c- the Java class to create a ClassNode for- Returns:
- a ClassNode representing the given class
- See Also:
-
make
Creates a ClassNode for the given Java class, optionally including generic type parameters. Predefined types return cached instances; others are created uncached.- Parameters:
c- the Java class to create a ClassNode forincludeGenerics- whether to include generic type parameters from the class definition- Returns:
- a ClassNode representing the given class
-
makeWithoutCaching
Creates a new ClassNode for the given Java class without caching. Each call creates a unique ClassNode instance, suitable for cases requiring independent instances.- Parameters:
c- the Java class to create a ClassNode for- Returns:
- a new ClassNode representing the given class (not cached)
- See Also:
-
makeWithoutCaching
Creates a new ClassNode for the given Java class without caching, optionally including generic types. Always creates a unique instance, even for predefined types.- Parameters:
c- the Java class to create a ClassNode forincludeGenerics- whether to include generic type parameters from the class- Returns:
- a new ClassNode representing the given class (not cached)
-
makeWithoutCaching
Creates a new ClassNode for the given class name without caching. Always creates a unique instance. The ClassNode is set up with Object as superclass. This is typically used for dynamically-created or parsed class names.- Parameters:
name- the fully-qualified or simple class name- Returns:
- a new ClassNode representing the named class (not cached)
- See Also:
-
make
Creates a ClassNode for the given class name, returning cached instances for predefined types. Returns the dynamic type for null or empty names. Checks both primitive names ("int", "boolean") and fully-qualified names ("java.lang.String", "java.util.Map").- Parameters:
name- the fully-qualified or simple class name, or null/empty for dynamic type- Returns:
- a ClassNode for the named class, or the dynamic type if name is null or empty
- See Also:
-
getWrapper
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:
-
getUnwrapper
Maps a wrapperClassNodeto its primitive node. The argument is replaced by itsredirect. WhenisPrimitiveType(ClassNode)is true, that redirected node is returned unchanged. Otherwise it is looked up as a wrapper and the matching primitive constant is returned. The wrappers in the table areBoolean,Byte,Character,Short,Integer,Long,Float,Double, andVoid, the last of which unwraps tovoid. A node that is neither a primitive nor one of those wrappers is returned after redirection.- Parameters:
cn- the type to unwrap; a null node is rejected- Returns:
- the primitive constant for a known wrapper, or the redirected node
- See Also:
-
isPrimitiveType
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:
-
isStaticConstantInitializerType
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:
-
isNumberType
Tests whethercnredirects to a numeric primitive or the matching wrapper. The twelve nodes arebyte,short,int,long,float,double, andByte,Short,Integer,Long,Float,Double.BigInteger,BigDecimal, andNumberare outside this test, as areboolean,char, andvoid. The wrapper checks accept a null node as a miss, and the later primitive checks dereferencecn.- Parameters:
cn- the type to test; must not be null- Returns:
truewhencnredirects to one of those twelve nodes
-
makeReference
Returns a new non-primaryClassNodeforReference. The node redirects to the cached reference type. Each call allocates a distinct node, leaving the shared reference constant unchanged.- Returns:
- a plain node whose redirect is the cached
groovy.lang.Referencetype
-
isCachedType
Tests whethertypeis identical to an entry in this class's predefinedClassNodetable. A different node with the same resolved name yieldsfalse, including a redirect whose target sits in the table.nullyieldsfalse.- Parameters:
type- the node to test, ornull- Returns:
truewhentypeis one of those instances
-
isDynamicTyped
Tests whethertypecarries the dynamic-type metadata written bydynamicType(). The flag is stored on the node, soOBJECT_TYPEand theDYNAMIC_TYPEalias yieldfalse. OnlyBoolean.TRUEcounts, andnullyieldsfalse.- Parameters:
type- the node to test, ornull- Returns:
truewhen the dynamic-type metadata isBoolean.TRUE
-
isPrimitiveBoolean
Tests whether theredirectoftypeisboolean_TYPEby identity. That constant is the cached primitivebooleannode. ABooleannode is a different type.typeis dereferenced, so a null argument is rejected.- Parameters:
type- the type to test- Returns:
truewhen the redirected node isboolean_TYPE
-
isPrimitiveChar
Tests whether theredirectoftypeischar_TYPEby identity. That constant is the cached primitivecharnode. ACharacternode is a different type.typeis dereferenced, so a null argument is rejected.- Parameters:
type- the type to test- Returns:
truewhen the redirected node ischar_TYPE
-
isPrimitiveByte
Tests whether theredirectoftypeisbyte_TYPEby identity. That constant is the cached primitivebytenode. ABytenode is a different type.typeis dereferenced, so a null argument is rejected.- Parameters:
type- the type to test- Returns:
truewhen the redirected node isbyte_TYPE
-
isPrimitiveInt
Tests whether theredirectoftypeisint_TYPEby identity. That constant is the cached primitiveintnode. AIntegernode is a different type.typeis dereferenced, so a null argument is rejected.- Parameters:
type- the type to test- Returns:
truewhen the redirected node isint_TYPE
-
isPrimitiveLong
Tests whether theredirectoftypeislong_TYPEby identity. That constant is the cached primitivelongnode. ALongnode is a different type.typeis dereferenced, so a null argument is rejected.- Parameters:
type- the type to test- Returns:
truewhen the redirected node islong_TYPE
-
isPrimitiveShort
Tests whether theredirectoftypeisshort_TYPEby identity. That constant is the cached primitiveshortnode. AShortnode is a different type.typeis dereferenced, so a null argument is rejected.- Parameters:
type- the type to test- Returns:
truewhen the redirected node isshort_TYPE
-
isPrimitiveDouble
Tests whether theredirectoftypeisdouble_TYPEby identity. That constant is the cached primitivedoublenode. ADoublenode is a different type.typeis dereferenced, so a null argument is rejected.- Parameters:
type- the type to test- Returns:
truewhen the redirected node isdouble_TYPE
-
isPrimitiveFloat
Tests whether theredirectoftypeisfloat_TYPEby identity. That constant is the cached primitivefloatnode. AFloatnode is a different type.typeis dereferenced, so a null argument is rejected.- Parameters:
type- the type to test- Returns:
truewhen the redirected node isfloat_TYPE
-
isPrimitiveVoid
Tests whether theredirectoftypeisVOID_TYPEby identity. That constant is the cached primitivevoidnode. AVoidnode is a different type.typeis dereferenced, so a null argument is rejected.- Parameters:
type- the type to test- Returns:
truewhen the redirected node isVOID_TYPE
-
isWrapperBoolean
Tests whether theredirectoftypeisBoolean_TYPEby identity.nullyieldsfalse. The primitivebooleannode is a different type.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis non-null and redirects toBoolean_TYPE
-
isWrapperCharacter
Tests whether theredirectoftypeisCharacter_TYPEby identity.nullyieldsfalse. The primitivecharnode is a different type.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis non-null and redirects toCharacter_TYPE
-
isWrapperByte
Tests whether theredirectoftypeisByte_TYPEby identity.nullyieldsfalse. The primitivebytenode is a different type.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis non-null and redirects toByte_TYPE
-
isWrapperInteger
Tests whether theredirectoftypeisInteger_TYPEby identity.nullyieldsfalse. The primitiveintnode is a different type.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis non-null and redirects toInteger_TYPE
-
isWrapperLong
Tests whether theredirectoftypeisLong_TYPEby identity.nullyieldsfalse. The primitivelongnode is a different type.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis non-null and redirects toLong_TYPE
-
isWrapperShort
Tests whether theredirectoftypeisShort_TYPEby identity.nullyieldsfalse. The primitiveshortnode is a different type.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis non-null and redirects toShort_TYPE
-
isWrapperDouble
Tests whether theredirectoftypeisDouble_TYPEby identity.nullyieldsfalse. The primitivedoublenode is a different type.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis non-null and redirects toDouble_TYPE
-
isWrapperFloat
Tests whether theredirectoftypeisFloat_TYPEby identity.nullyieldsfalse. The primitivefloatnode is a different type.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis non-null and redirects toFloat_TYPE
-
isWrapperVoid
Tests whether theredirectoftypeisvoid_WRAPPER_TYPEby identity.nullyieldsfalse. The primitivevoidnode is a different type.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis non-null and redirects tovoid_WRAPPER_TYPE
-
isBigIntegerType
Tests whethertypenamesBigInteger, usingClassNode.equals(Object)againstBigInteger_TYPE. Equality follows the resolved name, so a redirect to that name matches even when the node is not the cached constant.nullyieldsfalse.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeequalsBigInteger_TYPE
-
isBigDecimalType
Tests whethertypenamesBigDecimal, usingClassNode.equals(Object)againstBigDecimal_TYPE. Equality follows the resolved name, so a redirect to that name matches even when the node is not the cached constant.nullyieldsfalse.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeequalsBigDecimal_TYPE
-
isStringType
Tests whethertypenamesString, usingClassNode.equals(Object)againstSTRING_TYPE. Equality follows the resolved name, so a redirect to that name matches even when the node is not the cached constant.nullyieldsfalse.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeequalsSTRING_TYPE
-
isGStringType
Tests whethertypenamesGString, usingClassNode.equals(Object)againstGSTRING_TYPE. Equality follows the resolved name, so a redirect to that name matches even when the node is not the cached constant.nullyieldsfalse.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeequalsGSTRING_TYPE
-
isObjectType
Tests whethertypenamesObject, usingClassNode.equals(Object)againstOBJECT_TYPE. Equality follows the resolved name, so a plain reference to object matches, including a node fromdynamicType(). The dynamic-type metadata flag is a separate test; useisDynamicTyped(ClassNode)for it.nullyieldsfalse.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeequalsOBJECT_TYPE
-
isGroovyObjectType
Tests whethertypenamesGroovyObject, usingClassNode.equals(Object)againstGROOVY_OBJECT_TYPE. Equality follows the resolved name, so a redirect to that name matches even when the node is not the cached constant.nullyieldsfalse.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeequalsGROOVY_OBJECT_TYPE
-
isClassType
Tests whethertypenamesClass, usingClassNode.equals(Object)againstCLASS_Type. Equality follows the resolved name, so a redirect to that name matches even when the node is not the cached constant.nullyieldsfalse.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeequalsCLASS_Type
-
isSAMType
Tests whetherfindSAM(ClassNode)finds one abstract method ontype. On an interface, trait methods that already have a default implementation and methodsObjectalready declares are set aside. On an abstract class, an abstract method that already has a usable implementation on a superclass is set aside. Zero remaining methods, or more than one, means the type is not a SAM type.nullyieldsfalse.- Parameters:
type- the type to test, ornull- Returns:
truewhen exactly one abstract method remains
-
isFunctionalInterface
Tests whethertypeis an interface andisSAMType(ClassNode)is true.nullyieldsfalse. An abstract class is rejected even when it has a single abstract method, because the JVM converts a lambda only when the target is an interface.- Parameters:
type- the type to test, ornull- Returns:
truewhentypeis a non-null interface with one remaining abstract method
-
isGeneratedFunction
Checks if the type is a generated function, i.e. closure or lambda.- Since:
- 3.0.0
-
findSAM
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
-
getNextSuperClass
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.
-
dynamicType()when the type is unknown