HHH-13600 Avoid capturing lambdas in ParameterTranslationsImpl

This commit is contained in:
Sanne Grinovero 2019-08-28 11:39:46 +01:00
parent c8a36cd961
commit 40b30fa099
1 changed files with 26 additions and 8 deletions

View File

@ -48,10 +48,7 @@ public class ParameterTranslationsImpl implements ParameterTranslations {
}
final PositionalParameterSpecification ordinalSpecification = (PositionalParameterSpecification) specification;
final PositionalParameterInformationImpl info = ordinalParameters.computeIfAbsent(
ordinalSpecification.getLabel(),
k -> new PositionalParameterInformationImpl( k, ordinalSpecification.getExpectedType() )
);
final PositionalParameterInformationImpl info = getPositionalParameterInfo( ordinalParameters, ordinalSpecification );
info.addSourceLocation( i++ );
}
else if ( NamedParameterSpecification.class.isInstance( specification ) ) {
@ -60,10 +57,7 @@ public class ParameterTranslationsImpl implements ParameterTranslations {
}
final NamedParameterSpecification namedSpecification = (NamedParameterSpecification) specification;
final NamedParameterInformationImpl info = namedParameters.computeIfAbsent(
namedSpecification.getName(),
k -> new NamedParameterInformationImpl( k, namedSpecification.getExpectedType() )
);
final NamedParameterInformationImpl info = getNamedParameterInfo( namedParameters, namedSpecification );
/*
If a previous reference to the NamedParameter already exists with expected type null and the new
@ -96,6 +90,30 @@ public class ParameterTranslationsImpl implements ParameterTranslations {
}
}
private NamedParameterInformationImpl getNamedParameterInfo(
Map<String, NamedParameterInformationImpl> namedParameters,
NamedParameterSpecification namedSpecification) {
final String name = namedSpecification.getName();
NamedParameterInformationImpl namedParameterInformation = namedParameters.get( name );
if ( namedParameterInformation == null ) {
namedParameterInformation = new NamedParameterInformationImpl( name, namedSpecification.getExpectedType() );
namedParameters.put( name, namedParameterInformation );
}
return namedParameterInformation;
}
private static PositionalParameterInformationImpl getPositionalParameterInfo(
Map<Integer, PositionalParameterInformationImpl> ordinalParameters,
PositionalParameterSpecification ordinalSpecification) {
final Integer label = Integer.valueOf( ordinalSpecification.getLabel() );
PositionalParameterInformationImpl positionalParameterInformation = ordinalParameters.get( label );
if ( positionalParameterInformation == null ) {
positionalParameterInformation = new PositionalParameterInformationImpl( label, ordinalSpecification.getExpectedType() );
ordinalParameters.put( label, positionalParameterInformation );
}
return positionalParameterInformation;
}
@Override
@SuppressWarnings("unchecked")
public Map getNamedParameterInformationMap() {