From e0cfacd3b307b1ec9f0b62b2f953f0a0e85d9d1e Mon Sep 17 00:00:00 2001 From: grootjans Date: Mon, 21 Feb 2011 22:03:05 +0100 Subject: Issue 192: Add documentation for onMethod=, onParam, onConstructor still have to make a minor edit in the pre/post files --- buildScripts/website.ant.xml | 3 ++ usage_examples/onXExample_post.jpage | 41 +++++++++++++++++++++++++ usage_examples/onXExample_pre.jpage | 23 ++++++++++++++ website/features/Delegate.html | 2 +- website/features/index.html | 2 ++ website/features/onX.html | 58 ++++++++++++++++++++++++++++++++++++ 6 files changed, 128 insertions(+), 1 deletion(-) create mode 100644 usage_examples/onXExample_post.jpage create mode 100644 usage_examples/onXExample_pre.jpage create mode 100644 website/features/onX.html diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml index aabc337c..68e20eae 100644 --- a/buildScripts/website.ant.xml +++ b/buildScripts/website.ant.xml @@ -144,6 +144,9 @@ such as converting the changelog into HTML, and creating javadoc. + + + diff --git a/usage_examples/onXExample_post.jpage b/usage_examples/onXExample_post.jpage new file mode 100644 index 00000000..f71f16a3 --- /dev/null +++ b/usage_examples/onXExample_post.jpage @@ -0,0 +1,41 @@ +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +public class OnMethodOnParamExample { + private int fires = 200; + private int firemen = 20; + private String fireStationName = "base"; + + @Deprecated + public int getFires() { + return fires; + } + + @Deprecated + public void setFiremen(int firemen) { + this.firemen = firemen; + } + + public void setFireStationName(@SuppressWarnings("all") int fireStationName) { + this.fireStationName = fireStationName; + } + + @Override public String toString() { + return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires); + } +} + +class OnConstructorExample { + private final int radishes; + private int bananas; + + @Deprecated + public OnConstructorExample(int radishes) { + this.radishes = radishes; + } + + @Override public String toString() { + return String.format("I have %d bananas and %d radishes", bananas, radishes); + } +} \ No newline at end of file diff --git a/usage_examples/onXExample_pre.jpage b/usage_examples/onXExample_pre.jpage new file mode 100644 index 00000000..3e91fb3a --- /dev/null +++ b/usage_examples/onXExample_pre.jpage @@ -0,0 +1,23 @@ +import lombok.Getter; +import lombok.RequiredArgsConstructor; +import lombok.Setter; + +public class OnMethodOnParamExample { + @Getter(onMethod=@Deprecated) private int fires = 200; + @Setter(onMethod=@Deprecated) private int firemen = 20; + @Setter(onParam=@SuppressWarnings("all")) private String fireStationName = "base"; + + @Override public String toString() { + return String.format("firestation:%s, %d firemen are fighting %d fires", fireStationName, firemen, fires); + } +} + +@RequiredArgsConstructor(onConstructor=@Deprecated) +class OnConstructorExample { + private final int radishes; + private int bananas; + + @Override public String toString() { + return String.format("I have %d bananas and %d radishes", bananas, radishes); + } +} \ No newline at end of file diff --git a/website/features/Delegate.html b/website/features/Delegate.html index bdb22c26..52b1035d 100644 --- a/website/features/Delegate.html +++ b/website/features/Delegate.html @@ -51,7 +51,7 @@
diff --git a/website/features/index.html b/website/features/index.html index 06b6763e..e9a2255b 100644 --- a/website/features/index.html +++ b/website/features/index.html @@ -38,6 +38,8 @@
Finally! hassle-free final local variables.
@Delegate
Don't lose your composition
+
onMethod=,onParam=,onConstructor=
+
Annotate this! Add you favorite annotation to methods generated by lombok.
diff --git a/website/features/onX.html b/website/features/onX.html new file mode 100644 index 00000000..b94dea4b --- /dev/null +++ b/website/features/onX.html @@ -0,0 +1,58 @@ + + + + + + + + onMethod=,onParam=,onConstructor= +
+
+
+ +

onMethod=,onParam=,onConstructor=

+ +
+

Overview

+

+ Lombok lets you add your favorite annotation to methods generated by @Getter and @Setter by using the attribute onMethod + on the lombok annotation. You can specify annotations to the parameters of the method on @Setter with the attribute onParameter. + You can add annotation to constructors generated by @NoArgsConstructor, @RequiredArgsConstructor and @AllArgsConstructor by using the attribute + onConstructor +

+
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Small print

+ When the @Getter or @Setter annotation is placed on the type in stead of a field, using the attribute is not supported and it will result in a warning. +
+
+ +
+
+
+ + + -- cgit