From 06537da4e0d1c420c6669f6ce1490ea56adc4d7d Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Mon, 18 Feb 2013 22:42:39 +0100 Subject: Changed @Value to no longer imply @Wither. Usually you want only a few or no withers at all, and adding them is a lot simpler than removing them. This is a breaking change, but then that's why @Value was in experimental in the first place. --- website/features/experimental/Value.html | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) (limited to 'website/features/experimental/Value.html') diff --git a/website/features/experimental/Value.html b/website/features/experimental/Value.html index fb726d7b..d2acfee4 100644 --- a/website/features/experimental/Value.html +++ b/website/features/experimental/Value.html @@ -15,8 +15,9 @@

Since

- @Value was introduced as experimental feature in lombok v0.11.4. -

+ @Value was introduced as experimental feature in lombok v0.11.4. +

+ @Value no longer implies @Wither since lombok v0.11.8.

Experimental

@@ -24,19 +25,16 @@ Experimental because: Current status: positive - Currently we feel this feature may move out of experimental status with no or minor changes soon.

Overview

- @Value is the immutable variant of @Data; all fields are made private and final by default, and instead of setters, each field gets a so-called 'wither', - which is a method that produces a clone with each field having the same value, except for the field you want a new value for. The class itself is also made final by default, because immutability is not something that can - be forced onto a subclass. Like @Data, useful toString(), equals() and hashCode() methods are also generated, each field gets a getter method, and a constructor that covers every + @Value is the immutable variant of @Data; all fields are made private and final by default, and setters are not generated. The class itself is also made final by default, because immutability is not something that can be forced onto a subclass. Like @Data, useful toString(), equals() and hashCode() methods are also generated, each field gets a getter method, and a constructor that covers every argument (except final fields that are initialized in the field declaration) is also generated.

- In practice, @Value is shorthand for: final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter @Wither. + In practice, @Value is shorthand for: final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter.

It is possible to override the final-by-default and private-by-default behaviour using either an explicit access level on a field, or by using the @NonFinal or @PackagePrivate annotations.
It is possible to override any default behaviour for any of the 'parts' that make up @Value by explicitly using that annotation. @@ -57,13 +55,9 @@

Small print

- Look for the documentation on the 'parts' of @Value: @ToString, @EqualsAndHashCode, - @AllArgsConstructor, @FieldDefaults, @Getter, - @Wither. + Look for the documentation on the 'parts' of @Value: @ToString, @EqualsAndHashCode, @AllArgsConstructor, @FieldDefaults, and @Getter.

- For classes with generics, it's useful to have a static method which serves as a constructor, because inference of generic parameters via static methods works in java6 and avoids having to use the diamond operator. - While you can force this by applying an explicit @AllArgsConstructor annotation, there's also the @Value(staticConstructor="of") feature, which will make the generated all-arguments constructor - private, and generates a public static method named of which is a wrapper around this private constructor. + For classes with generics, it's useful to have a static method which serves as a constructor, because inference of generic parameters via static methods works in java6 and avoids having to use the diamond operator. While you can force this by applying an explicit @AllArgsConstructor(staticConstructor="of") annotation, there's also the @Value(staticConstructor="of") feature, which will make the generated all-arguments constructor private, and generates a public static method named of which is a wrapper around this private constructor.

-- cgit