From 7c068e5be43614a28efc2d6a07c88532d0718b2b Mon Sep 17 00:00:00 2001 From: Sanne Grinovero Date: Thu, 15 Dec 2022 18:59:56 +0000 Subject: [PATCH] HHH-15886 Micro optimisations in NavigableRole equals and hashcode --- .../metamodel/model/domain/NavigableRole.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/NavigableRole.java b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/NavigableRole.java index 5252e4c5ed..3deb000a6d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/NavigableRole.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/model/domain/NavigableRole.java @@ -22,7 +22,7 @@ import org.hibernate.spi.NavigablePath; * * @author Steve Ebersole */ -public class NavigableRole implements DotIdentifierSequence, Serializable { +public final class NavigableRole implements DotIdentifierSequence, Serializable { public static final String IDENTIFIER_MAPPER_PROPERTY = NavigablePath.IDENTIFIER_MAPPER_PROPERTY; private final NavigableRole parent; @@ -111,19 +111,20 @@ public class NavigableRole implements DotIdentifierSequence, Serializable { } @Override - public boolean equals(Object o) { + public boolean equals(final Object o) { if ( this == o ) { return true; } - if ( o == null || getClass() != o.getClass() ) { + if ( o == null || NavigableRole.class != o.getClass() ) { return false; } NavigableRole that = (NavigableRole) o; - return Objects.equals( getFullPath(), that.getFullPath() ); + return fullPath.equals( that.fullPath ); } @Override public int hashCode() { - return Objects.hash( getFullPath() ); + return this.fullPath.hashCode(); } + }