Top Description Methods
org.eclipse.xtend.lib.annotations

public @Interface Delegate

extends Annotation
Annotations
@Beta
@GwtCompatible
@Target:FIELD, METHOD
@Active:DelegateProcessor
@Documented
@SuppressWarnings:all
Imports
com.google.common.annotations.Beta, .GwtCompatible, java.lang.annotation.Documented, .ElementType, .Target, org.eclipse.xtend.lib.macro.Active

Implements interfaces by forwarding method calls to an annotated field or method.

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 This allows you to generate meaningful error messages or to dynamically dispatch based on the arguments.
Since
2.7

Method Summary

Modifier and TypeMethod and Description
public Class<?>[]
value()

Optional list of interfaces that this delegate is restricted to.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public Class<?>[] value()

Optional list of interfaces that this delegate is restricted to. Defaults to the common interfaces of the context type and the annotated element.