aboutsummaryrefslogtreecommitdiff
path: root/website/features/experimental/Delegate.html
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2014-05-08 06:25:38 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2014-05-20 23:43:08 +0200
commit4996428ea12be7e381d76614e34a15ad1cc6d275 (patch)
treeca5067b7b8f63eff6adeed83f8ff9339128d8ca7 /website/features/experimental/Delegate.html
parent05ca21b75e5c20e1e731d9141857f346bb3eca9f (diff)
downloadlombok-4996428ea12be7e381d76614e34a15ad1cc6d275.tar.gz
lombok-4996428ea12be7e381d76614e34a15ad1cc6d275.tar.bz2
lombok-4996428ea12be7e381d76614e34a15ad1cc6d275.zip
@Delegate has moved to lombok.experimental.
Some work on the aliasing system to make that go smoothly.
Diffstat (limited to 'website/features/experimental/Delegate.html')
-rw-r--r--website/features/experimental/Delegate.html93
1 files changed, 93 insertions, 0 deletions
diff --git a/website/features/experimental/Delegate.html b/website/features/experimental/Delegate.html
new file mode 100644
index 00000000..6f745f31
--- /dev/null
+++ b/website/features/experimental/Delegate.html
@@ -0,0 +1,93 @@
+<!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="since">
+ <h3>Since</h3>
+ <p>
+ @Delegate was introduced as feature in lombok v0.10. It was moved to the experimental package in lombok v1.14; the old version from the main lombok package is now deprecated.
+ </p>
+ </div>
+ <div class="experimental">
+ <h3>Experimental</h3>
+ <p>
+ Experimental because:
+ <ul>
+ <li>Not used that much</li>
+ <li>Difficult to support for edge cases, such as recursive delegation.</li>
+ <li>API is rather unfriendly; it would be a lot nicer if you can simply implement some methods and let <code>@Delegate</code> generate delegates for whatever you didn't manually implement, but due to issues with generics erasure this also can't be made to work without caveats.
+ </ul>
+ Current status: <em>negative</em> - Currently we feel this feature will not move out of experimental status anytime soon, and support for this feature may be dropped if future versions of javac or ecj make it difficult to continue to maintain the feature.
+ </div>
+ <div class="overview">
+ <h3>Overview</h3>
+ <p>
+ Any field or no-argument method can be annotated with <code>@Delegate</code> to let lombok generate delegate methods that forward the call to this field (or the result of invoking this method).
+ </p><p>
+ Lombok delegates all <code>public</code> methods of the field's type (or method's return type), as well as those of its supertypes except for all
+ methods declared in <code>java.lang.Object</code>.
+ </p><p>
+ You can pass any number of classes into the <code>@Delegate</code> annotation's <code>types</code> parameter.
+ 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/method's type.
+ </p><p>
+ All public non-<code>Object</code> methods that are part of the calculated type(s) are copied, whether or not you also wrote implementations for those methods. That would thus result in duplicate method errors. You can avoid these
+ by using the <code>@Delegate(excludes=SomeType.class)</code> parameter to exclude all public methods in the excluded type(s), and their supertypes.
+ </p><p>
+ To have very precise control over what is delegated and what isn't, write private inner interfaces with method signatures, then specify these
+ private inner interfaces as types in <code>@Delegate(types=PrivateInnerInterfaceWithIncludesList.class, excludes=SameForExcludes.class)</code>.
+ </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's <code>types</code> or <code>excludes</code> parameter, you cannot include generics.
+ This is a limitation of java. Use private inner interfaces or classes that extend the intended type including the
+ generics parameter to work around this problem.
+ </p><p>
+ When passing classes to the annotation, these classes do not need to be supertypes of the field. See the example.
+ </p><p>
+ <code>@Delegate</code> cannot be used on static fields or methods.
+ </p><p>
+ <code>@Delegate</code> cannot be used when the calculated type(s) to delegate / exclude themselves contain <code>@Delegate</code> annotations; in other words, <code>@Delegate</code> will error if you attempt to use it recursively.
+ </div>
+ </div>
+ <div class="footer">
+ <a href="index.html">Back to features</a> | <a href="FieldDefaults.html">Previous feature (@FieldDefaults)</a> | <a href="Wither.html">Next feature (@Wither)</a><br />
+ <a href="../../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright &copy; 2010-2013 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>