diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2015-08-16 02:39:13 +0200 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2015-08-16 02:39:13 +0200 |
commit | 059d2b5304514d0ae24dd3444826d2afc315c60f (patch) | |
tree | 71ffeb8c8df3ff8c4d61c30c0dd2156e51fbe838 /src/core/lombok/Builder.java | |
parent | 41d312454aece596db215800594f0ae5457e4bfd (diff) | |
parent | e9f20501f7b59a6245cbc97af65d5124847b1733 (diff) | |
download | lombok-059d2b5304514d0ae24dd3444826d2afc315c60f.tar.gz lombok-059d2b5304514d0ae24dd3444826d2afc315c60f.tar.bz2 lombok-059d2b5304514d0ae24dd3444826d2afc315c60f.zip |
Merge branch 'builderClone'
Conflicts:
doc/changelog.markdown
Diffstat (limited to 'src/core/lombok/Builder.java')
-rw-r--r-- | src/core/lombok/Builder.java | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/src/core/lombok/Builder.java b/src/core/lombok/Builder.java index 4556bef0..0639c4cb 100644 --- a/src/core/lombok/Builder.java +++ b/src/core/lombok/Builder.java @@ -113,9 +113,40 @@ public @interface Builder { /** Name of the instance method in the builder class that creates an instance of your {@code @Builder}-annotated class. */ String buildMethodName() default "build"; - /** Name of the builder class. + /** + * Name of the builder class. + * * Default for {@code @Builder} on types and constructors: {@code (TypeName)Builder}. + * <p> * Default for {@code @Builder} on static methods: {@code (ReturnTypeName)Builder}. */ String builderClassName() default ""; + + /** + * If true, generate an instance method to obtain a builder that is initialized with the values of this instance. + * Legal only if {@code @Builder} is used on a constructor, on the type itself, or on a static method that returns + * an instance of the declaring type. + */ + boolean toBuilder() default false; + + /** + * Put on a field (in case of {@code @Builder} on a type) or a parameter (for {@code @Builder} on a constructor or static method) to + * indicate how lombok should obtain a value for this field or parameter given an instance; this is only relevant if {@code toBuilder} is {@code true}. + * + * You do not need to supply an {@code @ObtainVia} annotation unless you wish to change the default behaviour: Use a field with the same name. + * <p> + * Note that one of {@code field} or {@code method} should be set, or an error is generated. + * <p> + * The default behaviour is to obtain a value by referencing the name of the parameter as a field on 'this'. + */ + public @interface ObtainVia { + /** Tells lombok to obtain a value with the expression {@code this.value}. */ + String field() default ""; + + /** Tells lombok to obtain a value with the expression {@code this.method()}. */ + String method() default ""; + + /** Tells lombok to obtain a value with the expression {@code SelfType.method(this)}; requires {@code method} to be set. */ + boolean isStatic() default false; + } } |