@HashCodeAndEqualsPlugin.Enhance public class HashCodeAndEqualsPlugin extends Object implements Plugin, Plugin.Factory, MethodAttributeAppender.Factory, MethodAttributeAppender
Object.hashCode()
and Object.equals(Object)
methods to a class if the
HashCodeAndEqualsPlugin.Enhance
annotation is present and no explicit method declaration was added. This plugin does not need to be closed.Modifier and Type | Class and Description |
---|---|
protected static class |
HashCodeAndEqualsPlugin.AnnotationOrderComparator
A comparator that arranges fields in the order of
HashCodeAndEqualsPlugin.Sorted . |
static interface |
HashCodeAndEqualsPlugin.Enhance
Instructs the
HashCodeAndEqualsPlugin to generate Object.hashCode() and Object.equals(Object) for the annotated
class unless these methods are already declared explicitly. |
static interface |
HashCodeAndEqualsPlugin.Sorted
Determines the sort order of fields for the equality check when implementing the
Object.equals(Object) method. |
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 a
HashCodeAndEqualsPlugin.ValueHandling annotation. |
static class |
HashCodeAndEqualsPlugin.WithNonNullableFields
A version of the
HashCodeAndEqualsPlugin that assumes that all fields are non-nullable unless they are explicitly marked. |
Plugin.Engine, Plugin.Factory, Plugin.ForElementMatcher, Plugin.NoOp, Plugin.WithPreprocessor
ElementMatcher.Junction<S>
Plugin.Factory.Simple, Plugin.Factory.UsingReflection
MethodAttributeAppender.Factory.Compound
MethodAttributeAppender.Compound, MethodAttributeAppender.Explicit, MethodAttributeAppender.Factory, MethodAttributeAppender.ForInstrumentedMethod, MethodAttributeAppender.ForReceiverType, MethodAttributeAppender.NoOp
Constructor and Description |
---|
HashCodeAndEqualsPlugin()
Creates a new hash code equals plugin without JSR305 annotations.
|
HashCodeAndEqualsPlugin(boolean jsr305)
Creates a new hash code equals plugin.
|
Modifier and Type | Method and Description |
---|---|
DynamicType.Builder<?> |
apply(DynamicType.Builder<?> builder,
TypeDescription typeDescription,
ClassFileLocator classFileLocator)
Applies this plugin.
|
void |
apply(org.objectweb.asm.MethodVisitor methodVisitor,
MethodDescription methodDescription,
AnnotationValueFilter annotationValueFilter)
Applies this attribute appender to a given method visitor.
|
void |
close() |
Plugin |
make()
Returns a plugin that can be used for a transformation and which is subsequently closed.
|
MethodAttributeAppender |
make(TypeDescription typeDescription)
Returns a method attribute appender that is applicable for a given type description.
|
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.
|
public HashCodeAndEqualsPlugin()
public HashCodeAndEqualsPlugin(boolean jsr305)
jsr305
- If true
, a JSR305 annotation is added to the Object.equals(Object)
method's parameter.public Plugin make()
make
in interface Plugin.Factory
public boolean matches(@CheckForNull TypeDescription target)
matches
in interface ElementMatcher<TypeDescription>
target
- The instance to be matched or null
.true
if the given element is matched by this matcher or false
otherwise.public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator)
apply
in interface Plugin
builder
- The builder to use as a basis for the applied transformation.typeDescription
- The type being transformed.classFileLocator
- A class file locator that can locate other types in the scope of the project.protected ElementMatcher<FieldDescription> nonNullable(ElementMatcher<FieldDescription> matcher)
matcher
- The matcher that identifies fields that are either nullable or non-nullable.public void close()
close
in interface Closeable
close
in interface AutoCloseable
public MethodAttributeAppender make(TypeDescription typeDescription)
make
in interface MethodAttributeAppender.Factory
typeDescription
- The type for which a method attribute appender is to be applied for.public void apply(org.objectweb.asm.MethodVisitor methodVisitor, MethodDescription methodDescription, AnnotationValueFilter annotationValueFilter)
apply
in interface MethodAttributeAppender
methodVisitor
- The method visitor to which the attributes that are represented by this attribute
appender are written to.methodDescription
- The description of the method for which the given method visitor creates an
instrumentation for.annotationValueFilter
- The annotation value filter to apply when the annotations are written.Copyright © 2014–2021. All rights reserved.