Overview | Package | Class | Deprecated | Index | Help
| Groovy Documentation
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.ast.tools
[Java] Class GenericsUtils

    java.lang.Object
      org.codehaus.groovy.ast.tools.GenericsUtils

    public class GenericsUtils
    extends java.lang.Object

Utility methods to deal with generic types.

Authors:
  Cedric Champeau

Field Summary
`static GenericsType[]` | `EMPTY_GENERICS_ARRAY`

Method Summary
`static GenericsType[]` | `alignGenericTypes(GenericsType[] redirectGenericTypes, GenericsType[] parameterizedTypes, GenericsType[] alignmentTarget)` Given a parameterized type and a generic type information, aligns actual type parameters.
`static GenericsType` | `buildWildcardType(ClassNode... types)` Generates a wildcard generic type in order to be used for checks against class nodes.
`static java.util.Map` | `extractPlaceholders(ClassNode cn)`
`static void` | `extractPlaceholders(ClassNode node, java.util.Map map)` For a given classnode, fills in the supplied map with the parameterized types it defines.
`static ClassNode` | `parameterizeInterfaceGenerics(ClassNode hint, ClassNode target)` Interface class nodes retrieved from ClassNode.getInterfaces or ClassNode.getAllInterfaces are returned with generic type arguments.
`static ClassNode` | `parameterizeType(ClassNode hint, ClassNode target)` Interface class nodes retrieved from ClassNode.getInterfaces or ClassNode.getAllInterfaces are returned with generic type arguments.

Methods inherited from class java.lang.Object
java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()

Field Detail

### EMPTY_GENERICS_ARRAY

    public static final GenericsType[] EMPTY_GENERICS_ARRAY

Method Detail

### alignGenericTypes

    public static GenericsType[] alignGenericTypes(GenericsType[] redirectGenericTypes, GenericsType[] parameterizedTypes, GenericsType[] alignmentTarget)

  Given a parameterized type and a generic type information, aligns actual type parameters. For example, if a class uses generic type

      <T,U,V>

  (redirectGenericTypes), is used with actual type parameters

      <java.lang.String, U,V>

  , then a class or interface using generic types

      <T,V>

  will be aligned to

      <java.lang.String,V>

  Parameters:
    `redirectGenericTypes` - the type arguments or the redirect class node
    `parameterizedTypes` - the actual type arguments used on this class node
    `alignmentTarget` - the generic type arguments to which we want to align to
  Returns:
    aligned type arguments

### buildWildcardType

    public static GenericsType buildWildcardType(ClassNode... types)

  Generates a wildcard generic type in order to be used for checks against class nodes. See GenericsType.isCompatibleWith.
  Parameters:
    `types` - the type to be used as the wildcard upper bound
  Returns:
    a wildcard generics type

### extractPlaceholders

    public static java.util.Map extractPlaceholders(ClassNode cn)

### extractPlaceholders

    public static void extractPlaceholders(ClassNode node, java.util.Map map)

  For a given classnode, fills in the supplied map with the parameterized types it defines.
  Parameters:
    node
    map

### parameterizeInterfaceGenerics

    public static ClassNode parameterizeInterfaceGenerics(ClassNode hint, ClassNode target)

  Interface class nodes retrieved from ClassNode.getInterfaces or ClassNode.getAllInterfaces are returned with generic type arguments. This method allows returning a parameterized interface given the parameterized class node which implements this interface.
  deprecated:
    Use #parameterizeType instead
  Parameters:
    `hint` - the class node where generics types are parameterized
    `target` - the interface we want to parameterize generics types
  Returns:
    a parameterized interface class node

### parameterizeType

    public static ClassNode parameterizeType(ClassNode hint, ClassNode target)

  Interface class nodes retrieved from ClassNode.getInterfaces or ClassNode.getAllInterfaces are returned with generic type arguments. This method allows returning a parameterized interface given the parameterized class node which implements this interface.
  Parameters:
    `hint` - the class node where generics types are parameterized
    `target` - the interface we want to parameterize generics types
  Returns:
    a parameterized interface class node

Groovy Documentation