Top Description Inners Fields Constructors Methods
net.bytebuddy.implementation

public Class EqualsMethod

extends Object
implements Implementation
Class Inheritance
All Implemented Interfaces
net.bytebuddy.implementation.Implementation, net.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable
Annotations
@Enhance
Imports
edu.umd.cs.findbugs.annotations.SuppressFBWarnings, net.bytebuddy.build.HashCodeAndEqualsPlugin, net.bytebuddy.description.field.FieldDescription, net.bytebuddy.description.method.MethodDescription, net.bytebuddy.description.type.TypeDefinition, .TypeDescription, net.bytebuddy.dynamic.scaffold.InstrumentedType, net.bytebuddy.implementation.bytecode.ByteCodeAppender, .StackManipulation, .StackSize, net.bytebuddy.implementation.bytecode.assign.InstanceCheck, .TypeCasting, net.bytebuddy.implementation.bytecode.constant.IntegerConstant, net.bytebuddy.implementation.bytecode.member.FieldAccess, .MethodInvocation, .MethodReturn, .MethodVariableAccess, net.bytebuddy.matcher.ElementMatcher, net.bytebuddy.jar.asm.Label, .MethodVisitor, .Opcodes, java.util.*

An implementation of Object#equals(Object) that takes a class's declared fields into consideration. Equality is resolved by comparing two instances of the same or a compatible class field by field where reference fields must either both be null or where the field value of the instance upon which the method is invoked returns true upon calling the value's equals method. For arrays, the corresponding utilities of java.util.Arrays are used.

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
EqualsMethod.Appender

A byte code appender to implement the EqualsMethod.

protected static class
EqualsMethod.CompoundComparator

A compound comparator that compares the values of multiple fields.

protected static class
EqualsMethod.ConditionalReturn

A conditional return aborts the equality computation if a given condition was reached.

protected static enum
EqualsMethod.NaturalOrderComparator

A comparator that retains the natural order.

protected static interface
EqualsMethod.NullValueGuard

Guards a field value against a potential null value.

protected static enum
EqualsMethod.SuperClassCheck

Checks the equality contract against the super class.

protected static enum
EqualsMethod.TypeCompatibilityCheck

Checks the overall type of the provided argument.

protected static enum
EqualsMethod.TypePropertyComparator

A comparator that sorts fields by a type property.

protected static enum
EqualsMethod.ValueComparator

A value comparator is responsible to compare to values of a given type.

Field Summary

Modifier and TypeField and Description
private final Comparator<? super FieldDescription.InDefinedShape>
comparator

The comparator to apply for ordering fields.

private static final MethodDescription.InDefinedShape
private final ElementMatcher.Junction<? super FieldDescription.InDefinedShape>
ignored

A matcher to filter fields that should not be used for a equality resolution.

private final ElementMatcher.Junction<? super FieldDescription.InDefinedShape>
nonNullable

A matcher to determine fields of a reference type that cannot be null.

private final EqualsMethod.SuperClassCheck
superClassCheck

The baseline equality to check.

private final EqualsMethod.TypeCompatibilityCheck
typeCompatibilityCheck

The instance type compatibility check.

Constructor Summary

AccessConstructor and Description
protected
EqualsMethod(EqualsMethod.SuperClassCheck
The baseline equality to check.
superClassCheck
)

Creates a new equals method implementation.

private
EqualsMethod(EqualsMethod.SuperClassCheck
The baseline equality to check.
superClassCheck
,
EqualsMethod.TypeCompatibilityCheck
The instance type compatibility check.
typeCompatibilityCheck
,
ElementMatcher.Junction<? super FieldDescription.InDefinedShape>
A matcher to filter fields that should not be used for a equality resolution.
ignored
,
ElementMatcher.Junction<? super FieldDescription.InDefinedShape>
A matcher to determine fields of a reference type that cannot be null.
nonNullable
,
Comparator<? super FieldDescription.InDefinedShape>
The comparator to apply for ordering fields.
comparator
)

Creates a new equals method implementation.

Method Summary

Modifier and TypeMethod and Description
public ByteCodeAppender
appender(Implementation.Target
The target of the current implementation.
implementationTarget
)

Implements net.bytebuddy.implementation.Implementation.appender.

Creates a byte code appender that determines the implementation of the instrumented type's methods.
public static EqualsMethod

Returns:

An equals method implementation that does not invoke the super class's Object#equals(Object) method.
isolated
()

Creates an equals method implementation that does not invoke the super class's Object#equals(Object) method.

public InstrumentedType
prepare(InstrumentedType
The instrumented type in its current form.
instrumentedType
)

Implements net.bytebuddy.dynamic.scaffold.InstrumentedType.Prepareable.prepare.

Prepares a given instrumented type.
public static EqualsMethod

Returns:

An equals implementation that invokes the super class's Object#equals(Object) method first.
requiringSuperClassEquality
()

Creates an equals implementation that invokes the super class's Object#equals(Object) method first.

public EqualsMethod

Returns:

A new version of this equals method that compares enumeration-typed fields before fields with non-enumeration-typed fields.
withEnumerationTypedFieldsFirst
()

Returns a new version of this equals method that compares fields with enumeration types prior to fields with non-enumeration types.

public EqualsMethod

Returns:

A new version of this equals method that sorts fields in their application order using the supplied comparator.
withFieldOrder
(Comparator<? super FieldDescription.InDefinedShape>
The comparator to apply.
comparator
)

Applies the supplied comparator to determine an order for fields for being compared.

public EqualsMethod

Returns:

A new version of this equals method implementation that also ignores any fields matched by the provided matcher.
withIgnoredFields
(ElementMatcher<? super FieldDescription.InDefinedShape>
A matcher to specify any fields that should be ignored.
ignored
)

Returns a new version of this equals method implementation that ignores the specified fields additionally to any previously specified fields.

public EqualsMethod

Returns:

A new version of this equals method implementation that also does not apply null value checks to any fields matched by the provided matcher.
withNonNullableFields
(ElementMatcher<? super FieldDescription.InDefinedShape>
A matcher to specify any fields that should not be guarded against null values.
nonNullable
)

Returns a new version of this equals method implementation that does not apply a null value check for the specified fields if they have a reference type additionally to any previously specified fields.

public EqualsMethod

Returns:

A new version of this equals method that compares primitive-typed fields before fields with non-primitive-typed fields.
withPrimitiveTypedFieldsFirst
()

Returns a new version of this equals method that compares fields with primitive types prior to fields with non-primitive types.

public EqualsMethod

Returns:

A new version of this equals method that compares primitive wrapper-typed fields before fields with non-primitive wrapper-typed fields.
withPrimitiveWrapperTypedFieldsFirst
()

Returns a new version of this equals method that compares fields with primitive wrapper types prior to fields with non-primitive wrapper types.

public EqualsMethod

Returns:

A new version of this equals method that compares String-typed fields before fields with non-String-typed fields.
withStringTypedFieldsFirst
()

Returns a new version of this equals method that compares fields with String types prior to fields with non-String types.

public Implementation

Returns:

A new version of this equals method implementation that permits subclasses of the instrumented type to be equal to instances of the instrumented type instead of requiring an exact match.
withSubclassEquality
()

Returns a new version of this equals method implementation that permits subclasses of the instrumented type to be equal to instances of the instrumented type instead of requiring an exact match.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait