aboutsummaryrefslogtreecommitdiff
path: root/website/features/GetterLazy.html
diff options
context:
space:
mode:
Diffstat (limited to 'website/features/GetterLazy.html')
-rw-r--r--website/features/GetterLazy.html12
1 files changed, 3 insertions, 9 deletions
diff --git a/website/features/GetterLazy.html b/website/features/GetterLazy.html
index bc5ecb0c..c6d21f01 100644
--- a/website/features/GetterLazy.html
+++ b/website/features/GetterLazy.html
@@ -15,12 +15,7 @@
<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.
+ <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">
@@ -38,15 +33,14 @@
<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.
+ You should never refer to the field directly, always use the getter generated by lombok, because the type of the field will be mangled into an <code>AtomicReference</code>. Do not try to directly access this <code>AtomicReference</code>; if it points to itself, the value has been calculated, and it is <code>null</code>. If the reference points to <code>null</code>, then the value has not been calculated. This behaviour may change in future versions. Therefore, <em>always</em> use the generated getter to access your field!
</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="index.html">Back to features</a> | <a href="Synchronized.html">Previous feature (@Synchronized)</a> | <a href="Log.html">Next feature (@Log)</a><br />
<a href="../credits.html" class="creditsLink">credits</a> | <span class="copyright">Copyright &copy; 2009-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>