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();
@Override
default R getSingleResult() {
return uniqueResult();
}
R getSingleResult();
@Override
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 T bindValue;
private Collection<T> bindValues;
private Collection<? extends T> bindValues;
// 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 ( value != null ) {
//noinspection unchecked
this.bindType = (AllowableParameterType<T>) typeResolver.resolveParameterBindType( value );
this.bindType = typeResolver.resolveParameterBindType( value );
}
}
}
@ -239,7 +238,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
// multi-valued binding support
@Override
public Collection<T> getBindValues() {
public Collection<? extends T> getBindValues() {
if ( !isMultiValued ) {
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.bindValue = null;
//noinspection unchecked
this.bindValues = (Collection<T>) values;
this.bindValues = values;
final Iterator<? extends T> iterator = values.iterator();
T value = null;
@ -263,8 +261,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
}
if ( bindType == null && value != null ) {
//noinspection unchecked
this.bindType = (AllowableParameterType<T>) typeResolver.resolveParameterBindType( value );
this.bindType = typeResolver.resolveParameterBindType( value );
}
}
@ -300,12 +297,12 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
}
@Override
public MappingModelExpressable getType() {
public MappingModelExpressable<T> getType() {
return type;
}
@Override
public boolean setType(MappingModelExpressable type) {
@Override @SuppressWarnings("unchecked")
public boolean setType(MappingModelExpressable<T> type) {
this.type = type;
if ( bindType == null || bindType.getJavaType() == Object.class ) {
if ( type instanceof AllowableParameterType<?> ) {
@ -329,7 +326,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
QueryParameterBindingValidator.INSTANCE.validate( getBindType(), value );
}
private void validate(T value, AllowableParameterType clarifiedType) {
private void validate(T value, AllowableParameterType<?> clarifiedType) {
QueryParameterBindingValidator.INSTANCE.validate( clarifiedType, value );
}

View File

@ -108,7 +108,7 @@ public interface QueryParameterBinding<T> {
*
* @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.