aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrootjans <grootjans@gmail.com>2011-02-07 22:44:55 +0100
committergrootjans <grootjans@gmail.com>2011-02-07 22:46:07 +0100
commit7b3968fe401c1db299a34feaba8f862069723e36 (patch)
tree3bf6728bd64349c43d404411abca4def00c62c47
parent2741ac3c4b53e29259243b069582ed456e9b6609 (diff)
downloadlombok-7b3968fe401c1db299a34feaba8f862069723e36.tar.gz
lombok-7b3968fe401c1db299a34feaba8f862069723e36.tar.bz2
lombok-7b3968fe401c1db299a34feaba8f862069723e36.zip
Added documentation for @Delegate. This fixes issue 189
-rw-r--r--buildScripts/website.ant.xml3
-rw-r--r--usage_examples/DelegateExample_post.jpage98
-rw-r--r--usage_examples/DelegateExample_pre.jpage27
-rw-r--r--website/features/Delegate.html70
-rw-r--r--website/features/index.html2
-rw-r--r--website/features/val.html4
6 files changed, 202 insertions, 2 deletions
diff --git a/buildScripts/website.ant.xml b/buildScripts/website.ant.xml
index d1eb92ec..aabc337c 100644
--- a/buildScripts/website.ant.xml
+++ b/buildScripts/website.ant.xml
@@ -141,6 +141,9 @@ such as converting the changelog into HTML, and creating javadoc.
<antcall target="-integrateSnippet">
<param name="transformationName" value="val" />
</antcall>
+ <antcall target="-integrateSnippet">
+ <param name="transformationName" value="Delegate" />
+ </antcall>
</target>
<target name="-website-dist">
diff --git a/usage_examples/DelegateExample_post.jpage b/usage_examples/DelegateExample_post.jpage
new file mode 100644
index 00000000..28c1bbb7
--- /dev/null
+++ b/usage_examples/DelegateExample_post.jpage
@@ -0,0 +1,98 @@
+import java.util.ArrayList;
+import java.util.Collection;
+import lombok.Delegate;
+
+public class DelegateExample {
+
+ long counter = 0L;
+ @Delegate
+ private final Collection<String> collection = new ArrayList<String>();
+
+ public boolean add(String name) {
+ counter++;
+ return collection.add(name);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public int size() {
+ return this.collection.size();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean isEmpty() {
+ return this.collection.isEmpty();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean contains(final java.lang.Object arg0) {
+ return this.collection.contains(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public java.util.Iterator<java.lang.String> iterator() {
+ return this.collection.iterator();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public java.lang.Object[] toArray() {
+ return this.collection.toArray();
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public <T extends .java.lang.Object>T[] toArray(final T[] arg0) {
+ return this.collection.<T>toArray(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean remove(final java.lang.Object arg0) {
+ return this.collection.remove(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean containsAll(final java.util.Collection<?> arg0) {
+ return this.collection.containsAll(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean addAll(final java.util.Collection<? extends java.lang.String> arg0) {
+ return this.collection.addAll(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean removeAll(final java.util.Collection<?> arg0) {
+ return this.collection.removeAll(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean retainAll(final java.util.Collection<?> arg0) {
+ return this.collection.retainAll(arg0);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public void clear() {
+ this.collection.clear();
+ }
+}
+
+class PartialDelegationExample {
+
+ @Delegate({SimpleCollection.class})
+ private final Collection<String> collection = new ArrayList<String>();
+
+ private interface SimpleCollection {
+
+ boolean add(String item);
+
+ boolean remove(Object item);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean add(final java.lang.String item) {
+ return this.collection.add(item);
+ }
+
+ @java.lang.SuppressWarnings("all")
+ public boolean remove(final java.lang.Object item) {
+ return this.collection.remove(item);
+ }
+} \ No newline at end of file
diff --git a/usage_examples/DelegateExample_pre.jpage b/usage_examples/DelegateExample_pre.jpage
new file mode 100644
index 00000000..b208c4ca
--- /dev/null
+++ b/usage_examples/DelegateExample_pre.jpage
@@ -0,0 +1,27 @@
+import java.util.ArrayList;
+import java.util.Collection;
+
+import lombok.Delegate;
+
+
+public class DelegateExample {
+ long counter = 0L;
+
+ @Delegate
+ private final Collection<String> collection = new ArrayList<String>();
+
+ public boolean add(String name) {
+ counter++;
+ return collection.add(name);
+ }
+}
+
+class PartialDelegationExample {
+ @Delegate({SimpleCollection.class})
+ private final Collection<String> collection = new ArrayList<String>();
+
+ private interface SimpleCollection {
+ boolean add(String item);
+ boolean remove(Object item);
+ }
+}
diff --git a/website/features/Delegate.html b/website/features/Delegate.html
new file mode 100644
index 00000000..bdb22c26
--- /dev/null
+++ b/website/features/Delegate.html
@@ -0,0 +1,70 @@
+<!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>@Delegate</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>@Delegate</h1>
+ <div class="byline">Don't lose your composition</div>
+ <div class="overview">
+ <h3>Overview</h3>
+ <p>
+ <em> NEW IN Lombok 0.10: </em> Any field can be annotated with <code>@Delegate</code> to let lombok generate delegate methods that forward the call
+ to this field.
+ </p>
+ <p>
+ Lombok delegates all <code>public</code> methods of the field's type, as well as those of its supertype except for all methods declared
+ in <code>java.lang.Object</code>. You can provide a specific implementation for a method by providing you own implementation, lombok will not
+ generate delegate methods for those already declared in the class.
+ </p>
+ <p>
+ You can pass any number of classes into the <code>@Delegate</code> annotation. If you do that, then lombok will delegate all <code>public</code>
+ methods in those types (and their supertypes, except <code>java.lang.Object</code>) instead of looking at the field's type.
+ </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>
+ When passing classes to the annotation, these cannot contain generics. This is a limitation of java that lombok cannot work around.
+ </p>
+ <p>
+ When passing classes to the annotation, these classes do not need to be supertypes of the field. See the example.
+ </p>
+ <div>
+ </div>
+ <div class="footer">
+ <a href="index.html">Back to features</a> | <a href="val.html">Previous feature (val)</a> | <span class="disabled">Next feature</span><br />
+ <a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright &copy; 2010-2011 Reinier Zwitserloot, Roel Spilker and Robbert Jan Grootjans, 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>
diff --git a/website/features/index.html b/website/features/index.html
index edc173fb..06b6763e 100644
--- a/website/features/index.html
+++ b/website/features/index.html
@@ -36,6 +36,8 @@
<dd>Captain's Log, stardate 24435.7: &quot;What was that line again?&quot;</dd>
<dt><a href="val.html"><code>val</code></a></dt>
<dd>Finally! hassle-free final local variables.</dd>
+ <dt><a href="Delegate.html"><code>@Delegate</code></a></dt>
+ <dd>Don't lose your composition</dd>
</dl>
</div>
<div class="pointer">
diff --git a/website/features/val.html b/website/features/val.html
index 4e05f8ca..f3e86447 100644
--- a/website/features/val.html
+++ b/website/features/val.html
@@ -50,8 +50,8 @@
</div>
</div>
<div class="footer">
- <a href="index.html">Back to features</a> | <a href="Log.html">Previous feature (@Log)</a> | <span class="disabled">Next feature</span><br />
- <a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright &copy; 2010 Reinier Zwitserloot and Roel Spilker, licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</span>
+ <a href="index.html">Back to features</a> | <a href="Log.html">Previous feature (@Log)</a> | <a href="Delegate.html">Next feature (@Delegate)</a><br />
+ <a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright &copy; 2010-2011 Reinier Zwitserloot and Roel Spilker, licensed under the <a href="http://www.opensource.org/licenses/mit-license.php">MIT license</a>.</span>
</div>
<div style="clear: both;"></div>
</div>