Package: org.codehaus.groovy.ast

## [Java] Class GenericsType

- org.codehaus.groovy.ast.GenericsType

-     public class GenericsType
      extends ASTNode

  Represents generic type information for parameterized types in Groovy/Java, including type variables, wildcard types, and type bounds. Supports placeholders for type parameters, wildcards with upper/lower bounds, and tracks resolution state for multi-phase compilation. Provides compatibility checking for generic type constraints.

  See Also:
    ClassNode
    GenericsTypeName

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `GenericsType.GenericsTypeName` | Represents the name of a GenericsType for use as a map key or in generic type comparisons.

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static GenericsType[]` | `EMPTY_ARRAY` |

  - ### Constructor Summary

    Constructors
    Constructor and description
    `GenericsType(ClassNode type, ClassNode[] upperBounds, ClassNode lowerBound)` Creates a generics type with optional upper and lower bounds.
    `GenericsType(ClassNode basicType)` Creates a simple generics type with no bounds for a concrete type.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public ClassNode` | `getLowerBound()` Returns the lower bound for this wildcard type (e.g., Bound in "?
    `` | `public String` | `getName()` Returns the name of this generic type.
    `` | `public ClassNode` | `getType()` Returns the underlying ClassNode for this generic type.
    `` | `public ClassNode[]` | `getUpperBounds()` Returns the upper bounds for this wildcard or placeholder type (e.g., `Bound` in {@code ?
    `` | `public boolean` | `isCompatibleWith(ClassNode classNode)` Determines if the provided type is compatible with this generic type specification.
    `` | `public boolean` | `isPlaceholder()` Returns true if this generic type represents a type variable placeholder (e.g., T in <T>).
    `` | `public boolean` | `isResolved()` Returns true if this generic type has been resolved during compilation phases.
    `` | `public boolean` | `isWildcard()` Returns true if this generic type represents a wildcard (e.g., ?
    `` | `public void` | `setName(String name)` Sets the name of this generic type.
    `` | `public void` | `setPlaceholder(boolean placeholder)` Marks this generic type as a placeholder type variable.
    `` | `public void` | `setResolved(boolean resolved)` Marks this generic type as resolved.
    `` | `public void` | `setType(ClassNode type)` Sets the underlying ClassNode for this generic type.
    `` | `public void` | `setWildcard(boolean wildcard)` Marks this generic type as a wildcard.
    `` | `public String` | `toString()`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Field Detail

    - #### public static final GenericsType[] EMPTY_ARRAY

  - ### Constructor Detail

    - #### public GenericsType(ClassNode type, ClassNode[] upperBounds, ClassNode lowerBound)

      Creates a generics type with optional upper and lower bounds. The type is marked as a placeholder if the provided type is a generics placeholder.

      Parameters:
        `type` - the ClassNode representing the main generic type (never null)
        `upperBounds` - optional array of upper bound ClassNodes (e.g., for "? extends Bound" or "T extends Bound")
        `lowerBound` - optional lower bound ClassNode (e.g., for "? super Bound")

    - #### public GenericsType(ClassNode basicType)

      Creates a simple generics type with no bounds for a concrete type.

      Parameters:
        `basicType` - the ClassNode representing the concrete type (never null)

  - ### Method Detail

    - #### public ClassNode getLowerBound()

      Returns the lower bound for this wildcard type (e.g., Bound in "? super Bound"), or null if this is not a lower-bounded wildcard.

      Returns:
        the lower bound ClassNode, or null

    - #### public String getName()

      Returns the name of this generic type. For wildcard types, returns "?"; otherwise returns the type name.

      Returns:
        the type name

    - #### public ClassNode getType()

      Returns the underlying ClassNode for this generic type.

      Returns:
        the type

    - #### public ClassNode[] getUpperBounds()

      Returns the upper bounds for this wildcard or placeholder type (e.g., `Bound` in `? extends Bound` or `Bound1 & Bound2` in `T extends Bound1 & Bound2`), or null if this type has no upper bounds.

      Returns:
        array of upper bound ClassNodes, or null

    - #### public boolean isCompatibleWith(ClassNode classNode)

      Determines if the provided type is compatible with this generic type specification. The check is complete and recursive, including nested generic parameters. Accounts for wildcards, placeholders, bounds, and generic type covariance rules.

      Parameters:
        `classNode` - the ClassNode to check for compatibility
      Returns:
        true if classNode satisfies this generic type specification

    - #### public boolean isPlaceholder()

      Returns true if this generic type represents a type variable placeholder (e.g., T in <T>).

      Returns:
        true if this is a placeholder type variable

    - #### public boolean isResolved()

      Returns true if this generic type has been resolved during compilation phases.

      Returns:
        true if resolved

    - #### public boolean isWildcard()

      Returns true if this generic type represents a wildcard (e.g., ? or ? extends/super Bound).

      Returns:
        true if this is a wildcard type

    - #### public void setName(String name)

      Sets the name of this generic type.

      throws:
        NullPointerException if name is null
      Parameters:
        `name` - the type name (never null)

    - #### public void setPlaceholder(boolean placeholder)

      Marks this generic type as a placeholder type variable. Setting to true also sets resolved=true and clears the wildcard flag, since placeholders and wildcards are mutually exclusive.

      Parameters:
        `placeholder` - true to mark as a placeholder

    - #### public void setResolved(boolean resolved)

      Marks this generic type as resolved. Setting to true also implicitly sets resolved=true.

      Parameters:
        `resolved` - true to mark as resolved

    - #### public void setType(ClassNode type)

      Sets the underlying ClassNode for this generic type.

      throws:
        NullPointerException if type is null
      Parameters:
        `type` - the ClassNode to set (never null)

    - #### public void setWildcard(boolean wildcard)

      Marks this generic type as a wildcard. Clears the placeholder flag if set, since wildcards and placeholders are mutually exclusive.

      Parameters:
        `wildcard` - true to mark as a wildcard

    - #### public String toString()