Package lombok
Annotation Type EqualsAndHashCode
-
@Target(TYPE) @Retention(SOURCE) public @interface EqualsAndHashCodeGenerates implementations for theequalsandhashCodemethods inherited by all objects, based on relevant fields.Complete documentation is found at the project lombok features page for @EqualsAndHashCode.
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description booleancallSuperCall on the superclass's implementations ofequalsandhashCodebefore calculating for the fields in this class.booleandoNotUseGettersNormally, if getters are available, those are called.java.lang.String[]excludeAny fields listed here will not be taken into account in the generatedequalsandhashCodeimplementations.java.lang.String[]ofIf present, explicitly lists the fields that are to be used for identity.booleanonlyExplicitlyIncludedOnly include fields and methods explicitly marked with@EqualsAndHashCode.Include.EqualsAndHashCode.AnyAnnotation[]onParamAny annotations listed here are put on the generated parameter ofequalsandcanEqual.
-
-
-
Element Detail
-
exclude
java.lang.String[] exclude
Any fields listed here will not be taken into account in the generatedequalsandhashCodeimplementations. Mutually exclusive withof().Will soon be marked
@Deprecated; use the@EqualsAndHashCode.Excludeannotation instead.- Returns:
- A list of fields to exclude.
- Default:
- {}
-
-
-
of
java.lang.String[] of
If present, explicitly lists the fields that are to be used for identity. Normally, all non-static, non-transient fields are used for identity.Mutually exclusive with
exclude().Will soon be marked
@Deprecated; use the@EqualsAndHashCode.Includeannotation together with@EqualsAndHashCode(onlyExplicitlyIncluded = true).- Returns:
- A list of fields to use (default: all of them).
- Default:
- {}
-
-
-
onParam
EqualsAndHashCode.AnyAnnotation[] onParam
Any annotations listed here are put on the generated parameter ofequalsandcanEqual. This is useful to add for example aNullableannotation.
The syntax for this feature depends on JDK version (nothing we can do about that; it's to work around javac bugs).
up to JDK7:
@EqualsAndHashCode(onParam=@__({@AnnotationsGoHere}))
from JDK8:
@EqualsAndHashCode(onParam_={@AnnotationsGohere})// note the underscore afteronParam.- Returns:
- List of annotations to apply to the generated parameter in the
equals()method.
- Default:
- {}
-
-
-
onlyExplicitlyIncluded
boolean onlyExplicitlyIncluded
Only include fields and methods explicitly marked with@EqualsAndHashCode.Include. Normally, all (non-static, non-transient) fields are included by default.- Returns:
- If
true, don't include non-static non-transient fields automatically (default:false).
- Default:
- false
-
-