minor fixes to generic types in QueryParameterBinding

gets rid of some warnings
This commit is contained in:
Gavin King 2021-12-29 11:55:38 +01:00
parent 537953e12c
commit bf1eec69d0
3 changed files with 11 additions and 16 deletions

View File

@ -37,9 +37,7 @@ public interface ProcedureCallImplementor<R> extends ProcedureCall, QueryImpleme
ProcedureParameterMetadataImplementor getParameterMetadata(); ProcedureParameterMetadataImplementor getParameterMetadata();
@Override @Override
default R getSingleResult() { R getSingleResult();
return uniqueResult();
}
@Override @Override
ProcedureCallImplementor<R> registerStoredProcedureParameter(int position, BasicTypeReference<?> type, ParameterMode mode); ProcedureCallImplementor<R> registerStoredProcedureParameter(int position, BasicTypeReference<?> type, ParameterMode mode);

View File

@ -41,7 +41,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
private TemporalType explicitTemporalPrecision; private TemporalType explicitTemporalPrecision;
private T bindValue; private T bindValue;
private Collection<T> bindValues; private Collection<? extends T> bindValues;
// todo (6.0) : add TemporalType to QueryParameter and use to default precision here // todo (6.0) : add TemporalType to QueryParameter and use to default precision here
@ -164,8 +164,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
if ( bindType == null ) { if ( bindType == null ) {
if ( value != null ) { if ( value != null ) {
//noinspection unchecked this.bindType = typeResolver.resolveParameterBindType( value );
this.bindType = (AllowableParameterType<T>) typeResolver.resolveParameterBindType( value );
} }
} }
} }
@ -239,7 +238,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
// multi-valued binding support // multi-valued binding support
@Override @Override
public Collection<T> getBindValues() { public Collection<? extends T> getBindValues() {
if ( !isMultiValued ) { if ( !isMultiValued ) {
throw new IllegalStateException( "Binding is not multi-valued; illegal call to #getBindValues" ); throw new IllegalStateException( "Binding is not multi-valued; illegal call to #getBindValues" );
} }
@ -253,8 +252,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
this.isMultiValued = true; this.isMultiValued = true;
this.bindValue = null; this.bindValue = null;
//noinspection unchecked this.bindValues = values;
this.bindValues = (Collection<T>) values;
final Iterator<? extends T> iterator = values.iterator(); final Iterator<? extends T> iterator = values.iterator();
T value = null; T value = null;
@ -263,8 +261,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
} }
if ( bindType == null && value != null ) { if ( bindType == null && value != null ) {
//noinspection unchecked this.bindType = typeResolver.resolveParameterBindType( value );
this.bindType = (AllowableParameterType<T>) typeResolver.resolveParameterBindType( value );
} }
} }
@ -300,12 +297,12 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
} }
@Override @Override
public MappingModelExpressable getType() { public MappingModelExpressable<T> getType() {
return type; return type;
} }
@Override @Override @SuppressWarnings("unchecked")
public boolean setType(MappingModelExpressable type) { public boolean setType(MappingModelExpressable<T> type) {
this.type = type; this.type = type;
if ( bindType == null || bindType.getJavaType() == Object.class ) { if ( bindType == null || bindType.getJavaType() == Object.class ) {
if ( type instanceof AllowableParameterType<?> ) { if ( type instanceof AllowableParameterType<?> ) {
@ -329,7 +326,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
QueryParameterBindingValidator.INSTANCE.validate( getBindType(), value ); QueryParameterBindingValidator.INSTANCE.validate( getBindType(), value );
} }
private void validate(T value, AllowableParameterType clarifiedType) { private void validate(T value, AllowableParameterType<?> clarifiedType) {
QueryParameterBindingValidator.INSTANCE.validate( clarifiedType, value ); QueryParameterBindingValidator.INSTANCE.validate( clarifiedType, value );
} }

View File

@ -108,7 +108,7 @@ public interface QueryParameterBinding<T> {
* *
* @return The currently bound values * @return The currently bound values
*/ */
Collection<T> getBindValues(); Collection<? extends T> getBindValues();
/** /**
* Returns the inferred mapping model expressable i.e. the model reference against which this parameter is compared. * Returns the inferred mapping model expressable i.e. the model reference against which this parameter is compared.