Package net.bytebuddy.build
Class HashCodeAndEqualsPlugin
- java.lang.Object
-
- net.bytebuddy.build.HashCodeAndEqualsPlugin
-
- All Implemented Interfaces:
Plugin
,ElementMatcher<TypeDescription>
- Direct Known Subclasses:
HashCodeAndEqualsPlugin.WithNonNullableFields
public class HashCodeAndEqualsPlugin extends java.lang.Object implements Plugin
A build tool plugin that addsObject.hashCode()
andObject.equals(Object)
methods to a class if theHashCodeAndEqualsPlugin.Enhance
annotation is present and no explicit method declaration was added.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
HashCodeAndEqualsPlugin.Enhance
Instructs theHashCodeAndEqualsPlugin
to generateObject.hashCode()
andObject.equals(Object)
for the annotated class unless these methods are already declared explicitly.static interface
HashCodeAndEqualsPlugin.ValueHandling
Determines how a field should be used within generated hash code and equality methods.protected static class
HashCodeAndEqualsPlugin.ValueMatcher
An element matcher for aHashCodeAndEqualsPlugin.ValueHandling
annotation.static class
HashCodeAndEqualsPlugin.WithNonNullableFields
A version of theHashCodeAndEqualsPlugin
that assumes that all fields are non-nullable unless they are explicitly marked.-
Nested classes/interfaces inherited from interface net.bytebuddy.matcher.ElementMatcher
ElementMatcher.Junction<S>
-
-
Constructor Summary
Constructors Constructor Description HashCodeAndEqualsPlugin()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DynamicType.Builder<?>
apply(DynamicType.Builder<?> builder, TypeDescription typeDescription)
Applies this plugin.boolean
matches(TypeDescription target)
Matches a target against this element matcher.protected ElementMatcher<FieldDescription>
nonNullable(ElementMatcher<FieldDescription> matcher)
Resolves the matcher to identify non-nullable fields.
-
-
-
Method Detail
-
matches
public boolean matches(TypeDescription target)
Description copied from interface:ElementMatcher
Matches a target against this element matcher.- Specified by:
matches
in interfaceElementMatcher<TypeDescription>
- Parameters:
target
- The instance to be matched.- Returns:
true
if the given element is matched by this matcher orfalse
otherwise.
-
apply
public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription)
Description copied from interface:Plugin
Applies this plugin.
-
nonNullable
protected ElementMatcher<FieldDescription> nonNullable(ElementMatcher<FieldDescription> matcher)
Resolves the matcher to identify non-nullable fields.- Parameters:
matcher
- The matcher that identifies fields that are either nullable or non-nullable.- Returns:
- The actual matcher to identify non-nullable fields.
-
-