aboutsummaryrefslogtreecommitdiff
path: root/website/features/GetterLazy.html
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2013-07-07 21:49:23 +0200
committerReinier Zwitserloot <reinier@zwitserloot.com>2013-07-07 21:49:48 +0200
commit91bfd390e05ed3d04dff6438ffd1bc9e01eb1fff (patch)
treeda0a6611de67080689c030ae50bf99626ea139b2 /website/features/GetterLazy.html
parent85fec0dffa5df13c0cafc86ca762774ba2c4d951 (diff)
downloadlombok-91bfd390e05ed3d04dff6438ffd1bc9e01eb1fff.tar.gz
lombok-91bfd390e05ed3d04dff6438ffd1bc9e01eb1fff.tar.bz2
lombok-91bfd390e05ed3d04dff6438ffd1bc9e01eb1fff.zip
updated docs for new desugaring for getter(lazy=true)
Diffstat (limited to 'website/features/GetterLazy.html')
-rw-r--r--website/features/GetterLazy.html10
1 files changed, 2 insertions, 8 deletions
diff --git a/website/features/GetterLazy.html b/website/features/GetterLazy.html
index f70c8e78..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,8 +33,7 @@
<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>