@Target(TYPE)
@Retention(SOURCE)
public @interface EqualsAndHashCode
equals and hashCode methods inherited by all objects, based on relevant fields.
Complete documentation is found at the project lombok features page for @EqualsAndHashCode.
| Modifier and Type | Optional Element | Description |
|---|---|---|
boolean |
callSuper |
Call on the superclass's implementations of
equals and hashCode before calculating for the fields in this class. |
boolean |
doNotUseGetters |
Normally, if getters are available, those are called.
|
java.lang.String[] |
exclude |
Any fields listed here will not be taken into account in the generated
equals and hashCode implementations. |
java.lang.String[] |
of |
If present, explicitly lists the fields that are to be used for identity.
|
boolean |
onlyExplicitlyIncluded |
Only include fields and methods explicitly marked with
@EqualsAndHashCode.Include. |
EqualsAndHashCode.AnyAnnotation[] |
onParam |
Any annotations listed here are put on the generated parameter of
equals and canEqual. |
java.lang.String[] exclude
equals and hashCode implementations.
Mutually exclusive with of().
Will soon be marked @Deprecated; use the @EqualsAndHashCode.Exclude annotation instead.
java.lang.String[] of
Mutually exclusive with exclude().
Will soon be marked @Deprecated; use the @EqualsAndHashCode.Include annotation together with @EqualsAndHashCode(onlyExplicitlyIncluded = true).
boolean callSuper
equals and hashCode before calculating for the fields in this class.
default: falseequals implementation as part of the generated equals algorithm.boolean doNotUseGetters
true.
default: falsetrue, always use direct field access instead of calling the getter method.EqualsAndHashCode.AnyAnnotation[] onParam
equals and canEqual.
This is useful to add for example a Nullable annotation.@EqualsAndHashCode(onParam=@__({@AnnotationsGoHere}))@EqualsAndHashCode(onParam_={@AnnotationsGohere}) // note the underscore after onParam.equals() method.Copyright © 2009-2018 The Project Lombok Authors, licensed under the MIT licence.