From d8da2b9438056e945ecc38d98fed413444c847b3 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 2 Feb 2015 04:47:21 +0100 Subject: added impl for @UtilityClass. --- website/features/experimental/UtilityClass.html | 80 +++++++++++++++++++++++++ website/features/experimental/index.html | 2 + website/features/experimental/onX.html | 2 +- 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 website/features/experimental/UtilityClass.html (limited to 'website/features/experimental') diff --git a/website/features/experimental/UtilityClass.html b/website/features/experimental/UtilityClass.html new file mode 100644 index 00000000..5526ec77 --- /dev/null +++ b/website/features/experimental/UtilityClass.html @@ -0,0 +1,80 @@ + + + + + + + + @UtilityClass +
+
+
+ +

@UtilityClass

+ +
+

Since

+

+ @UtilityClass was introduced as an experimental feature in lombok v1.16.2. +

+
+
+

Experimental

+

+ Experimental because: +

    +
  • Some debate as to whether its common enough to count as boilerplate.
  • +
+ Current status: positive - Currently we feel this feature may move out of experimental status with no or minor changes soon. +
+
+

Overview

+

+ A utility class is a class that is just a namespace for functions. No instances of it can exist, and all its members + are static. For example, java.lang.Math and java.util.Collections are well known utility classes. This annotation automatically turns the annotated class into one. +

+ A utility class cannot be instantiated. By marking your class with @UtilityClass, lombok will automatically + generate a private constructor that throws an exception, flags as error any explicit constructors you add, and marks + the class final. If the class is an inner class, the class is also marked static. +

+ All members of a utility class are automatically marked as static. Even fields and inner classes. +

+
+
+
+

With Lombok

+
@HTML_PRE@
+
+
+
+

Vanilla Java

+
@HTML_POST@
+
+
+
+
+

Small print

+

+ There isn't currently any way to create non-static members, or to define your own constructor. If you want to instantiate + the utility class, even only as an internal implementation detail, @UtilityClass cannot be used. +

+
+
+ +
+
+
+ + + diff --git a/website/features/experimental/index.html b/website/features/experimental/index.html index a5932b73..3f2d2802 100644 --- a/website/features/experimental/index.html +++ b/website/features/experimental/index.html @@ -34,6 +34,8 @@
Immutable 'setters' - methods that create a clone but with one changed field.
onMethod= / onConstructor= / onParam=
Sup dawg, we heard you like annotations, so we put annotations in your annotations so you can annotate while you're annotating.
+
@UtilityClass
+
Utility, metility, wetility! Utility classes for the masses.
diff --git a/website/features/experimental/onX.html b/website/features/experimental/onX.html index 064db557..ced78dff 100644 --- a/website/features/experimental/onX.html +++ b/website/features/experimental/onX.html @@ -69,7 +69,7 @@
-- cgit