From f1124aad02569c983cb8979445245141bf029a88 Mon Sep 17 00:00:00 2001
From: Reinier Zwitserloot See the small print of
- Any annotations named
By setting
Attempting to exclude fields that don't exist or would have been excluded anyway (because they are static or transient) results in warnings on the named fields.
You therefore don't have to worry about typos.
+
+ Having both
+ By default, any variables that start with a $ symbol are excluded automatically. You can only include them by using the 'of' parameter.
@ToString, @EqualsAndHashCode and
@Getter / @Setter.
@NonNull or @NotNull (case insensitive) on a field are interpreted as: This field must not ever hold
+ Any annotations named @NonNull (case insensitive) on a field are interpreted as: This field must not ever hold
null. Therefore, these annotations result in an explicit null check in the generated constructor for the provided field. Also, these
annotations (as well as any annotation named @Nullable) are copied to the constructor parameter, in both the true constructor and
any static constructor. The same principle applies to generated getters and setters (see the documentation for @Getter / @Setter)
diff --git a/website/features/EqualsAndHashCode.html b/website/features/EqualsAndHashCode.html
index d42891e7..d2575244 100644
--- a/website/features/EqualsAndHashCode.html
+++ b/website/features/EqualsAndHashCode.html
@@ -18,6 +18,7 @@
Any class definition may be annotated with @EqualsAndHashCode to let lombok generate implementations of the
equals(Object other) and hashCode() methods. By default, it'll use all non-static, non-transient
fields, but you can exclude more fields by naming them in the optional exclude parameter to the annotation.
+ Alternatively, you can specify exactly which fields you wish to be used by naming them in the of parameter.
callSuper to true, you can include the equals and hashCode methods of your superclass in the generated methods.
For hashCode, the result of super.hashCode() is included in the hash algorithm, and for equals, the generated method will return
@@ -65,6 +66,10 @@
exclude and of generates a warning; the exclude parameter will be ignored in that case.
+ boolean will not result in using the is prefix instead of the get prefix; for example,
returning java.lang.Boolean results in a get prefix, not an is prefix.
- Any annotations named @NonNull or @NotNull (case insensitive) on the field are interpreted as: This field must not ever hold
+ Any annotations named @NonNull (case insensitive) on the field are interpreted as: This field must not ever hold
null. Therefore, these annotations result in an explicit null check in the generated setter. Also, these
annotations (as well as any annotation named @Nullable) are copied to setter parameter and getter method
includeFieldNames parameter to true you can add some clarity (but also quite some length) to
the output of the toString() method.
- All non-static fields will be printed. If you want to skip some fields, you can name them in the exclude parameter; each named
- field will not be printed at all.
+ By default, all non-static fields will be printed. If you want to skip some fields, you can name them in the exclude parameter; each named
+ field will not be printed at all. Alternatively, you can specify exactly which fields you wish to be used by naming them in the of parameter.
By setting callSuper to true, you can include the output of the superclass implementation of toString to the
output. Be aware that the default implementation of toString() in java.lang.Object is pretty much meaningless, so you
@@ -53,8 +53,12 @@
Attempting to exclude fields that don't exist or would have been excluded anyway (because they are static) results in warnings on the named fields.
You therefore don't have to worry about typos.
+ Having both exclude and of generates a warning; the exclude parameter will be ignored in that case.
+
We don't promise to keep the output of the generated toString() methods the same between lombok versions. You should never design your API so that
other code is forced to parse your toString() output anyway!
+
+ By default, any variables that start with a $ symbol are excluded automatically. You can only include them by using the 'of' parameter.
-- cgit