From d41ef4bf8370a16121d00146f905e866ac7e5a0b Mon Sep 17 00:00:00 2001
From: Roel Spilker MapEntry.of("foo", 5)
instead of the much longer
new MapEntry<String, Integer>("foo", 5)
.
- To put annotations on the generated constructor, you can use onConstructor=@_({@AnnotationsHere})
, but be careful; this is an experimental feature. For more details see the documentation on the onX feature.
+ To put annotations on the generated constructor, you can use onConstructor=@__({@AnnotationsHere})
, but be careful; this is an experimental feature. For more details see the documentation on the onX feature.
Static fields are skipped by these annotations. Also, a @java.beans.ConstructorProperties
annotation is added for all constructors with at least 1 argument,
which allows bean editor tools to call the generated constructors. @ConstructorProperties
is now in Java 1.6, which means that if your code is intended for
diff --git a/website/features/GetterSetter.html b/website/features/GetterSetter.html
index 7e2ff226..2e39e1ad 100644
--- a/website/features/GetterSetter.html
+++ b/website/features/GetterSetter.html
@@ -29,7 +29,7 @@
You can always manually disable getter/setter generation for any field by using the special AccessLevel.NONE
access level. This lets you override the
behaviour of a @Getter
, @Setter
or @Data
annotation on a class.
- To put annotations on the generated method, you can use onMethod=@_({@AnnotationsHere})
; to put annotations on the only parameter of a generated setter method, you can use onParam=@_({@AnnotationsHere})
. Be careful though! This is an experimental feature. For more details see the documentation on the onX feature.
+ To put annotations on the generated method, you can use onMethod=@__({@AnnotationsHere})
; to put annotations on the only parameter of a generated setter method, you can use onParam=@__({@AnnotationsHere})
. Be careful though! This is an experimental feature. For more details see the documentation on the onX feature.
NEW in lombok v1.12.0: javadoc on the field will now be copied to generated getters and setters. Normally, all text is copied, and @return
is moved to the getter, whilst @param
lines are moved to the setter. Moved means: Deleted from the field's javadoc. It is also possible to define unique text for each getter/setter. To do that, you create a 'section' named GETTER
and/or SETTER
. A section is a line in your javadoc containing 2 or more dashes, then the text 'GETTER' or 'SETTER', followed by 2 or more dashes, and nothing else on the line. If you use sections, @return
and @param
stripping for that section is no longer done (move the @return
or @param
line into the section).
@Wither(level = AccessLevel.PROTECTED)
. Also like @Setter
, you can also put a @Wither
annotation on a type, which means
a 'wither' is generated for each field (even non-final fields).
- To put annotations on the generated method, you can use onMethod=@_({@AnnotationsHere})
; to put annotations on the only parameter of a generated wither method, you can use onParam=@_({@AnnotationsHere})
. Be careful though! This is an experimental feature. For more details see the documentation on the onX feature.
+ To put annotations on the generated method, you can use onMethod=@__({@AnnotationsHere})
; to put annotations on the only parameter of a generated wither method, you can use onParam=@__({@AnnotationsHere})
. Be careful though! This is an experimental feature. For more details see the documentation on the onX feature.
NEW in lombok v1.12.0: javadoc on the field will now be copied to generated withers. Normally, all text is copied, and @param
is moved to the wither, whilst @return
lines are stripped from the wither's javadoc. Moved means: Deleted from the field's javadoc. It is also possible to define unique text for the wither's javadoc. To do that, you create a 'section' named WITHER
. A section is a line in your javadoc containing 2 or more dashes, then the text 'WITHER', followed by 2 or more dashes, and nothing else on the line. If you use sections, @return
and @param
stripping / copying for that section is no longer done (move the @param
line into the section).
@Setter
and @Wither
support onParam
in addition to onMethod
; annotations listed will be put on the only parameter that the generated method has.
- The syntax is a little strange; to use any of the 3 onX
features, you must wrap the annotations to be applied to the constructor / method / parameter in @_(@AnnotationGoesHere)
. To apply multiple annotations, use @_({@Annotation1, @Annotation2})
. The annotations can themselves obviously have parameters as well.
+ The syntax is a little strange; to use any of the 3 onX
features, you must wrap the annotations to be applied to the constructor / method / parameter in @__(@AnnotationGoesHere)
. To apply multiple annotations, use @__({@Annotation1, @Annotation2})
. The annotations can themselves obviously have parameters as well.
- The reason of the weird syntax is to make this feature work in javac 7 compilers; the @_
type is an annotation reference to the annotation type _
(underscore) which doesn't actually exist; this makes javac 7 delay aborting the compilation process due to an error because it is possible an annotation processor will later create the _
type. Instead, lombok applies the annotations and removes the references so that the error will never actually occur. The point is: The _
type must not exist, otherwise the feature does not work. In the rare case that the _
type does exist (and is imported or in the package), you can simply add more underscores. Technically any non-existent type would work, but to maintain consistency and readability and catch erroneous use, lombok considers it an error if the 'wrapper' annotation is anything but a series of underscores.
+ The reason of the weird syntax is to make this feature work in javac 7 compilers; the @__
type is an annotation reference to the annotation type _
(underscore) which doesn't actually exist; this makes javac 7 delay aborting the compilation process due to an error because it is possible an annotation processor will later create the _
type. Instead, lombok applies the annotations and removes the references so that the error will never actually occur. The point is: The _
type must not exist, otherwise the feature does not work. In the rare case that the _
type does exist (and is imported or in the package), you can simply add more underscores. Technically any non-existent type would work, but to maintain consistency and readability and catch erroneous use, lombok considers it an error if the 'wrapper' annotation is anything but a series of underscores.
To reiterate: This feature can disappear at any time; if you use this feature, be prepared to adjust your code when we find a nicer way of implementing this feature, or, if a future version of javac forces us to remove this feature entirely with no alternative.
-- cgit