@Beta
@GwtCompatible
@Target(value={FIELD,METHOD})
@Documented
public @interface Delegate
interface I { def String m() } class Foo implements I { override String m() { "Foo" } } class Bar implements I { //This will generate a method m(), which calls foo.m() @Delegate val foo = new Foo }For each interface that the declaring class and the delegate have in common, an implementation for each method is added if it does not yet exist. This implementation forwards all calls directly to the delegate. You can restrict which interfaces to implement using the
Class
[] value of this
annotation. This is especially useful when there are several delegates that
have some interfaces in common.
Delegate methods can either take
Modifier and Type | Optional Element and Description |
---|---|
java.lang.Class<?>[] |
value
Optional list of interfaces that this delegate is restricted to.
|