HHH-13100 All custom implementation of Byte Buddy "Implementation" s should have a proper equals and hashcode
This commit is contained in:
parent
9110fc1ce8
commit
ddcb0bb0e6
|
@ -8,6 +8,8 @@ package org.hibernate.bytecode.enhance.internal.bytebuddy;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Access;
|
||||
import javax.persistence.AccessType;
|
||||
import javax.persistence.ManyToMany;
|
||||
|
@ -34,7 +36,7 @@ import net.bytebuddy.jar.asm.MethodVisitor;
|
|||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
import net.bytebuddy.jar.asm.Type;
|
||||
|
||||
class BiDirectionalAssociationHandler implements Implementation {
|
||||
final class BiDirectionalAssociationHandler implements Implementation {
|
||||
|
||||
private static final CoreMessageLogger log = CoreLogging.messageLogger( BiDirectionalAssociationHandler.class );
|
||||
|
||||
|
@ -327,4 +329,24 @@ class BiDirectionalAssociationHandler implements Implementation {
|
|||
}, implementationContext, instrumentedMethod );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || BiDirectionalAssociationHandler.class != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
final BiDirectionalAssociationHandler that = (BiDirectionalAssociationHandler) o;
|
||||
return Objects.equals( delegate, that.delegate ) &&
|
||||
Objects.equals( targetEntity, that.targetEntity ) &&
|
||||
Objects.equals( targetType, that.targetType ) &&
|
||||
Objects.equals( mappedBy, that.mappedBy );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( delegate, targetEntity, targetType, mappedBy );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@ import net.bytebuddy.pool.TypePool;
|
|||
import static net.bytebuddy.matcher.ElementMatchers.hasDescriptor;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
||||
class FieldAccessEnhancer implements AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper {
|
||||
import java.util.Objects;
|
||||
|
||||
final class FieldAccessEnhancer implements AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper {
|
||||
|
||||
private static final CoreMessageLogger log = CoreLogging.messageLogger( FieldAccessEnhancer.class );
|
||||
|
||||
|
@ -130,4 +132,24 @@ class FieldAccessEnhancer implements AsmVisitorWrapper.ForDeclaredMethods.Method
|
|||
}
|
||||
return fields.getOnly();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || FieldAccessEnhancer.class != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
final FieldAccessEnhancer that = (FieldAccessEnhancer) o;
|
||||
return Objects.equals( managedCtClass, that.managedCtClass ) &&
|
||||
Objects.equals( enhancementContext, that.enhancementContext ) &&
|
||||
Objects.equals( classPool, that.classPool );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( managedCtClass, enhancementContext, classPool );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
*/
|
||||
package org.hibernate.bytecode.enhance.internal.bytebuddy;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
import org.hibernate.bytecode.enhance.spi.EnhancerConstants;
|
||||
import org.hibernate.engine.spi.PersistentAttributeInterceptor;
|
||||
|
||||
|
@ -170,4 +172,24 @@ abstract class FieldReaderAppender implements ByteCodeAppender {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || getClass() != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
final FieldReaderAppender that = (FieldReaderAppender) o;
|
||||
return Objects.equals( managedCtClass, that.managedCtClass ) &&
|
||||
Objects.equals( persistentField, that.persistentField ) &&
|
||||
Objects.equals( persistentFieldAsDefined, that.persistentFieldAsDefined );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( managedCtClass, persistentField, persistentFieldAsDefined );
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ import net.bytebuddy.jar.asm.MethodVisitor;
|
|||
import net.bytebuddy.jar.asm.Opcodes;
|
||||
import net.bytebuddy.jar.asm.Type;
|
||||
|
||||
class InlineDirtyCheckingHandler implements Implementation, ByteCodeAppender {
|
||||
final class InlineDirtyCheckingHandler implements Implementation, ByteCodeAppender {
|
||||
|
||||
private final Implementation delegate;
|
||||
|
||||
|
@ -151,4 +151,23 @@ class InlineDirtyCheckingHandler implements Implementation, ByteCodeAppender {
|
|||
}
|
||||
return new Size( 1 + 2 * persistentField.getType().asErasure().getStackSize().getSize(), instrumentedMethod.getStackSize() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || InlineDirtyCheckingHandler.class != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
final InlineDirtyCheckingHandler that = (InlineDirtyCheckingHandler) o;
|
||||
return Objects.equals( delegate, that.delegate ) &&
|
||||
Objects.equals( managedCtClass, that.managedCtClass ) &&
|
||||
Objects.equals( persistentField, that.persistentField );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash( delegate, managedCtClass, persistentField );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,8 @@ import java.util.Arrays;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.persistence.Embedded;
|
||||
|
||||
import net.bytebuddy.description.field.FieldList;
|
||||
|
@ -41,7 +43,7 @@ import net.bytebuddy.pool.TypePool;
|
|||
import static net.bytebuddy.matcher.ElementMatchers.nameStartsWith;
|
||||
import static net.bytebuddy.matcher.ElementMatchers.not;
|
||||
|
||||
class PersistentAttributeTransformer implements AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper {
|
||||
final class PersistentAttributeTransformer implements AsmVisitorWrapper.ForDeclaredMethods.MethodVisitorWrapper {
|
||||
|
||||
private static final CoreMessageLogger log = CoreLogging.messageLogger( PersistentAttributeTransformer.class );
|
||||
|
||||
|
@ -313,4 +315,26 @@ class PersistentAttributeTransformer implements AsmVisitorWrapper.ForDeclaredMet
|
|||
return new Size( 1 + persistentField.getType().getStackSize().getSize(), instrumentedMethod.getStackSize() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if ( this == o ) {
|
||||
return true;
|
||||
}
|
||||
if ( o == null || PersistentAttributeTransformer.class != o.getClass() ) {
|
||||
return false;
|
||||
}
|
||||
final PersistentAttributeTransformer that = (PersistentAttributeTransformer) o;
|
||||
return Objects.equals( managedCtClass, that.managedCtClass ) &&
|
||||
Objects.equals( enhancementContext, that.enhancementContext ) &&
|
||||
Objects.equals( classPool, that.classPool ) &&
|
||||
Arrays.equals( enhancedFields, that.enhancedFields );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Objects.hash( managedCtClass, enhancementContext, classPool );
|
||||
result = 31 * result + Arrays.hashCode( enhancedFields );
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue