Top Description Inners Fields Constructors Methods
net.bytebuddy.build

public Class HashCodeAndEqualsPlugin

extends Object
implements Plugin, Factory, Factory, MethodAttributeAppender
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.attribute.MethodAttributeAppender, net.bytebuddy.implementation.attribute.MethodAttributeAppender.Factory, net.bytebuddy.build.Plugin.Factory, net.bytebuddy.build.Plugin, java.io.Closeable, java.lang.AutoCloseable, net.bytebuddy.matcher.ElementMatcher
Known Direct Subclasses
net.bytebuddy.build.HashCodeAndEqualsPlugin.WithNonNullableFields
Annotations
@Enhance
Imports
edu.umd.cs.findbugs.annotations.SuppressFBWarnings, net.bytebuddy.description.annotation.AnnotationDescription, net.bytebuddy.description.field.FieldDescription, net.bytebuddy.description.method.MethodDescription, .MethodList, net.bytebuddy.description.type.TypeDefinition, .TypeDescription, net.bytebuddy.dynamic.ClassFileLocator, .DynamicType, net.bytebuddy.implementation.EqualsMethod, .HashCodeMethod, net.bytebuddy.implementation.attribute.AnnotationValueFilter, .MethodAttributeAppender, net.bytebuddy.matcher.ElementMatcher, .ElementMatchers, net.bytebuddy.utility.nullability.MaybeNull, net.bytebuddy.jar.asm.AnnotationVisitor, .MethodVisitor, java.lang.annotation.*, java.util.Comparator

A build tool plugin that adds Object#hashCode() and Object#equals(Object) methods to a class if the Enhance annotation is present and no explicit method declaration was added. This plugin does not need to be closed.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static enum
HashCodeAndEqualsPlugin.AnnotationOrderComparator

A comparator that arranges fields in the order of Sorted.

public 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.

public static @interface
HashCodeAndEqualsPlugin.Sorted

Determines the sort order of fields for the equality check when implementing the Object#equals(Object) method.

public 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 ValueHandling annotation.

public static class
HashCodeAndEqualsPlugin.WithNonNullableFields

A version of the HashCodeAndEqualsPlugin that assumes that all fields are non-nullable unless they are explicitly marked.

Field Summary

Modifier and TypeField and Description
private final String
annotationType

Defines the binary name of a runtime-visible annotation type that should be added to the parameter of the Object#equals(Object) method, or null if no such name should be defined.

private static final MethodDescription.InDefinedShape
private static final MethodDescription.InDefinedShape
ENHANCE_INVOKE_SUPER

A description of the Enhance#invokeSuper() method.

private static final MethodDescription.InDefinedShape
private static final MethodDescription.InDefinedShape
private static final MethodDescription.InDefinedShape
private static final MethodDescription.InDefinedShape
SORTED_VALUE

A description of the Sorted#value() method.

private static final MethodDescription.InDefinedShape
VALUE_HANDLING_VALUE

A description of the ValueHandling#value() method.

Constructor Summary

AccessConstructor and Description
public
HashCodeAndEqualsPlugin()

Creates a new hash code equals plugin.

public
HashCodeAndEqualsPlugin(String
Defines the binary name of a runtime-visible annotation type that should be added to the parameter of the Object#equals(Object) method, or null if no such name should be defined.
annotationType
)

Creates a new hash code equals plugin.

Method Summary

Modifier and TypeMethod and Description
public DynamicType.Builder<?>
apply(DynamicType.Builder<?>
The builder to use as a basis for the applied transformation.
builder
,
TypeDescription
The type being transformed.
typeDescription
,
ClassFileLocator
A class file locator that can locate other types in the scope of the project.
classFileLocator
)

Implements net.bytebuddy.build.Plugin.apply.

Applies this plugin.
public void
apply(MethodVisitor
The method visitor to which the attributes that are represented by this attribute appender are written to.
methodVisitor
,
MethodDescription
The description of the method for which the given method visitor creates an instrumentation for.
methodDescription
,
AnnotationValueFilter
The annotation value filter to apply when the annotations are written.
annotationValueFilter
)

Implements net.bytebuddy.implementation.attribute.MethodAttributeAppender.apply.

Applies this attribute appender to a given method visitor.
public void
close()

Implements java.io.Closeable.close.

Closes this stream and releases any system resources associated with it.
public Plugin
make()

Implements net.bytebuddy.build.Plugin.Factory.make.

Returns a plugin that can be used for a transformation and which is subsequently closed.
public MethodAttributeAppender
make(TypeDescription
The type for which a method attribute appender is to be applied for.
typeDescription
)

Implements net.bytebuddy.implementation.attribute.MethodAttributeAppender.Factory.make.

Returns a method attribute appender that is applicable for a given type description.
public boolean
matches(TypeDescription
The instance to be matched or null.
target
)

Implements net.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.
protected ElementMatcher<FieldDescription>

Returns:

The actual matcher to identify non-nullable fields.
nonNullable
(ElementMatcher<FieldDescription>
The matcher that identifies fields that are either nullable or non-nullable.
matcher
)

Resolves the matcher to identify non-nullable fields.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationTypeback to summary
private final String annotationType

Defines the binary name of a runtime-visible annotation type that should be added to the parameter of the Object#equals(Object) method, or null if no such name should be defined.

Annotations
@MaybeNull
@ValueHandling:REVERSE_NULLABILITY
ENHANCE_INCLUDE_SYNTHETIC_FIELDSback to summary
private static final MethodDescription.InDefinedShape ENHANCE_INCLUDE_SYNTHETIC_FIELDS

A description of the Enhance#includeSyntheticFields() method.

ENHANCE_INVOKE_SUPERback to summary
private static final MethodDescription.InDefinedShape ENHANCE_INVOKE_SUPER

A description of the Enhance#invokeSuper() method.

ENHANCE_PERMIT_SUBCLASS_EQUALITYback to summary
private static final MethodDescription.InDefinedShape ENHANCE_PERMIT_SUBCLASS_EQUALITY

A description of the Enhance#permitSubclassEquality() method.

ENHANCE_SIMPLE_COMPARISON_FIRSTback to summary
private static final MethodDescription.InDefinedShape ENHANCE_SIMPLE_COMPARISON_FIRST

A description of the Enhance#simpleComparisonsFirst() method.

ENHANCE_USE_TYPE_HASH_CONSTANTback to summary
private static final MethodDescription.InDefinedShape ENHANCE_USE_TYPE_HASH_CONSTANT

A description of the Enhance#useTypeHashConstant() method.

SORTED_VALUEback to summary
private static final MethodDescription.InDefinedShape SORTED_VALUE

A description of the Sorted#value() method.

VALUE_HANDLING_VALUEback to summary
private static final MethodDescription.InDefinedShape VALUE_HANDLING_VALUE

A description of the ValueHandling#value() method.

Constructor Detail

HashCodeAndEqualsPluginback to summary
public HashCodeAndEqualsPlugin()

Creates a new hash code equals plugin.

HashCodeAndEqualsPluginback to summary
public HashCodeAndEqualsPlugin(String annotationType)

Creates a new hash code equals plugin.

Parameters
annotationType:String

Defines the binary name of a runtime-visible annotation type that should be added to the parameter of the Object#equals(Object) method, or null if no such name should be defined.

Method Detail

applyback to summary
public DynamicType.Builder<?> apply(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassFileLocator classFileLocator)

Implements net.bytebuddy.build.Plugin.apply.

Doc from net.bytebuddy.build.Plugin.apply.

Applies this plugin.

Parameters
builder:DynamicType.Builder<?>

The builder to use as a basis for the applied transformation.

typeDescription:TypeDescription

The type being transformed.

classFileLocator:ClassFileLocator

A class file locator that can locate other types in the scope of the project.

Returns:DynamicType.Builder<?>

The supplied builder with additional transformations registered.

Annotations
@SuppressFBWarnings:NP_NULL_ON_SOME_PATH_FROM_RETURN_VALUE
justification:Annotation presence is required by matcher.
applyback to summary
public void apply(MethodVisitor methodVisitor, MethodDescription methodDescription, AnnotationValueFilter annotationValueFilter)

Implements net.bytebuddy.implementation.attribute.MethodAttributeAppender.apply.

Doc from net.bytebuddy.implementation.attribute.MethodAttributeAppender.apply.

Applies this attribute appender to a given method visitor.

Parameters
methodVisitor:MethodVisitor

The method visitor to which the attributes that are represented by this attribute appender are written to.

methodDescription:MethodDescription

The description of the method for which the given method visitor creates an instrumentation for.

annotationValueFilter:AnnotationValueFilter

The annotation value filter to apply when the annotations are written.

closeback to summary
public void close()

Implements java.io.Closeable.close.

Doc from java.io.Closeable.close.

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

makeback to summary
public Plugin make()

Implements net.bytebuddy.build.Plugin.Factory.make.

Doc from net.bytebuddy.build.Plugin.Factory.make.

Returns a plugin that can be used for a transformation and which is subsequently closed.

Returns:Plugin

The plugin to use for type transformations.

makeback to summary
public MethodAttributeAppender make(TypeDescription typeDescription)

Implements net.bytebuddy.implementation.attribute.MethodAttributeAppender.Factory.make.

Doc from net.bytebuddy.implementation.attribute.MethodAttributeAppender.Factory.make.

Returns a method attribute appender that is applicable for a given type description.

Parameters
typeDescription:TypeDescription

The type for which a method attribute appender is to be applied for.

Returns:MethodAttributeAppender

The method attribute appender which should be applied for the given type.

matchesback to summary
public boolean matches(TypeDescription target)

Implements net.bytebuddy.matcher.ElementMatcher.matches.

Doc from net.bytebuddy.matcher.ElementMatcher.matches.

Matches a target against this element matcher.

Parameters
target:TypeDescription

The instance to be matched or null.

Returns:boolean

true if the given element is matched by this matcher or false otherwise.

nonNullableback to summary
protected ElementMatcher<FieldDescription> nonNullable(ElementMatcher<FieldDescription> matcher)

Resolves the matcher to identify non-nullable fields.

Parameters
matcher:ElementMatcher<FieldDescription>

The matcher that identifies fields that are either nullable or non-nullable.

Returns:ElementMatcher<FieldDescription>

The actual matcher to identify non-nullable fields.

net.bytebuddy.build back to summary

protected final Enum HashCodeAndEqualsPlugin.AnnotationOrderComparator

extends Enum<HashCodeAndEqualsPlugin.AnnotationOrderComparator>
implements Comparator<FieldDescription.InDefinedShape>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

A comparator that arranges fields in the order of Sorted.

Field Summary

Modifier and TypeField and Description
public static final HashCodeAndEqualsPlugin.AnnotationOrderComparator
INSTANCE

The singleton instance.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(FieldDescription.InDefinedShape
the first object to be compared.
left
,
FieldDescription.InDefinedShape
the second object to be compared.
right
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
public static HashCodeAndEqualsPlugin.AnnotationOrderComparator
public static HashCodeAndEqualsPlugin.AnnotationOrderComparator[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

INSTANCEback to summary
public static final HashCodeAndEqualsPlugin.AnnotationOrderComparator INSTANCE

The singleton instance.

Constructor Detail

AnnotationOrderComparatorback to summary
private AnnotationOrderComparator()

Method Detail

compareback to summary
public int compare(FieldDescription.InDefinedShape left, FieldDescription.InDefinedShape right)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
left:FieldDescription.InDefinedShape

the first object to be compared.

right:FieldDescription.InDefinedShape

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

valueOfback to summary
public static HashCodeAndEqualsPlugin.AnnotationOrderComparator valueOf(String name)
valuesback to summary
public static HashCodeAndEqualsPlugin.AnnotationOrderComparator[] values()
net.bytebuddy.build back to summary

public @Interface HashCodeAndEqualsPlugin.Enhance

extends Annotation
Annotations
@Documented
@Target:TYPE
@Retention:RUNTIME

Instructs the HashCodeAndEqualsPlugin to generate Object#hashCode() and Object#equals(Object) for the annotated class unless these methods are already declared explicitly.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
HashCodeAndEqualsPlugin.Enhance.InvokeSuper

A strategy for determining the base value of a hash code or equality contract.

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if synthetic fields should be included.
includeSyntheticFields
()

Determines if synthetic fields should be included in the hash code and equality contract.

public HashCodeAndEqualsPlugin.Enhance.InvokeSuper

Returns:

A strategy for determining the base value.
invokeSuper
()

Determines the base value of any added method, i.e. if hash code or equality is based on the super type or not.

public boolean

Returns:

true if instances subclasses of the instrumented type are accepted upon an equality check.
permitSubclassEquality
()

Determines if instances subclasses of the instrumented type are accepted upon an equality check.

public boolean

Returns:

true if fields with simple comparison methods should be compared first.
simpleComparisonsFirst
()

Determines if fields with primitive types, then enumeration types, then primtive wrapper types and then String types should be compared for equality before fields with other types.

public boolean

Returns:

true if the hash code constant should be derived of the instrumented type.
useTypeHashConstant
()

Determines if the hash code constant should be derived of the instrumented type.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

includeSyntheticFieldsback to summary
public boolean includeSyntheticFields()

Determines if synthetic fields should be included in the hash code and equality contract.

Returns:boolean

true if synthetic fields should be included.

invokeSuperback to summary
public HashCodeAndEqualsPlugin.Enhance.InvokeSuper invokeSuper()

Determines the base value of any added method, i.e. if hash code or equality is based on the super type or not.

Returns:HashCodeAndEqualsPlugin.Enhance.InvokeSuper

A strategy for determining the base value.

permitSubclassEqualityback to summary
public boolean permitSubclassEquality()

Determines if instances subclasses of the instrumented type are accepted upon an equality check.

Returns:boolean

true if instances subclasses of the instrumented type are accepted upon an equality check.

simpleComparisonsFirstback to summary
public boolean simpleComparisonsFirst()

Determines if fields with primitive types, then enumeration types, then primtive wrapper types and then String types should be compared for equality before fields with other types. Before determining such a field order, the Sorted property is always considered first if it is defined.

Returns:boolean

true if fields with simple comparison methods should be compared first.

useTypeHashConstantback to summary
public boolean useTypeHashConstant()

Determines if the hash code constant should be derived of the instrumented type. If Enhance#permitSubclassEquality() is set to true, this constant is derived of the declared class, otherwise the type hash is computed of the active instance.

Returns:boolean

true if the hash code constant should be derived of the instrumented type.

net.bytebuddy.build back to summary

public sealed Enum HashCodeAndEqualsPlugin.Enhance.InvokeSuper

extends Enum<HashCodeAndEqualsPlugin.Enhance.InvokeSuper>
Class Inheritance

A strategy for determining the base value of a hash code or equality contract.

Field Summary

Modifier and TypeField and Description
public static final HashCodeAndEqualsPlugin.Enhance.InvokeSuper
ALWAYS

Always invokes the super class's hash code and equality methods.

public static final HashCodeAndEqualsPlugin.Enhance.InvokeSuper
IF_ANNOTATED

Only invokes the super method's hash code and equality methods if the super class is also annotated with Enhance.

public static final HashCodeAndEqualsPlugin.Enhance.InvokeSuper
IF_DECLARED

Only invokes the super method's hash code and equality methods if any super class that is not Object explicitly defines such a method.

public static final HashCodeAndEqualsPlugin.Enhance.InvokeSuper
NEVER

Never invokes the super class's hash code and equality methods.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected abstract EqualsMethod

Returns:

The equals method to use.
equalsMethod
(TypeDescription
The instrumented type.
instrumentedType
)

Resolves the equals method to use.

protected abstract HashCodeMethod

Returns:

The hash code method to use.
hashCodeMethod
(TypeDescription
The instrumented type.
instrumentedType
,
boolean
true if the base hash should be based on the instrumented class's type.
typeHash
,
boolean
true if subclasses can be equal to their base classes.
subclassEquality
)

Resolves the hash code method to use.

public static HashCodeAndEqualsPlugin.Enhance.InvokeSuper
public static HashCodeAndEqualsPlugin.Enhance.InvokeSuper[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ALWAYSback to summary
public static final HashCodeAndEqualsPlugin.Enhance.InvokeSuper ALWAYS

Always invokes the super class's hash code and equality methods.

IF_ANNOTATEDback to summary
public static final HashCodeAndEqualsPlugin.Enhance.InvokeSuper IF_ANNOTATED

Only invokes the super method's hash code and equality methods if the super class is also annotated with Enhance.

IF_DECLAREDback to summary
public static final HashCodeAndEqualsPlugin.Enhance.InvokeSuper IF_DECLARED

Only invokes the super method's hash code and equality methods if any super class that is not Object explicitly defines such a method.

NEVERback to summary
public static final HashCodeAndEqualsPlugin.Enhance.InvokeSuper NEVER

Never invokes the super class's hash code and equality methods.

Constructor Detail

InvokeSuperback to summary
private InvokeSuper()

Method Detail

equalsMethodback to summary
protected abstract EqualsMethod equalsMethod(TypeDescription instrumentedType)

Resolves the equals method to use.

Parameters
instrumentedType:TypeDescription

The instrumented type.

Returns:EqualsMethod

The equals method to use.

hashCodeMethodback to summary
protected abstract HashCodeMethod hashCodeMethod(TypeDescription instrumentedType, boolean typeHash, boolean subclassEquality)

Resolves the hash code method to use.

Parameters
instrumentedType:TypeDescription

The instrumented type.

typeHash:boolean

true if the base hash should be based on the instrumented class's type.

subclassEquality:boolean

true if subclasses can be equal to their base classes.

Returns:HashCodeMethod

The hash code method to use.

valueOfback to summary
public static HashCodeAndEqualsPlugin.Enhance.InvokeSuper valueOf(String name)
valuesback to summary
public static HashCodeAndEqualsPlugin.Enhance.InvokeSuper[] values()
net.bytebuddy.build back to summary

public @Interface HashCodeAndEqualsPlugin.Sorted

extends Annotation
Annotations
@Documented
@Target:FIELD
@Retention:RUNTIME

Determines the sort order of fields for the equality check when implementing the Object#equals(Object) method. Any field that is not annotated is considered with a value of Sorted#DEFAULT where fields with a higher value are checked for equality first. This sort order is applied first after which the type order is considered if Enhance#simpleComparisonsFirst() is considered as additional sort criteria.

Field Summary

Modifier and TypeField and Description
public static final int
DEFAULT

The default sort weight.

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

The value for the sort order where fields with higher values are checked for equality first.
value
()

The value for the sort order where fields with higher values are checked for equality first.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Field Detail

DEFAULTback to summary
public static final int DEFAULT

The default sort weight.

Method Detail

valueback to summary
public int value()

The value for the sort order where fields with higher values are checked for equality first.

Returns:int

The value for the sort order where fields with higher values are checked for equality first.

net.bytebuddy.build back to summary

public @Interface HashCodeAndEqualsPlugin.ValueHandling

extends Annotation
Annotations
@Documented
@Target:FIELD
@Retention:RUNTIME

Determines how a field should be used within generated hash code and equality methods.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
HashCodeAndEqualsPlugin.ValueHandling.Sort

Determines how a field should be handled.

Method Summary

Modifier and TypeMethod and Description
public HashCodeAndEqualsPlugin.ValueHandling.Sort

Returns:

The handling of the annotated field.
value
()

Determines the handling of the annotated field.

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public HashCodeAndEqualsPlugin.ValueHandling.Sort value()

Determines the handling of the annotated field.

Returns:HashCodeAndEqualsPlugin.ValueHandling.Sort

The handling of the annotated field.

net.bytebuddy.build back to summary

public final Enum HashCodeAndEqualsPlugin.ValueHandling.Sort

extends Enum<HashCodeAndEqualsPlugin.ValueHandling.Sort>
Class Inheritance

Determines how a field should be handled.

Field Summary

Modifier and TypeField and Description
public static final HashCodeAndEqualsPlugin.ValueHandling.Sort
IGNORE

Excludes the field from hash code and equality methods.

public static final HashCodeAndEqualsPlugin.ValueHandling.Sort
REVERSE_NULLABILITY

Reverses the nullability of the field, i.e. assumes this field to be non-null or null if WithNonNullableFields is used.

Constructor Summary

AccessConstructor and Description
private
Sort()

Field Detail

IGNOREback to summary
public static final HashCodeAndEqualsPlugin.ValueHandling.Sort IGNORE

Excludes the field from hash code and equality methods.

REVERSE_NULLABILITYback to summary
public static final HashCodeAndEqualsPlugin.ValueHandling.Sort REVERSE_NULLABILITY

Reverses the nullability of the field, i.e. assumes this field to be non-null or null if WithNonNullableFields is used.

Constructor Detail

Sortback to summary
private Sort()

Method Detail

valueOfback to summary
public static HashCodeAndEqualsPlugin.ValueHandling.Sort valueOf(String name)
valuesback to summary
public static HashCodeAndEqualsPlugin.ValueHandling.Sort[] values()
net.bytebuddy.build back to summary

protected Class HashCodeAndEqualsPlugin.ValueMatcher

extends ElementMatcher.Junction.ForNonNullValues<FieldDescription>
Class Inheritance
Annotations
@Enhance

An element matcher for a ValueHandling annotation.

Field Summary

Modifier and TypeField and Description
private final HashCodeAndEqualsPlugin.ValueHandling.Sort
sort

The matched value.

Constructor Summary

AccessConstructor and Description
protected
ValueMatcher(HashCodeAndEqualsPlugin.ValueHandling.Sort
The matched value.
sort
)

Creates a new value matcher.

Method Summary

Modifier and TypeMethod and Description
protected boolean
doMatch(FieldDescription
The instance to be matched.
target
)

Implements abstract net.bytebuddy.matcher.ElementMatcher.Junction.ForNonNullValues.doMatch.

Matches the supplied value if it was found not to be null.
Inherited from net.bytebuddy.matcher.ElementMatcher.Junction.ForNonNullValues:
matches

Field Detail

sortback to summary
private final HashCodeAndEqualsPlugin.ValueHandling.Sort sort

The matched value.

Constructor Detail

ValueMatcherback to summary
protected ValueMatcher(HashCodeAndEqualsPlugin.ValueHandling.Sort sort)

Creates a new value matcher.

Parameters
sort:HashCodeAndEqualsPlugin.ValueHandling.Sort

The matched value.

Method Detail

doMatchback to summary
protected boolean doMatch(FieldDescription target)

Implements abstract net.bytebuddy.matcher.ElementMatcher.Junction.ForNonNullValues.doMatch.

Doc from net.bytebuddy.matcher.ElementMatcher.Junction.ForNonNullValues.doMatch.

Matches the supplied value if it was found not to be null.

Parameters
target:FieldDescription

The instance to be matched.

Returns:boolean

true if the given element is matched by this matcher or false otherwise.

net.bytebuddy.build back to summary

public Class HashCodeAndEqualsPlugin.WithNonNullableFields

extends HashCodeAndEqualsPlugin
Class Inheritance
Annotations
@Enhance

A version of the HashCodeAndEqualsPlugin that assumes that all fields are non-nullable unless they are explicitly marked.

Constructor Summary

AccessConstructor and Description
public
WithNonNullableFields()

Creates a new hash code equals plugin where fields are assumed nullable by default.

public
WithNonNullableFields(String
Defines the binary name of a runtime-visible annotation type that should be added to the parameter of the Object#equals(Object) method, or null if no such name should be defined.
annotationType
)

Creates a new hash code equals plugin where fields are assumed nullable by default.

Method Summary

Modifier and TypeMethod and Description
protected ElementMatcher<FieldDescription>
nonNullable(ElementMatcher<FieldDescription>
The matcher that identifies fields that are either nullable or non-nullable.
matcher
)

Overrides net.bytebuddy.build.HashCodeAndEqualsPlugin.nonNullable.

Resolves the matcher to identify non-nullable fields.
Inherited from net.bytebuddy.build.HashCodeAndEqualsPlugin:
applyapplyclosemakemakematches

Constructor Detail

WithNonNullableFieldsback to summary
public WithNonNullableFields()

Creates a new hash code equals plugin where fields are assumed nullable by default.

WithNonNullableFieldsback to summary
public WithNonNullableFields(String annotationType)

Creates a new hash code equals plugin where fields are assumed nullable by default.

Parameters
annotationType:String

Defines the binary name of a runtime-visible annotation type that should be added to the parameter of the Object#equals(Object) method, or null if no such name should be defined.

Method Detail

nonNullableback to summary
protected ElementMatcher<FieldDescription> nonNullable(ElementMatcher<FieldDescription> matcher)

Overrides net.bytebuddy.build.HashCodeAndEqualsPlugin.nonNullable.

Doc from net.bytebuddy.build.HashCodeAndEqualsPlugin.nonNullable.

Resolves the matcher to identify non-nullable fields.

Parameters
matcher:ElementMatcher<FieldDescription>

The matcher that identifies fields that are either nullable or non-nullable.

Returns:ElementMatcher<FieldDescription>

The actual matcher to identify non-nullable fields.