From 218f28cc95ee30d5d362c3ac9d5440c2f86fd712 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Tue, 16 Jul 2019 02:07:39 +0200 Subject: [website] [fixes #2167] be more clear about how the constructor generation interacts if both `@Value` and `@Builder` are on the same class. --- website/templates/features/Value.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'website/templates/features/Value.html') diff --git a/website/templates/features/Value.html b/website/templates/features/Value.html index 5d97a7b8..f6ef9403 100644 --- a/website/templates/features/Value.html +++ b/website/templates/features/Value.html @@ -15,7 +15,7 @@

@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, except that explicitly including an implementation of any of the relevant methods simply means that part won't be generated and no warning will be emitted. For example, if you write your own toString, no error occurs, and lombok will not generate a toString. Also, any explicit constructor, no matter the arguments list, implies lombok will not generate a constructor. If you do want lombok to generate the all-args constructor, add @AllArgsConstructor to the class. You can mark any constructor or method with @lombok.experimental.Tolerate to hide them from lombok. + In practice, @Value is shorthand for: final @ToString @EqualsAndHashCode @AllArgsConstructor @FieldDefaults(makeFinal = true, level = AccessLevel.PRIVATE) @Getter, except that explicitly including an implementation of any of the relevant methods simply means that part won't be generated and no warning will be emitted. For example, if you write your own toString, no error occurs, and lombok will not generate a toString. Also, any explicit constructor, no matter the arguments list, implies lombok will not generate a constructor. If you do want lombok to generate the all-args constructor, add @AllArgsConstructor to the class. Note that if both `@Builder` and `@Value` are on a class, the package private allargs constructor that `@Builder` wants to make 'wins' over the public one that `@Value` wants to make. You can mark any constructor or method with @lombok.experimental.Tolerate to hide them from lombok.

It is possible to override the final-by-default and private-by-default behavior using either an explicit access level on a field, or by using the @NonFinal or @PackagePrivate annotations. @NonFinal can also be used on a class to remove the final keyword.
It is possible to override any default behavior for any of the 'parts' that make up @Value by explicitly using that annotation. -- cgit