@Documented
@Retention(value=RUNTIME)
@Target(value=PARAMETER)
public @interface DelegatesTo
This annotation can also be used to help the type checker (TypeChecked
)
which would not report errors then if the delegate is of the documented type. Of course, it is
also compatible with CompileStatic
.
Example:
// Document the fact that the delegate of the closure will be an ExecSpec ExecResult exec(@DelegatesTo(ExecSpec) Closure closure) { ... }
Modifier and Type | Optional Element and Description |
---|---|
int |
genericTypeIndex |
int |
strategy |
java.lang.String |
target |
java.lang.String |
type
The type member should be used when the type of the delagate cannot
be represented with
value() , genericTypeIndex() or
target() . |
java.lang.Class |
value |
public abstract java.lang.Class value
public abstract int strategy
public abstract int genericTypeIndex
public abstract java.lang.String target
public abstract java.lang.String type
value()
, genericTypeIndex()
or
target()
. In this case, it is possible to use a String to represent
the type, at the cost of potential uncatched errors at compile time if the
type is invalid and increased compile time.