aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2012-11-17 20:26:58 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2012-11-17 20:26:58 +0100
commitef8769d3180b2c6de91a64f69dfa23a2e6e449b9 (patch)
treedff0f1f3dd0221041afb45e7f1f50d7bddec3a23
parent58851b4c6e96a51d1ac298c7ed85efac6ffe8335 (diff)
downloadlombok-ef8769d3180b2c6de91a64f69dfa23a2e6e449b9.tar.gz
lombok-ef8769d3180b2c6de91a64f69dfa23a2e6e449b9.tar.bz2
lombok-ef8769d3180b2c6de91a64f69dfa23a2e6e449b9.zip
Added all documentation for the onX feature and updated changelog.
Now to actually write the feature (Well, rescue it from the onX-removal tag).
-rw-r--r--buildScripts/website.ant.xml3
-rw-r--r--doc/changelog.markdown3
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java2
-rw-r--r--usage_examples/onXExample_post.jpage22
-rw-r--r--usage_examples/onXExample_pre.jpage15
-rw-r--r--website/features/Constructor.html2
-rw-r--r--website/features/GetterSetter.html2
-rw-r--r--website/features/experimental/Wither.html2
-rw-r--r--website/features/onX.html69
9 files changed, 119 insertions, 1 deletions
diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml
index c5bddfec..35e34367 100644
--- a/buildScripts/website.ant.xml
+++ b/buildScripts/website.ant.xml
@@ -146,6 +146,9 @@ such as converting the changelog into HTML, and creating javadoc.
<param name="transformationName" value="Delegate" />
</antcall>
<antcall target="-integrateSnippet">
+ <param name="transformationName" value="onX" />
+ </antcall>
+ <antcall target="-integrateSnippet">
<param name="transformationName" value="experimental/Accessors" />
</antcall>
<antcall target="-integrateSnippet">
diff --git a/doc/changelog.markdown b/doc/changelog.markdown
index 2fcb0593..33a96226 100644
--- a/doc/changelog.markdown
+++ b/doc/changelog.markdown
@@ -1,6 +1,9 @@
Lombok Changelog
----------------
+### v0.11.7 (Edgy Guinea Pig)
+* FEATURE: Reintroduced `onMethod`, `onConstructor` and `onParam` to `@Getter`, `@Setter`, `@Wither`, and `@XArgsConstructor`. These parameters allow you to add annotations to the methods/constructors that lombok will generate. This is a workaround feature: The stability of the feature on future versions of javac is not guaranteed, and if a better way to implement this feature is found, this feature's current incarnation will be removed without a reasonable period of deprecation. [Documentation on the onX feature](http://projectlombok.org/feature/onX.html)
+
### v0.11.6 (October 30th, 2012)
* FEATURE: Lombok can be disabled entirely for any given compile run by using JVM switch `-Dlombok.disable`. This might be useful for code style checkers and such.
* FEATURE: Added support for Slf4j extended logger [Issue #421](http://code.google.com/p/projectlombok/issues/detail?id=421)
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 9fabe91c..ad3e4a17 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -646,7 +646,7 @@ public class JavacHandlerUtil {
/**
* Returns the type of the field, unless a getter exists for this field, in which case the return type of the getter is returned.
*
- * @see #createFieldAccessor(TreeMaker, JavacNode)
+ * @see #createFieldAccessor(TreeMaker, JavacNode, FieldAccess)
*/
static JCExpression getFieldType(JavacNode field, FieldAccess fieldAccess) {
boolean lookForGetter = lookForGetter(field, fieldAccess);
diff --git a/usage_examples/onXExample_post.jpage b/usage_examples/onXExample_post.jpage
new file mode 100644
index 00000000..1be94f2a
--- /dev/null
+++ b/usage_examples/onXExample_post.jpage
@@ -0,0 +1,22 @@
+import javax.inject.Inject;
+import javax.persistence.Id;
+import javax.persistence.Column;
+import javax.validation.constraints.Max;
+
+public class OnXExample {
+ private long unid;
+
+ @Inject
+ public OnXExample(long unid) {
+ this.unid = unid;
+ }
+
+ @Id @Column(name="unique-id")
+ public long getUnid() {
+ return unid;
+ }
+
+ public void setUnid(@Max(10000) long unid) {
+ this.unid = unid;
+ }
+}
diff --git a/usage_examples/onXExample_pre.jpage b/usage_examples/onXExample_pre.jpage
new file mode 100644
index 00000000..2cc9c581
--- /dev/null
+++ b/usage_examples/onXExample_pre.jpage
@@ -0,0 +1,15 @@
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.Setter;
+
+import javax.inject.Inject;
+import javax.persistence.Id;
+import javax.persistence.Column;
+import javax.validation.constraints.Max;
+
+@AllArgsConstructor(onConstructor=@Inject)
+public class OnXExample {
+ @Getter(onMethod={@Id, @Column(name="unique-id"})
+ @Setter(onParam=@Max(10000))
+ private long unid;
+}
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 <code>MapEntry.of("foo", 5)</code> instead of the much longer
<code>new MapEntry&lt;String, Integer&gt;("foo", 5)</code>.
</p><p>
+ To put annotations on the generated constructor, you can use <code>onConstructor={@AnnotationsHere}</code>. For more details see the documentation on the <a href="onX.html">onX</a> feature.
+ </p><p>
Static fields are skipped by these annotations. Also, a <code>@java.beans.ConstructorProperties</code> annotation is added for all constructors with at least 1 argument,
which allows bean editor tools to call the generated constructors. <code>@ConstructorProperties</code> 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. <em>Running</em> 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 @@
</p><p>
You can always manually disable getter/setter generation for any field by using the special <code>AccessLevel.NONE</code> access level. This lets you override the
behaviour of a <code>@Getter</code>, <code>@Setter</code> or <code>@Data</code> annotation on a class.
+ </p><p>
+ To put annotations on the generated method, you can use <code>onMethod={@AnnotationsHere}</code>; to put annotations on the only parameter of a generated setter method, you can use <code>onParam={@AnnotationsHere}</code>. For more details see the documentation on the <a href="onX.html">onX</a> feature.
</p>
</div>
<div class="snippets">
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 <a href="../GetterSetter.html"><code>@Setter</code></a>, you can specify an access level in case you want the generated wither to be something other than <code>public</code>:<br />
<code>@Wither(level = AccessLevel.PROTECTED)</code>. Also like <a href="../GetterSetter.html"><code>@Setter</code></a>, you can also put a <code>@Wither</code> annotation on a type, which means
a 'wither' is generated for each field (even non-final fields).
+ </p><p>
+ To put annotations on the generated method, you can use <code>onMethod={@AnnotationsHere}</code>; to put annotations on the only parameter of this method, you can use <code>onParam={@AnnotationsHere}</code>. For more details see the documentation on the <a href="onX.html">onX</a> feature.
</p>
</div>
<div class="snippets">
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 @@
+<!DOCTYPE html>
+<html><head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <link rel="stylesheet" type="text/css" href="../logi/reset.css" />
+ <link rel="stylesheet" type="text/css" href="features.css" />
+ <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
+ <meta name="description" content="Spice up your java" />
+ <title>onX</title>
+</head><body><div id="pepper">
+ <div class="minimumHeight"></div>
+ <div class="meat">
+ <div class="header"><a href="../index.html">Project Lombok</a></div>
+ <h1>onX</h1>
+ <div class="byline">Sup dawg, we heard you like annotations, so we put annotations in your annotations so you can annotate while you're annotating.</div>
+ <div class="overview">
+ <h3>Overview</h3>
+ <p>
+ <strong>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.</strong>
+ </p><p>
+ 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.
+ </p><p>
+ <code>@Getter</code>, <code>@Setter</code>, and <code>@Wither</code> support the <code>onMethod</code>
+ option, which will put the listed annotations on the generated method.
+ </p><p>
+ <code>@AllArgsConstructor</code>, <code>@NoArgsConstructor</code>, and <code>@RequiredArgsConstructor</code> support the <code>onConstructor</code> option which will put the listed annotations on the generated constructor.
+ </p><p>
+ <code>@Setter</code> and <code>@Wither</code> support <code>onParam</code> in addition to <code>onMethod</code>; annotations listed will be put on the only parameter that the generated method has.
+ </p><p>
+ None of the mentioned annotations above actually have parameters named <code>onMethod</code>, <code>onParam</code>, or <code>onConstructor</code>; 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.
+ </p>
+ </div>
+ <div class="snippets">
+ <div class="pre">
+ <h3>With Lombok</h3>
+ <div class="snippet">@HTML_PRE@</div>
+ </div>
+ <div class="sep"></div>
+ <div class="post">
+ <h3>Vanilla Java</h3>
+ <div class="snippet">@HTML_POST@</div>
+ </div>
+ </div>
+ <div style="clear: left;"></div>
+ <div class="overview">
+ <h3>Small print</h3><div class="smallprint">
+ <p>
+ 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.
+ </p>
+ </div>
+ </div>
+ <div class="footer">
+ <a href="index.html">Back to features</a><br />
+ <a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright &copy; 2009-2012 The Project Lombok Authors, licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</span>
+ </div>
+ <div style="clear: both;"></div>
+ </div>
+</div>
+<script type="text/javascript">
+ var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+ try {
+ var pageTracker = _gat._getTracker("UA-9884254-1");
+ pageTracker._trackPageview();
+ } catch(err) {}
+</script>
+</body></html>