Package org.apache.groovy.ast.tools

# Class TypeUseUtils

java.lang.Object
org.apache.groovy.ast.tools.TypeUseUtils

public final class TypeUseUtils extends Object
Classification of a `ClassNode` as a type use (JLS 4.5, 4.7, 4.8). Distinct from a generic class declaration, whose `ClassNode.getGenericsTypes()` are the formals.

Since:
  6.0.0

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static String`
  `describeTypeUse(ClassNode type)`
  Source-like display of a type use, including rare enclosing arguments (`Outer<String>.Inner`) and array brackets.
  `static boolean`
  `hasWildcardTypeArgument(ClassNode type)`
  True when a type argument of `type` or an enclosing rare type is a wildcard.
  `static boolean`
  `isParameterizedEnclosingType(ClassNode type)`
  True when `type` carries type arguments, including wildcards (`Outer<?>`).
  `static boolean`
  `isParameterizedTypeUsage(ClassNode type)`
  True when `type` is a parameterized usage (`Cell<String>`), as opposed to the generic type name (`Cell`) or the class declaration node (whose `ClassNode.getGenericsTypes()` are the formals).
  `static boolean`
  `isParameterizedTypeUsageIncludingEnclosing(ClassNode type)`
  True when `type` or any enclosing rare type is a parameterized usage.
  `static boolean`
  `isRawGenericType(ClassNode type)`
  True when `type` is a raw use of a generic declaration (`Outer` for `class Outer<T>`).
  `static boolean`
  `isReifiable(ClassNode type)`
  JLS 4.7: types available in full at run time.
  `static boolean`
  `isStaticMemberType(ClassNode type)`
  Nested interfaces and enums are implicitly static; otherwise the `ACC_STATIC` bit on the declaration is authoritative.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### isParameterizedTypeUsage

    public static boolean isParameterizedTypeUsage(ClassNode type)
    True when `type` is a parameterized usage (`Cell<String>`), as opposed to the generic type name (`Cell`) or the class declaration node (whose `ClassNode.getGenericsTypes()` are the formals).

  - ### isParameterizedTypeUsageIncludingEnclosing

    public static boolean isParameterizedTypeUsageIncludingEnclosing(ClassNode type)
    True when `type` or any enclosing rare type is a parameterized usage. Used for class literals (JLS 15.8.2): `Outer<String>.Inner.class`. Declaration formals on `Map` must not make `Map.Entry` a class-literal error.

  - ### isParameterizedEnclosingType

    public static boolean isParameterizedEnclosingType(ClassNode type)
    True when `type` carries type arguments, including wildcards (`Outer<?>`). Raw names (`Outer`) are not parameterized. Unlike `isParameterizedTypeUsage(ClassNode)`, this does not require a redirect node: an enclosing type on a nested use may still be the parser's unresolved node.

  - ### isRawGenericType

    public static boolean isRawGenericType(ClassNode type)
    True when `type` is a raw use of a generic declaration (`Outer` for `class Outer<T>`).

  - ### isReifiable

    public static boolean isReifiable(ClassNode type)
    JLS 4.7: types available in full at run time. Used for array creation (JLS 15.10.1) and `instanceof` (JLS 15.20.2).

  - ### isStaticMemberType

    public static boolean isStaticMemberType(ClassNode type)
    Nested interfaces and enums are implicitly static; otherwise the `ACC_STATIC` bit on the declaration is authoritative.

  - ### hasWildcardTypeArgument

    public static boolean hasWildcardTypeArgument(ClassNode type)
    True when a type argument of `type` or an enclosing rare type is a wildcard.

  - ### describeTypeUse

    public static String describeTypeUse(ClassNode type)
    Source-like display of a type use, including rare enclosing arguments (`Outer<String>.Inner`) and array brackets.