@Delegate

Overview

NEW IN Lombok 0.10: Any field can be annotated with @Delegate to let lombok generate delegate methods that forward the call to this field.

Lombok delegates all public methods of the field's type, as well as those of its supertype except for all methods declared in java.lang.Object. You can provide a specific implementation for a method by providing you own implementation, lombok will not generate delegate methods for those already declared in the class.

You can pass any number of classes into the @Delegate annotation. If you do that, then lombok will delegate all public methods in those types (and their supertypes, except java.lang.Object) instead of looking at the field's type.

With Lombok

@HTML_PRE@

Vanilla Java

@HTML_POST@

Small print

When passing classes to the annotation, these cannot contain generics. This is a limitation of java that lombok cannot work around.

When passing classes to the annotation, these classes do not need to be supertypes of the field. See the example.