Base class for hints which use the type of a parameter of the annotated method as the signature. This can optionally use a generic type of the selected parameter as the hint. For example, imagine the following method:
void foo(A firstArg, B secondArg, Closure c) {...}
If the c closure should be { B it , then we can see that the parameter type
should be picked from the second parameter of the foo method, which is what -> ...}groovy.
lets you do.
Alternatively, the method may look like this:
void <T> foo(A<T> firstArg, B secondArg, Closure c) {...}
in which case if you want to express the fact that c should accept a <T> then you can use the
genericTypeIndex value.
This class is extended by several hint providers that make it easier to use as annotation values.
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | PickAnyArgumentHint(final int
the index of the parameter from which to extract the type parameterIndex, final int if >=0, then returns the corresponding generic type instead of the parameter type. genericTypeIndex)Creates a picker which will extract the parameterIndex-th parameter type, or its genericTypeIndex-th generic type genericTypeIndex is >=0. |
| Modifier and Type | Method and Description |
|---|---|
| public ClassNode[] | getParameterTypes(final MethodNode node, final String[] options, final SourceUnit sourceUnit, final CompilationUnit unit, final ASTNode usage)
Implements abstract groovy. |
| genericTypeIndex | back to summary |
|---|---|
| private final int genericTypeIndex | |
| parameterIndex | back to summary |
|---|---|
| private final int parameterIndex | |
| PickAnyArgumentHint | back to summary |
|---|---|
| public PickAnyArgumentHint() Creates the an argument picker which extracts the type of the first parameter. | |
| PickAnyArgumentHint | back to summary |
|---|---|
| public PickAnyArgumentHint(final int parameterIndex, final int genericTypeIndex) Creates a picker which will extract the parameterIndex-th parameter type, or its genericTypeIndex-th generic type genericTypeIndex is >=0.
| |
| getParameterTypes | back to summary |
|---|---|
| public ClassNode[] getParameterTypes(final MethodNode node, final String[] options, final SourceUnit sourceUnit, final CompilationUnit unit, final ASTNode usage) Implements abstract groovy.
| |