HHH-12604 Replace EqualsHelper.equals with Objects.equals

This commit is contained in:
Philippe Marschall 2018-05-19 10:49:01 +02:00 committed by Guillaume Smet
parent 7022adfb2b
commit 4c52764c41
20 changed files with 62 additions and 75 deletions

View File

@ -8,8 +8,8 @@ package org.hibernate.boot.jaxb;
import java.io.Serializable;
import java.util.Locale;
import java.util.Objects;
import org.hibernate.internal.util.compare.EqualsHelper;
/**
* Describes the origin of an xml document
@ -57,7 +57,7 @@ public class Origin implements Serializable {
final Origin other = (Origin) o;
return type == other.type
&& EqualsHelper.equals( name, other.name );
&& Objects.equals( name, other.name );
}

View File

@ -11,10 +11,9 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import org.hibernate.internal.util.compare.EqualsHelper;
/**
* Models the information pertaining to a custom type definition supplied by the user. Used
* to delay instantiation of the actual {@link org.hibernate.type.Type} instance.
@ -110,10 +109,10 @@ public class TypeDefinition implements Serializable {
}
final TypeDefinition that = (TypeDefinition) o;
return EqualsHelper.equals( this.name, that.name )
&& EqualsHelper.equals( this.typeImplementorClass, that.typeImplementorClass )
return Objects.equals( this.name, that.name )
&& Objects.equals( this.typeImplementorClass, that.typeImplementorClass )
&& Arrays.equals( this.registrationKeys, that.registrationKeys )
&& EqualsHelper.equals( this.parameters, that.parameters );
&& Objects.equals( this.parameters, that.parameters );
}
@Override

View File

@ -8,13 +8,13 @@ package org.hibernate.boot.model.relational;
import java.util.Collection;
import java.util.Map;
import java.util.Objects;
import java.util.TreeMap;
import org.hibernate.HibernateException;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.mapping.DenormalizedTable;
import org.hibernate.mapping.Table;
@ -145,7 +145,7 @@ public class Namespace {
}
final Namespace that = (Namespace) o;
return EqualsHelper.equals( this.name, that.name );
return Objects.equals( this.name, that.name );
}
@Override
@ -190,8 +190,8 @@ public class Namespace {
final Name that = (Name) o;
return EqualsHelper.equals( this.catalog, that.catalog )
&& EqualsHelper.equals( this.schema, that.schema );
return Objects.equals( this.catalog, that.catalog )
&& Objects.equals( this.schema, that.schema );
}
@Override

View File

@ -6,10 +6,11 @@
*/
package org.hibernate.boot.model.relational;
import java.util.Objects;
import org.hibernate.HibernateException;
import org.hibernate.boot.model.naming.Identifier;
import org.hibernate.boot.model.naming.IllegalIdentifierException;
import org.hibernate.internal.util.compare.EqualsHelper;
/**
* Parses a qualified name.
@ -86,9 +87,9 @@ public class QualifiedNameParser {
NameParts that = (NameParts) o;
return EqualsHelper.equals( this.getCatalogName(), that.getCatalogName() )
&& EqualsHelper.equals( this.getSchemaName(), that.getSchemaName() )
&& EqualsHelper.equals( this.getObjectName(), that.getObjectName() );
return Objects.equals( this.getCatalogName(), that.getCatalogName() )
&& Objects.equals( this.getSchemaName(), that.getSchemaName() )
&& Objects.equals( this.getObjectName(), that.getObjectName() );
}
@Override

View File

@ -6,13 +6,13 @@
*/
package org.hibernate.boot.model.source.internal.hbm;
import java.sql.Types;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.Properties;
import org.hibernate.AssertionFailure;
@ -104,7 +104,6 @@ import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.log.DeprecationLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.loader.PropertyPath;
import org.hibernate.mapping.Any;
import org.hibernate.mapping.Array;
@ -1684,7 +1683,7 @@ public class ModelBinder {
continue;
}
if ( EqualsHelper.equals( tableName, determinedName ) ) {
if ( Objects.equals( tableName, determinedName ) ) {
continue;
}
@ -1715,7 +1714,7 @@ public class ModelBinder {
for ( RelationalValueSource relationalValueSource : relationalValueSources ) {
// We need to get the containing table name for both columns and formulas,
// particularly when a column/formula is for a property on a secondary table.
if ( EqualsHelper.equals( tableName, relationalValueSource.getContainingTableName() ) ) {
if ( Objects.equals( tableName, relationalValueSource.getContainingTableName() ) ) {
continue;
}

View File

@ -7,9 +7,9 @@
package org.hibernate.cache.internal;
import java.io.Serializable;
import java.util.Objects;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.type.Type;
/**
@ -76,9 +76,9 @@ final class CacheKeyImplementation implements Serializable {
return false;
}
final CacheKeyImplementation that = (CacheKeyImplementation) other;
return EqualsHelper.equals( entityOrRoleName, that.entityOrRoleName )
&& type.isEqual( id, that.id)
&& EqualsHelper.equals( tenantId, that.tenantId );
return Objects.equals( entityOrRoleName, that.entityOrRoleName )
&& type.isEqual( id, that.id )
&& Objects.equals( tenantId, that.tenantId );
}
@Override

View File

@ -10,11 +10,11 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.type.EntityType;
import org.hibernate.type.Type;
@ -143,8 +143,8 @@ public class NaturalIdCacheKey implements Serializable {
}
final NaturalIdCacheKey other = (NaturalIdCacheKey) o;
return EqualsHelper.equals( entityName, other.entityName )
&& EqualsHelper.equals( tenantId, other.tenantId )
return Objects.equals( entityName, other.entityName )
&& Objects.equals( tenantId, other.tenantId )
&& Arrays.deepEquals( this.naturalIdValues, other.naturalIdValues );
}

View File

@ -10,6 +10,7 @@ import java.io.IOException;
import java.io.Serializable;
import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import org.hibernate.engine.spi.QueryParameters;
@ -17,7 +18,6 @@ import org.hibernate.engine.spi.RowSelection;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.engine.spi.TypedValue;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.transform.CacheableResultTransformer;
import org.hibernate.type.Type;
@ -214,10 +214,10 @@ public class QueryKey implements Serializable {
if ( !sqlQueryString.equals( that.sqlQueryString ) ) {
return false;
}
if ( !EqualsHelper.equals( firstRow, that.firstRow ) || !EqualsHelper.equals( maxRows, that.maxRows ) ) {
if ( !Objects.equals( firstRow, that.firstRow ) || !Objects.equals( maxRows, that.maxRows ) ) {
return false;
}
if ( !EqualsHelper.equals( customTransformer, that.customTransformer ) ) {
if ( !Objects.equals( customTransformer, that.customTransformer ) ) {
return false;
}
if ( positionalParameterTypes == null ) {
@ -242,9 +242,9 @@ public class QueryKey implements Serializable {
}
}
return EqualsHelper.equals( filterKeys, that.filterKeys )
&& EqualsHelper.equals( namedParameters, that.namedParameters )
&& EqualsHelper.equals( tenantIdentifier, that.tenantIdentifier );
return Objects.equals( filterKeys, that.filterKeys )
&& Objects.equals( namedParameters, that.namedParameters )
&& Objects.equals( tenantIdentifier, that.tenantIdentifier );
}
@Override

View File

@ -6,11 +6,12 @@
*/
package org.hibernate.context.spi;
import java.util.Objects;
import org.hibernate.Session;
import org.hibernate.SessionBuilder;
import org.hibernate.context.TenantIdentifierMismatchException;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.util.compare.EqualsHelper;
/**
* Base support for {@link CurrentSessionContext} implementors.
@ -46,7 +47,7 @@ public abstract class AbstractCurrentSessionContext implements CurrentSessionCon
final CurrentTenantIdentifierResolver resolver = factory.getCurrentTenantIdentifierResolver();
if ( resolver != null && resolver.validateExistingCurrentSessions() ) {
final String current = resolver.resolveCurrentTenantIdentifier();
if ( ! EqualsHelper.equals( existingSession.getTenantIdentifier(), current ) ) {
if ( !Objects.equals( existingSession.getTenantIdentifier(), current ) ) {
throw new TenantIdentifierMismatchException(
String.format(
"Reported current tenant identifier [%s] did not match tenant identifier from " +

View File

@ -10,9 +10,9 @@ import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
import java.util.Objects;
import org.hibernate.AssertionFailure;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.pretty.MessageHelper;
@ -98,7 +98,7 @@ public final class EntityKey implements Serializable {
return true;
}
else {
return EqualsHelper.equals( otherKey.persister.getRootEntityName(), persister.getRootEntityName() );
return Objects.equals( otherKey.persister.getRootEntityName(), persister.getRootEntityName() );
}
}

View File

@ -16,21 +16,6 @@ import java.util.Arrays;
*/
public final class EqualsHelper {
@SuppressWarnings("SimplifiableIfStatement")
public static boolean equals(final Object x, final Object y) {
if ( x == y ) {
return true;
}
if ( x == null || y == null ) {
// One is null, but the other is not (otherwise the `x == y` check would have passed).
// null can never equal a non-null
return false;
}
return x.equals( y );
}
/**
* Like the legacy {@link #equals} method, but handles array-specific checks
*

View File

@ -10,6 +10,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import java.util.Objects;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
@ -19,7 +20,6 @@ import org.hibernate.engine.spi.Mapping;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.type.AbstractType;
import org.hibernate.type.Type;
@ -112,7 +112,7 @@ public class DiscriminatorType extends AbstractType {
public boolean isDirty(Object old, Object current, boolean[] checkable, SharedSessionContractImplementor session)
throws HibernateException {
return EqualsHelper.equals( old, current );
return Objects.equals( old, current );
}

View File

@ -15,6 +15,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
import java.util.StringTokenizer;
import org.hibernate.JDBCException;
@ -29,7 +30,6 @@ import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.internal.util.config.ConfigurationHelper;
import org.hibernate.tool.schema.extract.spi.ColumnInformation;
import org.hibernate.tool.schema.extract.spi.ExtractionContext;
@ -647,7 +647,7 @@ public class InformationExtractorJdbcDatabaseMetaDataImpl implements Information
firstPass = false;
}
else {
if ( !EqualsHelper.equals( pkIdentifier, currentPkIdentifier ) ) {
if ( !Objects.equals( pkIdentifier, currentPkIdentifier ) ) {
throw new SchemaExtractionException(
String.format(
"Encountered primary keys differing name on table %s",

View File

@ -10,12 +10,12 @@ import java.io.Serializable;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Map;
import java.util.Objects;
import org.hibernate.HibernateException;
import org.hibernate.engine.jdbc.Size;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.internal.util.compare.EqualsHelper;
/**
* Abstract superclass of the built in Type hierarchy.
@ -106,7 +106,7 @@ public abstract class AbstractType implements Type {
}
public boolean isEqual(Object x, Object y) {
return EqualsHelper.equals(x, y);
return Objects.equals( x, y );
}
public int getHashCode(Object x) {

View File

@ -8,10 +8,10 @@ package org.hibernate.type.descriptor.java;
import java.io.Serializable;
import java.util.Comparator;
import java.util.Objects;
import org.hibernate.HibernateException;
import org.hibernate.internal.util.compare.ComparableComparator;
import org.hibernate.internal.util.compare.EqualsHelper;
/**
* Abstract adapter for Java type descriptors.
@ -80,7 +80,7 @@ public abstract class AbstractTypeDescriptor<T> implements BasicJavaDescriptor<T
@Override
public boolean areEqual(T one, T another) {
return EqualsHelper.equals( one, another );
return Objects.equals( one, another );
}
@Override

View File

@ -12,6 +12,7 @@ import java.util.Comparator;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
@ -40,7 +41,6 @@ import org.hibernate.id.IdentifierGenerator;
import org.hibernate.id.UUIDHexGenerator;
import org.hibernate.internal.FilterAliasGenerator;
import org.hibernate.internal.StaticFilterAliasGenerator;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metamodel.model.domain.NavigableRole;
@ -245,7 +245,7 @@ public class CustomPersister implements EntityPersister {
Object[] y,
Object owner,
SharedSessionContractImplementor session) throws HibernateException {
if ( !EqualsHelper.equals( x[0], y[0] ) ) {
if ( !Objects.equals( x[0], y[0] ) ) {
return new int[] { 0 };
}
else {
@ -258,7 +258,7 @@ public class CustomPersister implements EntityPersister {
Object[] y,
Object owner,
SharedSessionContractImplementor session) throws HibernateException {
if ( !EqualsHelper.equals( x[0], y[0] ) ) {
if ( !Objects.equals( x[0], y[0] ) ) {
return new int[] { 0 };
}
else {

View File

@ -6,8 +6,9 @@
*/
package org.hibernate.envers.internal.entities;
import java.util.Objects;
import org.hibernate.envers.ModificationStore;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.type.Type;
/**
@ -169,10 +170,10 @@ public class PropertyData {
final PropertyData that = (PropertyData) o;
return usingModifiedFlag == that.usingModifiedFlag
&& store == that.store
&& EqualsHelper.equals( accessType, that.accessType )
&& EqualsHelper.equals( beanName, that.beanName )
&& EqualsHelper.equals( name, that.name )
&& EqualsHelper.equals( synthetic, that.synthetic );
&& Objects.equals( accessType, that.accessType )
&& Objects.equals( beanName, that.beanName )
&& Objects.equals( name, that.name )
&& Objects.equals( synthetic, that.synthetic );
}
@Override

View File

@ -11,11 +11,11 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Types;
import java.util.Objects;
import org.hibernate.HibernateException;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.envers.RevisionType;
import org.hibernate.internal.util.compare.EqualsHelper;
import org.hibernate.type.IntegerType;
import org.hibernate.usertype.UserType;
@ -91,6 +91,6 @@ public class RevisionTypeType implements UserType, Serializable {
@Override
public boolean equals(Object x, Object y) throws HibernateException {
return EqualsHelper.equals( x, y );
return Objects.equals( x, y );
}
}

View File

@ -6,7 +6,8 @@
*/
package org.hibernate.envers.internal.entities.mapper.id;
import org.hibernate.internal.util.compare.EqualsHelper;
import java.util.Objects;
import org.hibernate.query.Query;
/**
@ -52,7 +53,7 @@ public class QueryParameterData {
}
final QueryParameterData that = (QueryParameterData) o;
return EqualsHelper.equals( flatEntityPropertyName, that.flatEntityPropertyName );
return Objects.equals( flatEntityPropertyName, that.flatEntityPropertyName );
}
@Override

View File

@ -6,7 +6,7 @@
*/
package org.hibernate.envers.internal.tools;
import org.hibernate.internal.util.compare.EqualsHelper;
import java.util.Objects;
/**
* A triple of objects.
@ -50,9 +50,9 @@ public class Triple<T1, T2, T3> {
}
final Triple other = (Triple) o;
return EqualsHelper.equals( obj1, other.obj1 )
&& EqualsHelper.equals( obj2, other.obj2 )
&& EqualsHelper.equals( obj3, other.obj3 );
return Objects.equals( obj1, other.obj1 )
&& Objects.equals( obj2, other.obj2 )
&& Objects.equals( obj3, other.obj3 );
}
@Override