From 6b0ef0a5c4351f7e8801ffcd07bb9c5ef7015fac Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Thu, 28 Jun 2018 18:17:15 +0200 Subject: [PATCH] HHH-12685 Fix a few warnings --- .../CriteriaQueryTypeQueryAdapter.java | 55 ++++++++----------- 1 file changed, 24 insertions(+), 31 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/compile/CriteriaQueryTypeQueryAdapter.java b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/compile/CriteriaQueryTypeQueryAdapter.java index 9e301c9c45..555600d62c 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/compile/CriteriaQueryTypeQueryAdapter.java +++ b/hibernate-core/src/main/java/org/hibernate/query/criteria/internal/compile/CriteriaQueryTypeQueryAdapter.java @@ -348,7 +348,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @SuppressWarnings({ "unchecked" }) public T getParameterValue(Parameter param) { entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); if ( parameterInfo.isNamed() ) { return ( T ) jpqlQuery.getParameterValue( parameterInfo.getName() ); } @@ -357,15 +357,15 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { } } - private ExplicitParameterInfo resolveParameterInfo(Parameter param) { + private ExplicitParameterInfo resolveParameterInfo(Parameter param) { if ( ExplicitParameterInfo.class.isInstance( param ) ) { - return (ExplicitParameterInfo) param; + return (ExplicitParameterInfo) param; } else if ( ParameterExpression.class.isInstance( param ) ) { return explicitParameterInfoMap.get( param ); } else { - for ( ExplicitParameterInfo parameterInfo : explicitParameterInfoMap.values() ) { + for ( ExplicitParameterInfo parameterInfo : explicitParameterInfoMap.values() ) { if ( param.getName() != null && param.getName().equals( parameterInfo.getName() ) ) { return parameterInfo; } @@ -378,10 +378,9 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { } @Override - @SuppressWarnings({ "unchecked" }) public QueryImplementor setParameter(Parameter param, T t) { entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), t ); } @@ -392,10 +391,9 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { } @Override - @SuppressWarnings({ "unchecked" }) public QueryImplementor setParameter(Parameter param, Calendar calendar, TemporalType temporalType) { entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), calendar, temporalType ); } @@ -406,10 +404,9 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { } @Override - @SuppressWarnings({ "unchecked" }) public QueryImplementor setParameter(Parameter param, Date date, TemporalType temporalType) { entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), date, temporalType ); } @@ -425,15 +422,14 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { } @Override - @SuppressWarnings({ "unchecked" }) public Object getParameterValue(String name) { entityManager.checkOpen( false ); locateParameterByName( name ); return jpqlQuery.getParameterValue( name ); } - private ExplicitParameterInfo locateParameterByName(String name) { - for ( ExplicitParameterInfo parameterInfo : explicitParameterInfoMap.values() ) { + private ExplicitParameterInfo locateParameterByName(String name) { + for ( ExplicitParameterInfo parameterInfo : explicitParameterInfoMap.values() ) { if ( parameterInfo.isNamed() && parameterInfo.getName().equals( name ) ) { return parameterInfo; } @@ -441,8 +437,8 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { throw new IllegalArgumentException( "Unable to locate parameter registered with that name [" + name + "]" ); } - private ExplicitParameterInfo locateParameterByPosition(int position) { - for ( ExplicitParameterInfo parameterInfo : explicitParameterInfoMap.values() ) { + private ExplicitParameterInfo locateParameterByPosition(int position) { + for ( ExplicitParameterInfo parameterInfo : explicitParameterInfoMap.values() ) { if ( parameterInfo.getPosition() == position ) { return parameterInfo; } @@ -470,30 +466,27 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { } @Override - @SuppressWarnings({ "unchecked" }) public QueryImplementor setParameter(String name, Object value) { entityManager.checkOpen( true ); - ExplicitParameterInfo parameterInfo = locateParameterByName( name ); + ExplicitParameterInfo parameterInfo = locateParameterByName( name ); parameterInfo.validateBindValue( value ); jpqlQuery.setParameter( name, value ); return this; } @Override - @SuppressWarnings({ "unchecked" }) public QueryImplementor setParameter(String name, Calendar calendar, TemporalType temporalType) { entityManager.checkOpen( true ); - ExplicitParameterInfo parameterInfo = locateParameterByName( name ); + ExplicitParameterInfo parameterInfo = locateParameterByName( name ); parameterInfo.validateCalendarBind(); jpqlQuery.setParameter( name, calendar, temporalType ); return this; } @Override - @SuppressWarnings({ "unchecked" }) public QueryImplementor setParameter(String name, Date date, TemporalType temporalType) { entityManager.checkOpen( true ); - ExplicitParameterInfo parameterInfo = locateParameterByName( name ); + ExplicitParameterInfo parameterInfo = locateParameterByName( name ); parameterInfo.validateDateBind(); jpqlQuery.setParameter( name, date, temporalType ); return this; @@ -502,7 +495,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @Override public QueryImplementor setEntity(String name, Object val) { entityManager.checkOpen( false ); - ExplicitParameterInfo parameterInfo = locateParameterByName( name ); + ExplicitParameterInfo parameterInfo = locateParameterByName( name ); parameterInfo.validateBindValue( val ); jpqlQuery.setEntity( name, val ); return this; @@ -511,7 +504,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @Override public QueryImplementor setParameter(String name, Object val, Type type) { entityManager.checkOpen( false ); - ExplicitParameterInfo parameterInfo = locateParameterByName( name ); + ExplicitParameterInfo parameterInfo = locateParameterByName( name ); parameterInfo.validateBindValue( val ); jpqlQuery.setParameter( name, val, type ); return this; @@ -520,7 +513,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @Override public QueryImplementor setParameter(QueryParameter parameter, T val) { entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( parameter ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( parameter ); parameterInfo.validateBindValue( val ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), val ); @@ -535,7 +528,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { public

QueryImplementor setParameter( QueryParameter

parameter, P val, TemporalType temporalType) { entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( parameter ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( parameter ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), val, temporalType ); } @@ -556,7 +549,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @Override public

QueryImplementor setParameterList(QueryParameter

parameter, Collection

values) { entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( parameter ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( parameter ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), values ); } @@ -633,7 +626,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @Override public

QueryImplementor setParameter(QueryParameter

parameter, P value, Type type) { entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( parameter ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( parameter ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), value, type ); } @@ -646,7 +639,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @Override public QueryImplementor setParameter(Parameter param, Instant value, TemporalType temporalType){ entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), value, temporalType ); } @@ -659,7 +652,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @Override public QueryImplementor setParameter(Parameter param, LocalDateTime value, TemporalType temporalType){ entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), value, temporalType ); } @@ -672,7 +665,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @Override public QueryImplementor setParameter(Parameter param, ZonedDateTime value, TemporalType temporalType){ entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), value, temporalType ); } @@ -685,7 +678,7 @@ public class CriteriaQueryTypeQueryAdapter implements QueryImplementor { @Override public QueryImplementor setParameter(Parameter param, OffsetDateTime value, TemporalType temporalType){ entityManager.checkOpen( false ); - final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); + final ExplicitParameterInfo parameterInfo = resolveParameterInfo( param ); if ( parameterInfo.isNamed() ) { jpqlQuery.setParameter( parameterInfo.getName(), value, temporalType ); }