diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-11-25 12:55:13 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2010-11-25 12:55:13 +0100 |
commit | 3c092da93ada3bd99b04b37633fb844a14b8c132 (patch) | |
tree | fccbb94069f9d118dcebf26a663020bae78530e7 /src/core/lombok/Delegate.java | |
parent | c340c9c24f45b7007ed04fb5ce9e1f1819e8e0ba (diff) | |
download | lombok-3c092da93ada3bd99b04b37633fb844a14b8c132.tar.gz lombok-3c092da93ada3bd99b04b37633fb844a14b8c132.tar.bz2 lombok-3c092da93ada3bd99b04b37633fb844a14b8c132.zip |
Documented @Delegate with javadoc.
Diffstat (limited to 'src/core/lombok/Delegate.java')
-rw-r--r-- | src/core/lombok/Delegate.java | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/core/lombok/Delegate.java b/src/core/lombok/Delegate.java index 9056dada..4308f6f9 100644 --- a/src/core/lombok/Delegate.java +++ b/src/core/lombok/Delegate.java @@ -26,8 +26,27 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Put on any field to make lombok generate delegate methods that forward the call to this field. + * + * Example: + * <pre> + * private @Delegate List<String> foo; + * </pre> + * + * will generate for example an {@code boolean add(String)} method, which contains: {@code return foo.add(arg);}, as well as all other methods in {@code List}. + * + * All public instance methods of the field's type, as well as all public instance methods of all the field's type's superfields are delegated, except for all methods + * that exist in {@link java.lang.Object}, and except for methods that are already present in the class. + */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.SOURCE) public @interface Delegate { + /** + * Normally the type of the field is used as delegate type. However, to choose a different type to delegate, you can list one (or more) types here. Note that types with + * type arguments can only be done as a field type. A solution for this is to create a private inner interface/class with the appropriate types extended, and possibly + * with all methods you'd like to delegate listed, and then supply that class here. The field does not actually have to implement the type you're delegating; the + * type listed here is used only to determine which delegate methods to generate. + */ Class<?>[] value() default {}; } |