public class MapEntryOrKeyValue extends ClosureSignatureHint
A special hint which handles a common use case in the Groovy methods that work on maps. In case of an iteration on a list of map entries, you often want the user to be able to work either on a Entry map entry or on a key,value pair.
The result is a closure which can have the following forms:
{ key, value ->
... }
where key is the key of a map entry, and value the corresponding value{ entry ->
... }
where entry is a Entry map entry{ ... }
where it is an implicit Entry map entryThis hint handles all those cases by picking the generics from the first argument of the method (by default).
The options array is used to modify the behavior of this hint. Each string in the option array consists of a key=value pair.
void doSomething(String str, Map<K,>V map, @ClosureParams(value=MapEntryOrKeyValue.class,options="argNum=1") Closure c) { ... }
Type Params | Return Type | Name and description |
---|---|---|
|
public List<ClassNode> |
getClosureSignatures(MethodNode node, SourceUnit sourceUnit, CompilationUnit compilationUnit, String[] options, ASTNode usage) |
Methods inherited from class | Name |
---|---|
class ClosureSignatureHint |
findClassNode, getClosureSignatures, pickGenericType, pickGenericType |