aboutsummaryrefslogtreecommitdiff
path: root/website/features/GetterLazy.html
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2010-11-18 12:45:02 +0100
committerReinier Zwitserloot <reinier@zwitserloot.com>2010-11-18 13:04:09 +0100
commit3c47eb1299467f052f25581430d20bc3b2b83f4d (patch)
tree3bdc37b4324b185e0c907b421d389735193f20d9 /website/features/GetterLazy.html
parent36f9a5aabc393738af1587907e324ea44661ed4d (diff)
downloadlombok-3c47eb1299467f052f25581430d20bc3b2b83f4d.tar.gz
lombok-3c47eb1299467f052f25581430d20bc3b2b83f4d.tar.bz2
lombok-3c47eb1299467f052f25581430d20bc3b2b83f4d.zip
Added documentation for val and @Getter(lazy=true) and updated docs for Log and EqualsAndHashCode to reflect new lombok 0.10 features.
Diffstat (limited to 'website/features/GetterLazy.html')
-rw-r--r--website/features/GetterLazy.html65
1 files changed, 65 insertions, 0 deletions
diff --git a/website/features/GetterLazy.html b/website/features/GetterLazy.html
new file mode 100644
index 00000000..a91e782c
--- /dev/null
+++ b/website/features/GetterLazy.html
@@ -0,0 +1,65 @@
+<!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>@Getter(lazy=true)</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>@Getter and @Setter</h1>
+ <div class="byline">Laziness is a virtue!</div>
+ <div class="overview">
+ <h3>Overview</h3>
+ <p>
+ <em>NEW IN Lombok 0.10: </em>You can let lombok generate a getter which will calculate a value once, the first time this getter is called, and cache it from then on. This can be useful
+ if calculating the value takes a lot of CPU, or the value takes a lot of memory. To use this feature, create a <code>private final</code> variable,
+ initialize it with the expression that's expensive to run, and annotate your field with <code>@Getter(lazy=true)</code>. The field will be hidden from the
+ rest of your code, and the expression will be evaluated no more than once, when the getter is first called. There are no magic marker values (i.e. even
+ if the result of your expensive calculation is <code>null</code>, the result is cached) and your expensive calculation need not be thread-safe, as lombok
+ takes care of locking.
+ </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>
+ Lombok actually creates a few fields all prefixed with <code>$lombok$</code> to cache the value. You should not rely on the exact type, name, and structure
+ of these fields as future implementations may change them. To access the lazily initialized value, <em>always</em> use the generated getter.
+ </p><p>
+ Other Lombok annotations such as <code>@ToString</code> always call the getter even if you use <code>doNotUseGetters=true</code>.
+ </p>
+ </div>
+ </div>
+ <div class="footer">
+ <a href="index.html">Back to features</a> | <a href="GetterSetter.html">Previous feature (@Getter / @Setter)</a> | <a href="ToString.html">Next feature (@ToString)</a><br />
+ <a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright &copy; 2009-2010 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>
+</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>