From f1124aad02569c983cb8979445245141bf029a88 Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Thu, 3 Sep 2009 01:44:59 +0200 Subject: Addressed issue #32: The @EqualsAndHashCode and @ToString annotations now support explicitly listing the fields to use, via the new 'of' parameter. We've also added any fields that start with $ to the default excludes list. Lombok itself can generate these fields ($lock of @Synchronized, for example), and in general they probably should count as effectively not part of the class. --- website/features/EqualsAndHashCode.html | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'website/features/EqualsAndHashCode.html') 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.

By setting 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 @@

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 exclude and of generates a warning; the exclude parameter will be ignored in that case. +

+ By default, any variables that start with a $ symbol are excluded automatically. You can only include them by using the 'of' parameter.

-- cgit