From ef8769d3180b2c6de91a64f69dfa23a2e6e449b9 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 17 Nov 2012 20:26:58 +0100 Subject: Added all documentation for the onX feature and updated changelog. Now to actually write the feature (Well, rescue it from the onX-removal tag). --- website/features/Constructor.html | 2 + website/features/GetterSetter.html | 2 + website/features/experimental/Wither.html | 2 + website/features/onX.html | 69 +++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+) create mode 100644 website/features/onX.html (limited to 'website/features') diff --git a/website/features/Constructor.html b/website/features/Constructor.html index 48c913b4..c60d915f 100644 --- a/website/features/Constructor.html +++ b/website/features/Constructor.html @@ -35,6 +35,8 @@ Such a static factory method will infer generics, unlike a normal constructor. This means your API users get write 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}. 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 compilation on Java 1.5, a compiler error will occur. Running on a JVM 1.5 should be no problem (the annotation will be ignored). To suppress the generation of diff --git a/website/features/GetterSetter.html b/website/features/GetterSetter.html index beb40a61..a7dda812 100644 --- a/website/features/GetterSetter.html +++ b/website/features/GetterSetter.html @@ -28,6 +28,8 @@

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}. For more details see the documentation on the onX feature.

diff --git a/website/features/experimental/Wither.html b/website/features/experimental/Wither.html index 34d6d0d9..a7b77dab 100644 --- a/website/features/experimental/Wither.html +++ b/website/features/experimental/Wither.html @@ -44,6 +44,8 @@ Like @Setter, you can specify an access level in case you want the generated wither to be something other than public:
@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 this method, you can use onParam={@AnnotationsHere}. For more details see the documentation on the onX feature.

diff --git a/website/features/onX.html b/website/features/onX.html new file mode 100644 index 00000000..b001f294 --- /dev/null +++ b/website/features/onX.html @@ -0,0 +1,69 @@ + + + + + + + + onX +
+
+
+ +

onX

+ +
+

Overview

+

+ This feature is considered 'workaround status' - it exists in order to allow users of lombok that cannot work without this feature to have access to it anyway. If we find a better way to implement this feature, or some future java version introduces an alternative strategy, this feature can disappear without a reasonable deprecation period. Also, this feature may not work in future versions of javac. Use at your own discretion. +

+ Most annotations that make lombok generate methods or constructors can be configured to also + make lombok put custom annotations on elements in the generated code. +

+ @Getter, @Setter, and @Wither support the onMethod + option, which will put the listed annotations on the generated method. +

+ @AllArgsConstructor, @NoArgsConstructor, and @RequiredArgsConstructor support the onConstructor option which will put the listed annotations on the generated constructor. +

+ @Setter and @Wither support onParam in addition to onMethod; annotations listed will be put on the only parameter that the generated method has. +

+ None of the mentioned annotations above actually have parameters named onMethod, onParam, or onConstructor; nevertheless, if you type them, lombok will make it work. Unfortunately this does mean that auto-complete and other tool-driven convenience features will not work as expected. The annotations lack these parameters in order to work around javac limitations. +

+
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Small print

+

+ We can't think of any small print for this feature, other than 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