|
lombok-pg - | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||
@Target(value=METHOD) @Retention(value=SOURCE) public static @interface Builder.Extension
Use this on methods in a @Builder-annotated class to specify extensions for the generated
builder. To decide if an extension initializes required fields or not, @Builder.Extension
will look at the method name an read the fields like this:
withFullnameAndAge(final String fullname, final int age) ([<PREFIX>]<FIELD_NAME1>And<FIELD_NAME2>And..<FIELD_NAMEN>())
To allow different method names, for example if you want to prevent ambiguous method signatures, you need to specify the affected fields like this:
@Builder(fields={"fullname", "age"});
private void customMethodName(final String fullname, final int age)
Note: For this to work, the methods annotated by @Builder.Extension, need to be
private and must return void. And if you want to initialize a required field value in you own extension, you need
to set all other required initializes values too.
| Optional Element Summary | |
|---|---|
String[] |
fields
List of fields that are affected by this extension. |
public abstract String[] fields
List of fields that are affected by this extension.
This list is used to determine whether a extension initializes all required fields or not.
If no list is provided the method name is analyzed.
|
lombok-pg - | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: REQUIRED | OPTIONAL | DETAIL: ELEMENT | |||||||