From 3c47eb1299467f052f25581430d20bc3b2b83f4d Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 18 Nov 2010 12:45:02 +0100 Subject: Added documentation for val and @Getter(lazy=true) and updated docs for Log and EqualsAndHashCode to reflect new lombok 0.10 features. --- website/features/GetterLazy.html | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 website/features/GetterLazy.html (limited to 'website/features/GetterLazy.html') 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 @@ + + + + + + + + @Getter(lazy=true) +
+
+
+ +

@Getter and @Setter

+ +
+

Overview

+

+ NEW IN Lombok 0.10: 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 private final variable, + initialize it with the expression that's expensive to run, and annotate your field with @Getter(lazy=true). 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 null, the result is cached) and your expensive calculation need not be thread-safe, as lombok + takes care of locking. +

+
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Small print

+

+ Lombok actually creates a few fields all prefixed with $lombok$ 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, always use the generated getter. +

+ Other Lombok annotations such as @ToString always call the getter even if you use doNotUseGetters=true. +

+
+
+ +
+
+
+ + + -- cgit