Package org.codehaus.groovy.control

# Class GenericsVisitor

java.lang.Object
org.codehaus.groovy.ast.CodeVisitorSupport
org.codehaus.groovy.ast.ClassCodeVisitorSupport
org.codehaus.groovy.control.GenericsVisitor

All Implemented Interfaces:
  `GroovyClassVisitor`, `GroovyCodeVisitor`, `ErrorCollecting`

public class GenericsVisitor extends ClassCodeVisitorSupport
Verify correct usage of generics. This includes:

- class header (class and superclass declaration)
- arity of type parameters for fields, parameters, local variables
- invalid diamond `<>` usage

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GenericsVisitor(SourceUnit source)`
  Creates a visitor that validates generic type usage for one source unit.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected SourceUnit`
  `getSourceUnit()`
  Returns the source unit currently being verified.
  `void`
  `visitArrayExpression(ArrayExpression expression)`
  Validates generic usage for array element types.
  `void`
  `visitCastExpression(CastExpression expression)`
  Validates generic usage for cast target types.
  `void`
  `visitClass(ClassNode node)`
  Validates generic usage in a class header and its contents.
  `void`
  `visitConstructorCallExpression(ConstructorCallExpression expression)`
  Validates generic usage on constructor call types.
  `protected void`
  `visitConstructorOrMethod(MethodNode node, boolean isConstructor)`
  Validates generic usage for a constructor or method signature.
  `void`
  `visitDeclarationExpression(DeclarationExpression expression)`
  Validates generic usage in declared variable types.
  `void`
  `visitField(FieldNode node)`
  Validates generic usage for a field declaration.

  ### Methods inherited from class org.codehaus.groovy.ast.ClassCodeVisitorSupport

  `addError, visitAnnotation, visitAnnotations, visitAnnotations, visitAssertStatement, visitBlockStatement, visitBreakStatement, visitCaseStatement, visitCatchStatement, visitClassCodeContainer, visitClosureExpression, visitConstructor, visitContinueStatement, visitDoWhileLoop, visitExpressionStatement, visitForLoop, visitIfElse, visitImports, visitMethod, visitObjectInitializerStatements, visitPackage, visitProperty, visitReturnStatement, visitStatement, visitStatementAnnotations, visitSwitch, visitSynchronizedStatement, visitThrowStatement, visitTryCatchFinally, visitWhileLoop`

  ### Methods inherited from class org.codehaus.groovy.ast.CodeVisitorSupport

  `afterSwitchCaseStatementsVisited, afterSwitchConditionExpressionVisited, visitArgumentlistExpression, visitAttributeExpression, visitBinaryExpression, visitBitwiseNegationExpression, visitBooleanExpression, visitBytecodeExpression, visitClassExpression, visitClosureListExpression, visitConstantExpression, visitEmptyStatement, visitFieldExpression, visitGStringExpression, visitLambdaExpression, visitListExpression, visitMapEntryExpression, visitMapExpression, visitMethodCallExpression, visitMethodPointerExpression, visitMethodReferenceExpression, visitNotExpression, visitPostfixExpression, visitPrefixExpression, visitPropertyExpression, visitRangeExpression, visitShortTernaryExpression, visitSpreadExpression, visitSpreadMapExpression, visitStaticMethodCallExpression, visitTernaryExpression, visitTupleExpression, visitUnaryMinusExpression, visitUnaryPlusExpression, visitVariableExpression`

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

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

  ### Methods inherited from interface org.codehaus.groovy.ast.GroovyCodeVisitor

  `visit, visit, visitEmptyExpression, visitListOfExpressions`

- ## Constructor Details

  - ### GenericsVisitor

    public GenericsVisitor(SourceUnit source)
    Creates a visitor that validates generic type usage for one source unit.
    Parameters:
      `source` - the source unit being verified

- ## Method Details

  - ### getSourceUnit

    protected SourceUnit getSourceUnit()
    Returns the source unit currently being verified.
    Specified by:
      `getSourceUnit` in class `ClassCodeVisitorSupport`
    Returns:
      the active source unit

  - ### visitClass

    public void visitClass(ClassNode node)
    Validates generic usage in a class header and its contents.
    Specified by:
      `visitClass` in interface `GroovyClassVisitor`
    Overrides:
      `visitClass` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the class to inspect

  - ### visitField

    public void visitField(FieldNode node)
    Validates generic usage for a field declaration.
    Specified by:
      `visitField` in interface `GroovyClassVisitor`
    Overrides:
      `visitField` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the field to inspect

  - ### visitConstructorOrMethod

    protected void visitConstructorOrMethod(MethodNode node, boolean isConstructor)
    Validates generic usage for a constructor or method signature.
    Overrides:
      `visitConstructorOrMethod` in class `ClassCodeVisitorSupport`
    Parameters:
      `node` - the executable member to inspect
      `isConstructor` - whether `node` is a constructor

  - ### visitConstructorCallExpression

    public void visitConstructorCallExpression(ConstructorCallExpression expression)
    Validates generic usage on constructor call types.
    Specified by:
      `visitConstructorCallExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitConstructorCallExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the constructor call to inspect

  - ### visitDeclarationExpression

    public void visitDeclarationExpression(DeclarationExpression expression)
    Validates generic usage in declared variable types.
    Specified by:
      `visitDeclarationExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitDeclarationExpression` in class `ClassCodeVisitorSupport`
    Parameters:
      `expression` - the declaration expression to inspect

  - ### visitArrayExpression

    public void visitArrayExpression(ArrayExpression expression)
    Validates generic usage for array element types.
    Specified by:
      `visitArrayExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitArrayExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the array expression to inspect

  - ### visitCastExpression

    public void visitCastExpression(CastExpression expression)
    Validates generic usage for cast target types.
    Specified by:
      `visitCastExpression` in interface `GroovyCodeVisitor`
    Overrides:
      `visitCastExpression` in class `CodeVisitorSupport`
    Parameters:
      `expression` - the cast expression to inspect