Explicit type can be replaced by <>
Issue: SPR-13188
This commit is contained in:
@@ -51,7 +51,7 @@ class DatabasePopulatorConfigUtils {
|
||||
boolean ignoreFailedDrops = element.getAttribute("ignore-failures").equals("DROPS");
|
||||
boolean continueOnError = element.getAttribute("ignore-failures").equals("ALL");
|
||||
|
||||
ManagedList<BeanMetadataElement> delegates = new ManagedList<BeanMetadataElement>();
|
||||
ManagedList<BeanMetadataElement> delegates = new ManagedList<>();
|
||||
for (Element scriptElement : scripts) {
|
||||
String executionAttr = scriptElement.getAttribute("execution");
|
||||
if (!StringUtils.hasText(executionAttr)) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -72,9 +72,9 @@ public class SortedResourcesFactoryBean extends AbstractFactoryBean<Resource[]>
|
||||
|
||||
@Override
|
||||
protected Resource[] createInstance() throws Exception {
|
||||
List<Resource> scripts = new ArrayList<Resource>();
|
||||
List<Resource> scripts = new ArrayList<>();
|
||||
for (String location : this.locations) {
|
||||
List<Resource> resources = new ArrayList<Resource>(
|
||||
List<Resource> resources = new ArrayList<>(
|
||||
Arrays.asList(this.resourcePatternResolver.getResources(location)));
|
||||
Collections.sort(resources, new Comparator<Resource>() {
|
||||
@Override
|
||||
|
||||
@@ -212,8 +212,8 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
|
||||
*/
|
||||
protected void initialize(Class<T> mappedClass) {
|
||||
this.mappedClass = mappedClass;
|
||||
this.mappedFields = new HashMap<String, PropertyDescriptor>();
|
||||
this.mappedProperties = new HashSet<String>();
|
||||
this.mappedFields = new HashMap<>();
|
||||
this.mappedProperties = new HashSet<>();
|
||||
PropertyDescriptor[] pds = BeanUtils.getPropertyDescriptors(mappedClass);
|
||||
for (PropertyDescriptor pd : pds) {
|
||||
if (pd.getWriteMethod() != null) {
|
||||
@@ -280,7 +280,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
|
||||
|
||||
ResultSetMetaData rsmd = rs.getMetaData();
|
||||
int columnCount = rsmd.getColumnCount();
|
||||
Set<String> populatedProperties = (isCheckFullyPopulated() ? new HashSet<String>() : null);
|
||||
Set<String> populatedProperties = (isCheckFullyPopulated() ? new HashSet<>() : null);
|
||||
|
||||
for (int index = 1; index <= columnCount; index++) {
|
||||
String column = JdbcUtils.lookupColumnName(rsmd, index);
|
||||
@@ -377,7 +377,7 @@ public class BeanPropertyRowMapper<T> implements RowMapper<T> {
|
||||
* @param mappedClass the class that each row should be mapped to
|
||||
*/
|
||||
public static <T> BeanPropertyRowMapper<T> newInstance(Class<T> mappedClass) {
|
||||
return new BeanPropertyRowMapper<T>(mappedClass);
|
||||
return new BeanPropertyRowMapper<>(mappedClass);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,7 +58,7 @@ public class CallableStatementCreatorFactory {
|
||||
*/
|
||||
public CallableStatementCreatorFactory(String callString) {
|
||||
this.callString = callString;
|
||||
this.declaredParameters = new LinkedList<SqlParameter>();
|
||||
this.declaredParameters = new LinkedList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +113,7 @@ public class CallableStatementCreatorFactory {
|
||||
* @param params list of parameters (may be {@code null})
|
||||
*/
|
||||
public CallableStatementCreator newCallableStatementCreator(Map<String, ?> params) {
|
||||
return new CallableStatementCreatorImpl(params != null ? params : new HashMap<String, Object>());
|
||||
return new CallableStatementCreatorImpl(params != null ? params : new HashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -69,7 +69,7 @@ public class ColumnMapRowMapper implements RowMapper<Map<String, Object>> {
|
||||
* @see org.springframework.util.LinkedCaseInsensitiveMap
|
||||
*/
|
||||
protected Map<String, Object> createColumnMap(int columnCount) {
|
||||
return new LinkedCaseInsensitiveMap<Object>(columnCount);
|
||||
return new LinkedCaseInsensitiveMap<>(columnCount);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -481,7 +481,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
|
||||
@Override
|
||||
public <T> List<T> query(String sql, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
return query(sql, new RowMapperResultSetExtractor<T>(rowMapper));
|
||||
return query(sql, new RowMapperResultSetExtractor<>(rowMapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -758,46 +758,46 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
|
||||
@Override
|
||||
public <T> List<T> query(PreparedStatementCreator psc, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
return query(psc, new RowMapperResultSetExtractor<T>(rowMapper));
|
||||
return query(psc, new RowMapperResultSetExtractor<>(rowMapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> query(String sql, PreparedStatementSetter pss, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
return query(sql, pss, new RowMapperResultSetExtractor<T>(rowMapper));
|
||||
return query(sql, pss, new RowMapperResultSetExtractor<>(rowMapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> query(String sql, Object[] args, int[] argTypes, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
return query(sql, args, argTypes, new RowMapperResultSetExtractor<T>(rowMapper));
|
||||
return query(sql, args, argTypes, new RowMapperResultSetExtractor<>(rowMapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> query(String sql, Object[] args, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
return query(sql, args, new RowMapperResultSetExtractor<T>(rowMapper));
|
||||
return query(sql, args, new RowMapperResultSetExtractor<>(rowMapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> List<T> query(String sql, RowMapper<T> rowMapper, Object... args) throws DataAccessException {
|
||||
return query(sql, args, new RowMapperResultSetExtractor<T>(rowMapper));
|
||||
return query(sql, args, new RowMapperResultSetExtractor<>(rowMapper));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T queryForObject(String sql, Object[] args, int[] argTypes, RowMapper<T> rowMapper)
|
||||
throws DataAccessException {
|
||||
|
||||
List<T> results = query(sql, args, argTypes, new RowMapperResultSetExtractor<T>(rowMapper, 1));
|
||||
List<T> results = query(sql, args, argTypes, new RowMapperResultSetExtractor<>(rowMapper, 1));
|
||||
return DataAccessUtils.requiredSingleResult(results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T queryForObject(String sql, Object[] args, RowMapper<T> rowMapper) throws DataAccessException {
|
||||
List<T> results = query(sql, args, new RowMapperResultSetExtractor<T>(rowMapper, 1));
|
||||
List<T> results = query(sql, args, new RowMapperResultSetExtractor<>(rowMapper, 1));
|
||||
return DataAccessUtils.requiredSingleResult(results);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T queryForObject(String sql, RowMapper<T> rowMapper, Object... args) throws DataAccessException {
|
||||
List<T> results = query(sql, args, new RowMapperResultSetExtractor<T>(rowMapper, 1));
|
||||
List<T> results = query(sql, args, new RowMapperResultSetExtractor<>(rowMapper, 1));
|
||||
return DataAccessUtils.requiredSingleResult(results);
|
||||
}
|
||||
|
||||
@@ -911,7 +911,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
if (keys != null) {
|
||||
try {
|
||||
RowMapperResultSetExtractor<Map<String, Object>> rse =
|
||||
new RowMapperResultSetExtractor<Map<String, Object>>(getColumnMapRowMapper(), 1);
|
||||
new RowMapperResultSetExtractor<>(getColumnMapRowMapper(), 1);
|
||||
generatedKeys.addAll(rse.extractData(keys));
|
||||
}
|
||||
finally {
|
||||
@@ -966,7 +966,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
return ps.executeBatch();
|
||||
}
|
||||
else {
|
||||
List<Integer> rowsAffected = new ArrayList<Integer>();
|
||||
List<Integer> rowsAffected = new ArrayList<>();
|
||||
for (int i = 0; i < batchSize; i++) {
|
||||
pss.setValues(ps, i);
|
||||
if (ipss != null && ipss.isBatchExhausted(i)) {
|
||||
@@ -1010,7 +1010,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
return execute(sql, new PreparedStatementCallback<int[][]>() {
|
||||
@Override
|
||||
public int[][] doInPreparedStatement(PreparedStatement ps) throws SQLException {
|
||||
List<int[]> rowsAffected = new ArrayList<int[]>();
|
||||
List<int[]> rowsAffected = new ArrayList<>();
|
||||
try {
|
||||
boolean batchSupported = true;
|
||||
if (!JdbcUtils.supportsBatchUpdates(ps.getConnection())) {
|
||||
@@ -1116,9 +1116,9 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
public Map<String, Object> call(CallableStatementCreator csc, List<SqlParameter> declaredParameters)
|
||||
throws DataAccessException {
|
||||
|
||||
final List<SqlParameter> updateCountParameters = new ArrayList<SqlParameter>();
|
||||
final List<SqlParameter> resultSetParameters = new ArrayList<SqlParameter>();
|
||||
final List<SqlParameter> callParameters = new ArrayList<SqlParameter>();
|
||||
final List<SqlParameter> updateCountParameters = new ArrayList<>();
|
||||
final List<SqlParameter> resultSetParameters = new ArrayList<>();
|
||||
final List<SqlParameter> callParameters = new ArrayList<>();
|
||||
for (SqlParameter parameter : declaredParameters) {
|
||||
if (parameter.isResultsParameter()) {
|
||||
if (parameter instanceof SqlReturnResultSet) {
|
||||
@@ -1162,7 +1162,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
List<SqlParameter> updateCountParameters, List<SqlParameter> resultSetParameters, int updateCount)
|
||||
throws SQLException {
|
||||
|
||||
Map<String, Object> returnedResults = new HashMap<String, Object>();
|
||||
Map<String, Object> returnedResults = new HashMap<>();
|
||||
int rsIndex = 0;
|
||||
int updateIndex = 0;
|
||||
boolean moreResults;
|
||||
@@ -1224,7 +1224,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
protected Map<String, Object> extractOutputParameters(CallableStatement cs, List<SqlParameter> parameters)
|
||||
throws SQLException {
|
||||
|
||||
Map<String, Object> returnedResults = new HashMap<String, Object>();
|
||||
Map<String, Object> returnedResults = new HashMap<>();
|
||||
int sqlColIndex = 1;
|
||||
for (SqlParameter param : parameters) {
|
||||
if (param instanceof SqlOutParameter) {
|
||||
@@ -1272,7 +1272,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
if (rs == null) {
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
Map<String, Object> returnedResults = new HashMap<String, Object>();
|
||||
Map<String, Object> returnedResults = new HashMap<>();
|
||||
try {
|
||||
ResultSet rsToUse = rs;
|
||||
if (this.nativeJdbcExtractor != null) {
|
||||
@@ -1320,7 +1320,7 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
* @see SingleColumnRowMapper
|
||||
*/
|
||||
protected <T> RowMapper<T> getSingleColumnRowMapper(Class<T> requiredType) {
|
||||
return new SingleColumnRowMapper<T>(requiredType);
|
||||
return new SingleColumnRowMapper<>(requiredType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1334,10 +1334,10 @@ public class JdbcTemplate extends JdbcAccessor implements JdbcOperations {
|
||||
*/
|
||||
protected Map<String, Object> createResultsMap() {
|
||||
if (isResultsMapCaseInsensitive()) {
|
||||
return new LinkedCaseInsensitiveMap<Object>();
|
||||
return new LinkedCaseInsensitiveMap<>();
|
||||
}
|
||||
else {
|
||||
return new LinkedHashMap<String, Object>();
|
||||
return new LinkedHashMap<>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -67,7 +67,7 @@ public class PreparedStatementCreatorFactory {
|
||||
*/
|
||||
public PreparedStatementCreatorFactory(String sql) {
|
||||
this.sql = sql;
|
||||
this.declaredParameters = new LinkedList<SqlParameter>();
|
||||
this.declaredParameters = new LinkedList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,7 +205,7 @@ public class PreparedStatementCreatorFactory {
|
||||
this.parameters = parameters;
|
||||
if (this.parameters.size() != declaredParameters.size()) {
|
||||
// account for named parameters being used multiple times
|
||||
Set<String> names = new HashSet<String>();
|
||||
Set<String> names = new HashSet<>();
|
||||
for (int i = 0; i < parameters.size(); i++) {
|
||||
Object param = parameters.get(i);
|
||||
if (param instanceof SqlParameterValue) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -87,7 +87,7 @@ public class RowMapperResultSetExtractor<T> implements ResultSetExtractor<List<T
|
||||
|
||||
@Override
|
||||
public List<T> extractData(ResultSet rs) throws SQLException {
|
||||
List<T> results = (this.rowsExpected > 0 ? new ArrayList<T>(this.rowsExpected) : new ArrayList<T>());
|
||||
List<T> results = (this.rowsExpected > 0 ? new ArrayList<>(this.rowsExpected) : new ArrayList<T>());
|
||||
int rowNum = 0;
|
||||
while (rs.next()) {
|
||||
results.add(this.rowMapper.mapRow(rs, rowNum++));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -197,7 +197,7 @@ public class SingleColumnRowMapper<T> implements RowMapper<T> {
|
||||
* @since 4.1
|
||||
*/
|
||||
public static <T> SingleColumnRowMapper<T> newInstance(Class<T> requiredType) {
|
||||
return new SingleColumnRowMapper<T>(requiredType);
|
||||
return new SingleColumnRowMapper<>(requiredType);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -177,7 +177,7 @@ public class SqlParameter {
|
||||
* to a List of SqlParameter objects as used in this package.
|
||||
*/
|
||||
public static List<SqlParameter> sqlTypesToAnonymousParameterList(int... types) {
|
||||
List<SqlParameter> result = new LinkedList<SqlParameter>();
|
||||
List<SqlParameter> result = new LinkedList<>();
|
||||
if (types != null) {
|
||||
for (int type : types) {
|
||||
result.add(new SqlParameter(type));
|
||||
|
||||
@@ -86,7 +86,7 @@ public abstract class StatementCreatorUtils {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(StatementCreatorUtils.class);
|
||||
|
||||
private static final Map<Class<?>, Integer> javaTypeToSqlTypeMap = new HashMap<Class<?>, Integer>(32);
|
||||
private static final Map<Class<?>, Integer> javaTypeToSqlTypeMap = new HashMap<>(32);
|
||||
|
||||
static {
|
||||
javaTypeToSqlTypeMap.put(boolean.class, Types.BOOLEAN);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -64,16 +64,16 @@ public class CallMetaDataContext {
|
||||
private String schemaName;
|
||||
|
||||
/** List of SqlParameter objects to be used in call execution */
|
||||
private List<SqlParameter> callParameters = new ArrayList<SqlParameter>();
|
||||
private List<SqlParameter> callParameters = new ArrayList<>();
|
||||
|
||||
/** Actual name to use for the return value in the output map */
|
||||
private String actualFunctionReturnName;
|
||||
|
||||
/** Set of in parameter names to exclude use for any not listed */
|
||||
private Set<String> limitedInParameterNames = new HashSet<String>();
|
||||
private Set<String> limitedInParameterNames = new HashSet<>();
|
||||
|
||||
/** List of SqlParameter names for out parameters */
|
||||
private List<String> outParameterNames = new ArrayList<String>();
|
||||
private List<String> outParameterNames = new ArrayList<>();
|
||||
|
||||
/** Indicates whether this is a procedure or a function **/
|
||||
private boolean function = false;
|
||||
@@ -300,11 +300,11 @@ public class CallMetaDataContext {
|
||||
* Reconcile the provided parameters with available metadata and add new ones where appropriate.
|
||||
*/
|
||||
protected List<SqlParameter> reconcileParameters(List<SqlParameter> parameters) {
|
||||
final List<SqlParameter> declaredReturnParams = new ArrayList<SqlParameter>();
|
||||
final Map<String, SqlParameter> declaredParams = new LinkedHashMap<String, SqlParameter>();
|
||||
final List<SqlParameter> declaredReturnParams = new ArrayList<>();
|
||||
final Map<String, SqlParameter> declaredParams = new LinkedHashMap<>();
|
||||
boolean returnDeclared = false;
|
||||
List<String> outParamNames = new ArrayList<String>();
|
||||
List<String> metaDataParamNames = new ArrayList<String>();
|
||||
List<String> outParamNames = new ArrayList<>();
|
||||
List<String> metaDataParamNames = new ArrayList<>();
|
||||
|
||||
// Get the names of the meta data parameters
|
||||
for (CallParameterMetaData meta : this.metaDataProvider.getCallParameterMetaData()) {
|
||||
@@ -343,7 +343,7 @@ public class CallMetaDataContext {
|
||||
}
|
||||
setOutParameterNames(outParamNames);
|
||||
|
||||
List<SqlParameter> workParams = new ArrayList<SqlParameter>();
|
||||
List<SqlParameter> workParams = new ArrayList<>();
|
||||
workParams.addAll(declaredReturnParams);
|
||||
|
||||
if (!this.metaDataProvider.isProcedureColumnMetaDataUsed()) {
|
||||
@@ -351,7 +351,7 @@ public class CallMetaDataContext {
|
||||
return workParams;
|
||||
}
|
||||
|
||||
Map<String, String> limitedInParamNamesMap = new HashMap<String, String>(this.limitedInParameterNames.size());
|
||||
Map<String, String> limitedInParamNamesMap = new HashMap<>(this.limitedInParameterNames.size());
|
||||
for (String limitedParamName : this.limitedInParameterNames) {
|
||||
limitedInParamNamesMap.put(
|
||||
this.metaDataProvider.parameterNameToUse(limitedParamName).toLowerCase(), limitedParamName);
|
||||
@@ -460,8 +460,8 @@ public class CallMetaDataContext {
|
||||
Map<String, String> caseInsensitiveParameterNames =
|
||||
SqlParameterSourceUtils.extractCaseInsensitiveParameterNames(parameterSource);
|
||||
|
||||
Map<String, String> callParameterNames = new HashMap<String, String>(this.callParameters.size());
|
||||
Map<String, Object> matchedParameters = new HashMap<String, Object>(this.callParameters.size());
|
||||
Map<String, String> callParameterNames = new HashMap<>(this.callParameters.size());
|
||||
Map<String, Object> matchedParameters = new HashMap<>(this.callParameters.size());
|
||||
for (SqlParameter parameter : this.callParameters) {
|
||||
if (parameter.isInputValueProvided()) {
|
||||
String parameterName = parameter.getName();
|
||||
@@ -521,7 +521,7 @@ public class CallMetaDataContext {
|
||||
if (!this.metaDataProvider.isProcedureColumnMetaDataUsed()) {
|
||||
return inParameters;
|
||||
}
|
||||
Map<String, String> callParameterNames = new HashMap<String, String>(this.callParameters.size());
|
||||
Map<String, String> callParameterNames = new HashMap<>(this.callParameters.size());
|
||||
for (SqlParameter parameter : this.callParameters) {
|
||||
if (parameter.isInputValueProvided()) {
|
||||
String parameterName = parameter.getName();
|
||||
@@ -531,7 +531,7 @@ public class CallMetaDataContext {
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<String, Object> matchedParameters = new HashMap<String, Object>(inParameters.size());
|
||||
Map<String, Object> matchedParameters = new HashMap<>(inParameters.size());
|
||||
for (String parameterName : inParameters.keySet()) {
|
||||
String parameterNameToMatch = this.metaDataProvider.parameterNameToUse(parameterName);
|
||||
String callParameterName = callParameterNames.get(parameterNameToMatch.toLowerCase());
|
||||
@@ -569,7 +569,7 @@ public class CallMetaDataContext {
|
||||
}
|
||||
|
||||
public Map<String, ?> matchInParameterValuesWithCallParameters(Object[] parameterValues) {
|
||||
Map<String, Object> matchedParameters = new HashMap<String, Object>(parameterValues.length);
|
||||
Map<String, Object> matchedParameters = new HashMap<>(parameterValues.length);
|
||||
int i = 0;
|
||||
for (SqlParameter parameter : this.callParameters) {
|
||||
if (parameter.isInputValueProvided()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -56,7 +56,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||
|
||||
private boolean storesLowerCaseIdentifiers = false;
|
||||
|
||||
private List<CallParameterMetaData> callParameterMetaData = new ArrayList<CallParameterMetaData>();
|
||||
private List<CallParameterMetaData> callParameterMetaData = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
@@ -323,7 +323,7 @@ public class GenericCallMetaDataProvider implements CallMetaDataProvider {
|
||||
ResultSet procs = null;
|
||||
try {
|
||||
procs = databaseMetaData.getProcedures(metaDataCatalogName, metaDataSchemaName, metaDataProcedureName);
|
||||
List<String> found = new ArrayList<String>();
|
||||
List<String> found = new ArrayList<>();
|
||||
while (procs.next()) {
|
||||
found.add(procs.getString("PROCEDURE_CAT") + "." + procs.getString("PROCEDURE_SCHEM") +
|
||||
"." + procs.getString("PROCEDURE_NAME"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,7 +70,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
Arrays.asList("Apache Derby", "HSQL Database Engine");
|
||||
|
||||
/** Collection of TableParameterMetaData objects */
|
||||
private List<TableParameterMetaData> tableParameterMetaData = new ArrayList<TableParameterMetaData>();
|
||||
private List<TableParameterMetaData> tableParameterMetaData = new ArrayList<>();
|
||||
|
||||
/** NativeJdbcExtractor that can be used to retrieve the native connection */
|
||||
private NativeJdbcExtractor nativeJdbcExtractor;
|
||||
@@ -294,7 +294,7 @@ public class GenericTableMetaDataProvider implements TableMetaDataProvider {
|
||||
private void locateTableAndProcessMetaData(DatabaseMetaData databaseMetaData, String catalogName,
|
||||
String schemaName, String tableName) {
|
||||
|
||||
Map<String, TableMetaData> tableMeta = new HashMap<String, TableMetaData>();
|
||||
Map<String, TableMetaData> tableMeta = new HashMap<>();
|
||||
ResultSet tables = null;
|
||||
try {
|
||||
tables = databaseMetaData.getTables(
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,7 @@ public class TableMetaDataContext {
|
||||
private String schemaName;
|
||||
|
||||
/** List of columns objects to be used in this context */
|
||||
private List<String> tableColumns = new ArrayList<String>();
|
||||
private List<String> tableColumns = new ArrayList<>();
|
||||
|
||||
/** should we access insert parameter meta data info or not */
|
||||
private boolean accessTableColumnMetaData = true;
|
||||
@@ -217,13 +217,13 @@ public class TableMetaDataContext {
|
||||
this.generatedKeyColumnsUsed = true;
|
||||
}
|
||||
if (declaredColumns.size() > 0) {
|
||||
return new ArrayList<String>(declaredColumns);
|
||||
return new ArrayList<>(declaredColumns);
|
||||
}
|
||||
Set<String> keys = new LinkedHashSet<String>(generatedKeyNames.length);
|
||||
Set<String> keys = new LinkedHashSet<>(generatedKeyNames.length);
|
||||
for (String key : generatedKeyNames) {
|
||||
keys.add(key.toUpperCase());
|
||||
}
|
||||
List<String> columns = new ArrayList<String>();
|
||||
List<String> columns = new ArrayList<>();
|
||||
for (TableParameterMetaData meta : metaDataProvider.getTableParameterMetaData()) {
|
||||
if (!keys.contains(meta.getParameterName().toUpperCase())) {
|
||||
columns.add(meta.getParameterName());
|
||||
@@ -237,7 +237,7 @@ public class TableMetaDataContext {
|
||||
* @param parameterSource the parameter names and values
|
||||
*/
|
||||
public List<Object> matchInParameterValuesWithInsertColumns(SqlParameterSource parameterSource) {
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
List<Object> values = new ArrayList<>();
|
||||
// for parameter source lookups we need to provide caseinsensitive lookup support since the
|
||||
// database metadata is not necessarily providing case sensitive column names
|
||||
Map<String, String> caseInsensitiveParameterNames =
|
||||
@@ -277,8 +277,8 @@ public class TableMetaDataContext {
|
||||
* @param inParameters the parameter names and values
|
||||
*/
|
||||
public List<Object> matchInParameterValuesWithInsertColumns(Map<String, ?> inParameters) {
|
||||
List<Object> values = new ArrayList<Object>();
|
||||
Map<String, Object> source = new LinkedHashMap<String, Object>(inParameters.size());
|
||||
List<Object> values = new ArrayList<>();
|
||||
Map<String, Object> source = new LinkedHashMap<>(inParameters.size());
|
||||
for (String key : inParameters.keySet()) {
|
||||
source.put(key.toLowerCase(), inParameters.get(key));
|
||||
}
|
||||
@@ -294,7 +294,7 @@ public class TableMetaDataContext {
|
||||
* @return the insert string to be used
|
||||
*/
|
||||
public String createInsertString(String... generatedKeyNames) {
|
||||
Set<String> keys = new LinkedHashSet<String>(generatedKeyNames.length);
|
||||
Set<String> keys = new LinkedHashSet<>(generatedKeyNames.length);
|
||||
for (String key : generatedKeyNames) {
|
||||
keys.add(key.toUpperCase());
|
||||
}
|
||||
@@ -345,7 +345,7 @@ public class TableMetaDataContext {
|
||||
int[] types = new int[getTableColumns().size()];
|
||||
List<TableParameterMetaData> parameters = this.metaDataProvider.getTableParameterMetaData();
|
||||
Map<String, TableParameterMetaData> parameterMap =
|
||||
new LinkedHashMap<String, TableParameterMetaData>(parameters.size());
|
||||
new LinkedHashMap<>(parameters.size());
|
||||
for (TableParameterMetaData tpmd : parameters) {
|
||||
parameterMap.put(tpmd.getParameterName().toUpperCase(), tpmd);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,9 +30,9 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public abstract class AbstractSqlParameterSource implements SqlParameterSource {
|
||||
|
||||
private final Map<String, Integer> sqlTypes = new HashMap<String, Integer>();
|
||||
private final Map<String, Integer> sqlTypes = new HashMap<>();
|
||||
|
||||
private final Map<String, String> typeNames = new HashMap<String, String>();
|
||||
private final Map<String, String> typeNames = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -77,7 +77,7 @@ public class BeanPropertySqlParameterSource extends AbstractSqlParameterSource {
|
||||
*/
|
||||
public String[] getReadablePropertyNames() {
|
||||
if (this.propertyNames == null) {
|
||||
List<String> names = new ArrayList<String>();
|
||||
List<String> names = new ArrayList<>();
|
||||
PropertyDescriptor[] props = this.beanWrapper.getPropertyDescriptors();
|
||||
for (PropertyDescriptor pd : props) {
|
||||
if (this.beanWrapper.isReadableProperty(pd.getName())) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -43,7 +43,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class MapSqlParameterSource extends AbstractSqlParameterSource {
|
||||
|
||||
private final Map<String, Object> values = new LinkedHashMap<String, Object>();
|
||||
private final Map<String, Object> values = new LinkedHashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -223,14 +223,14 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
|
||||
public <T> T queryForObject(String sql, SqlParameterSource paramSource, Class<T> requiredType)
|
||||
throws DataAccessException {
|
||||
|
||||
return queryForObject(sql, paramSource, new SingleColumnRowMapper<T>(requiredType));
|
||||
return queryForObject(sql, paramSource, new SingleColumnRowMapper<>(requiredType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T queryForObject(String sql, Map<String, ?> paramMap, Class<T> requiredType)
|
||||
throws DataAccessException {
|
||||
|
||||
return queryForObject(sql, paramMap, new SingleColumnRowMapper<T>(requiredType));
|
||||
return queryForObject(sql, paramMap, new SingleColumnRowMapper<>(requiredType));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -247,7 +247,7 @@ public class NamedParameterJdbcTemplate implements NamedParameterJdbcOperations
|
||||
public <T> List<T> queryForList(String sql, SqlParameterSource paramSource, Class<T> elementType)
|
||||
throws DataAccessException {
|
||||
|
||||
return query(sql, paramSource, new SingleColumnRowMapper<T>(elementType));
|
||||
return query(sql, paramSource, new SingleColumnRowMapper<>(elementType));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -74,9 +74,9 @@ public abstract class NamedParameterUtils {
|
||||
public static ParsedSql parseSqlStatement(final String sql) {
|
||||
Assert.notNull(sql, "SQL must not be null");
|
||||
|
||||
Set<String> namedParameters = new HashSet<String>();
|
||||
Set<String> namedParameters = new HashSet<>();
|
||||
String sqlToUse = sql;
|
||||
List<ParameterHolder> parameterList = new ArrayList<ParameterHolder>();
|
||||
List<ParameterHolder> parameterList = new ArrayList<>();
|
||||
|
||||
char[] statement = sql.toCharArray();
|
||||
int namedParameterCount = 0;
|
||||
@@ -416,7 +416,7 @@ public abstract class NamedParameterUtils {
|
||||
*/
|
||||
public static List<SqlParameter> buildSqlParameterList(ParsedSql parsedSql, SqlParameterSource paramSource) {
|
||||
List<String> paramNames = parsedSql.getParameterNames();
|
||||
List<SqlParameter> params = new LinkedList<SqlParameter>();
|
||||
List<SqlParameter> params = new LinkedList<>();
|
||||
for (String paramName : paramNames) {
|
||||
params.add(new SqlParameter(paramName, paramSource.getSqlType(paramName), paramSource.getTypeName(paramName)));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2008 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,9 +30,9 @@ public class ParsedSql {
|
||||
|
||||
private String originalSql;
|
||||
|
||||
private List<String> parameterNames = new ArrayList<String>();
|
||||
private List<String> parameterNames = new ArrayList<>();
|
||||
|
||||
private List<int[]> parameterIndexes = new ArrayList<int[]>();
|
||||
private List<int[]> parameterIndexes = new ArrayList<>();
|
||||
|
||||
private int namedParameterCount;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -87,7 +87,7 @@ public class SqlParameterSourceUtils {
|
||||
* @return the Map that can be used for case insensitive matching of parameter names
|
||||
*/
|
||||
public static Map<String, String> extractCaseInsensitiveParameterNames(SqlParameterSource parameterSource) {
|
||||
Map<String, String> caseInsensitiveParameterNames = new HashMap<String, String>();
|
||||
Map<String, String> caseInsensitiveParameterNames = new HashMap<>();
|
||||
if (parameterSource instanceof BeanPropertySqlParameterSource) {
|
||||
String[] propertyNames = ((BeanPropertySqlParameterSource)parameterSource).getReadablePropertyNames();
|
||||
for (int i = 0; i < propertyNames.length; i++) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -58,10 +58,10 @@ public abstract class AbstractJdbcCall {
|
||||
private final CallMetaDataContext callMetaDataContext = new CallMetaDataContext();
|
||||
|
||||
/** List of SqlParameter objects */
|
||||
private final List<SqlParameter> declaredParameters = new ArrayList<SqlParameter>();
|
||||
private final List<SqlParameter> declaredParameters = new ArrayList<>();
|
||||
|
||||
/** List of RefCursor/ResultSet RowMapper objects */
|
||||
private final Map<String, RowMapper<?>> declaredRowMappers = new LinkedHashMap<String, RowMapper<?>>();
|
||||
private final Map<String, RowMapper<?>> declaredRowMappers = new LinkedHashMap<>();
|
||||
|
||||
/**
|
||||
* Has this operation been compiled? Compilation means at least checking
|
||||
|
||||
@@ -71,7 +71,7 @@ public abstract class AbstractJdbcInsert {
|
||||
private final TableMetaDataContext tableMetaDataContext = new TableMetaDataContext();
|
||||
|
||||
/** List of columns objects to be used in insert statement */
|
||||
private final List<String> declaredColumns = new ArrayList<String>();
|
||||
private final List<String> declaredColumns = new ArrayList<>();
|
||||
|
||||
/** The names of the columns holding the generated key */
|
||||
private String[] generatedKeyNames = new String[0];
|
||||
@@ -467,7 +467,7 @@ public abstract class AbstractJdbcInsert {
|
||||
if (keyQuery.toUpperCase().startsWith("RETURNING")) {
|
||||
Long key = getJdbcTemplate().queryForObject(getInsertString() + " " + keyQuery,
|
||||
values.toArray(new Object[values.size()]), Long.class);
|
||||
Map<String, Object> keys = new HashMap<String, Object>(1);
|
||||
Map<String, Object> keys = new HashMap<>(1);
|
||||
keys.put(getGeneratedKeyNames()[0], key);
|
||||
keyHolder.getKeyList().add(keys);
|
||||
}
|
||||
@@ -488,7 +488,7 @@ public abstract class AbstractJdbcInsert {
|
||||
//Get the key
|
||||
Statement keyStmt = null;
|
||||
ResultSet rs = null;
|
||||
Map<String, Object> keys = new HashMap<String, Object>(1);
|
||||
Map<String, Object> keys = new HashMap<>(1);
|
||||
try {
|
||||
keyStmt = con.createStatement();
|
||||
rs = keyStmt.executeQuery(keyQuery);
|
||||
@@ -545,7 +545,7 @@ public abstract class AbstractJdbcInsert {
|
||||
@SuppressWarnings("unchecked")
|
||||
protected int[] doExecuteBatch(Map<String, ?>... batch) {
|
||||
checkCompiled();
|
||||
List<List<Object>> batchValues = new ArrayList<List<Object>>(batch.length);
|
||||
List<List<Object>> batchValues = new ArrayList<>(batch.length);
|
||||
for (Map<String, ?> args : batch) {
|
||||
batchValues.add(matchInParameterValuesWithInsertColumns(args));
|
||||
}
|
||||
@@ -559,7 +559,7 @@ public abstract class AbstractJdbcInsert {
|
||||
*/
|
||||
protected int[] doExecuteBatch(SqlParameterSource... batch) {
|
||||
checkCompiled();
|
||||
List<List<Object>> batchValues = new ArrayList<List<Object>>(batch.length);
|
||||
List<List<Object>> batchValues = new ArrayList<>(batch.length);
|
||||
for (SqlParameterSource parameterSource : batch) {
|
||||
batchValues.add(matchInParameterValuesWithInsertColumns(parameterSource));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -125,7 +125,7 @@ public class SimpleJdbcCall extends AbstractJdbcCall implements SimpleJdbcCallOp
|
||||
|
||||
@Override
|
||||
public SimpleJdbcCall useInParameterNames(String... inParameterNames) {
|
||||
setInParameterNames(new LinkedHashSet<String>(Arrays.asList(inParameterNames)));
|
||||
setInParameterNames(new LinkedHashSet<>(Arrays.asList(inParameterNames)));
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -66,7 +66,7 @@ public class UserCredentialsDataSourceAdapter extends DelegatingDataSource {
|
||||
private String password;
|
||||
|
||||
private final ThreadLocal<JdbcUserCredentials> threadBoundCredentials =
|
||||
new NamedThreadLocal<JdbcUserCredentials>("Current JDBC user credentials");
|
||||
new NamedThreadLocal<>("Current JDBC user credentials");
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.List;
|
||||
*/
|
||||
public class CompositeDatabasePopulator implements DatabasePopulator {
|
||||
|
||||
private final List<DatabasePopulator> populators = new ArrayList<DatabasePopulator>(4);
|
||||
private final List<DatabasePopulator> populators = new ArrayList<>(4);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -52,7 +52,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class ResourceDatabasePopulator implements DatabasePopulator {
|
||||
|
||||
private List<Resource> scripts = new ArrayList<Resource>();
|
||||
private List<Resource> scripts = new ArrayList<>();
|
||||
|
||||
private String sqlScriptEncoding;
|
||||
|
||||
@@ -137,7 +137,7 @@ public class ResourceDatabasePopulator implements DatabasePopulator {
|
||||
public void setScripts(Resource... scripts) {
|
||||
assertContentsOfScriptArray(scripts);
|
||||
// Ensure that the list is modifiable
|
||||
this.scripts = new ArrayList<Resource>(Arrays.asList(scripts));
|
||||
this.scripts = new ArrayList<>(Arrays.asList(scripts));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -460,7 +460,7 @@ public abstract class ScriptUtils {
|
||||
separator = FALLBACK_STATEMENT_SEPARATOR;
|
||||
}
|
||||
|
||||
List<String> statements = new LinkedList<String>();
|
||||
List<String> statements = new LinkedList<>();
|
||||
splitSqlScript(resource, script, separator, commentPrefix, blockCommentStartDelimiter,
|
||||
blockCommentEndDelimiter, statements);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -112,7 +112,7 @@ public abstract class AbstractRoutingDataSource extends AbstractDataSource imple
|
||||
if (this.targetDataSources == null) {
|
||||
throw new IllegalArgumentException("Property 'targetDataSources' is required");
|
||||
}
|
||||
this.resolvedDataSources = new HashMap<Object, DataSource>(this.targetDataSources.size());
|
||||
this.resolvedDataSources = new HashMap<>(this.targetDataSources.size());
|
||||
for (Map.Entry<Object, Object> entry : this.targetDataSources.entrySet()) {
|
||||
Object lookupKey = resolveSpecifiedLookupKey(entry.getKey());
|
||||
DataSource dataSource = resolveSpecifiedDataSource(entry.getValue());
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class MapDataSourceLookup implements DataSourceLookup {
|
||||
|
||||
private final Map<String, DataSource> dataSources = new HashMap<String, DataSource>(4);
|
||||
private final Map<String, DataSource> dataSources = new HashMap<>(4);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -55,9 +55,9 @@ public class BatchSqlUpdate extends SqlUpdate {
|
||||
|
||||
private boolean trackRowsAffected = true;
|
||||
|
||||
private final LinkedList<Object[]> parameterQueue = new LinkedList<Object[]>();
|
||||
private final LinkedList<Object[]> parameterQueue = new LinkedList<>();
|
||||
|
||||
private final List<Integer> rowsAffected = new ArrayList<Integer>();
|
||||
private final List<Integer> rowsAffected = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -74,7 +74,7 @@ public abstract class RdbmsOperation implements InitializingBean {
|
||||
|
||||
private String sql;
|
||||
|
||||
private final List<SqlParameter> declaredParameters = new LinkedList<SqlParameter>();
|
||||
private final List<SqlParameter> declaredParameters = new LinkedList<>();
|
||||
|
||||
/**
|
||||
* Has this operation been compiled? Compilation means at
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -49,7 +49,7 @@ import org.springframework.jdbc.core.SingleColumnRowMapper;
|
||||
*/
|
||||
public class SqlFunction<T> extends MappingSqlQuery<T> {
|
||||
|
||||
private final SingleColumnRowMapper<T> rowMapper = new SingleColumnRowMapper<T>();
|
||||
private final SingleColumnRowMapper<T> rowMapper = new SingleColumnRowMapper<>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -110,7 +110,7 @@ public abstract class StoredProcedure extends SqlCall {
|
||||
* stored procedure has been called.
|
||||
*/
|
||||
public Map<String, Object> execute(Object... inParams) {
|
||||
Map<String, Object> paramsToUse = new HashMap<String, Object>();
|
||||
Map<String, Object> paramsToUse = new HashMap<>();
|
||||
validateParameters(inParams);
|
||||
int i = 0;
|
||||
for (SqlParameter sqlParameter : getDeclaredParameters()) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -35,7 +35,7 @@ public class CustomSQLExceptionTranslatorRegistrar implements InitializingBean {
|
||||
* Key is the database product name as defined in the
|
||||
* {@link org.springframework.jdbc.support.SQLErrorCodesFactory}.
|
||||
*/
|
||||
private final Map<String, SQLExceptionTranslator> translators = new HashMap<String, SQLExceptionTranslator>();
|
||||
private final Map<String, SQLExceptionTranslator> translators = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -54,7 +54,7 @@ public class CustomSQLExceptionTranslatorRegistry {
|
||||
* Key is the database product name as defined in the
|
||||
* {@link org.springframework.jdbc.support.SQLErrorCodesFactory}.
|
||||
*/
|
||||
private final Map<String, SQLExceptionTranslator> translatorMap = new HashMap<String, SQLExceptionTranslator>();
|
||||
private final Map<String, SQLExceptionTranslator> translatorMap = new HashMap<>();
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,7 +45,7 @@ public class GeneratedKeyHolder implements KeyHolder {
|
||||
* Create a new GeneratedKeyHolder with a default list.
|
||||
*/
|
||||
public GeneratedKeyHolder() {
|
||||
this.keyList = new LinkedList<Map<String, Object>>();
|
||||
this.keyList = new LinkedList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -85,7 +85,7 @@ public class SQLErrorCodesFactory {
|
||||
/**
|
||||
* Map to cache the SQLErrorCodes instance per DataSource.
|
||||
*/
|
||||
private final Map<DataSource, SQLErrorCodes> dataSourceCache = new WeakHashMap<DataSource, SQLErrorCodes>(16);
|
||||
private final Map<DataSource, SQLErrorCodes> dataSourceCache = new WeakHashMap<>(16);
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -45,15 +45,15 @@ import org.springframework.jdbc.BadSqlGrammarException;
|
||||
*/
|
||||
public class SQLStateSQLExceptionTranslator extends AbstractFallbackSQLExceptionTranslator {
|
||||
|
||||
private static final Set<String> BAD_SQL_GRAMMAR_CODES = new HashSet<String>(8);
|
||||
private static final Set<String> BAD_SQL_GRAMMAR_CODES = new HashSet<>(8);
|
||||
|
||||
private static final Set<String> DATA_INTEGRITY_VIOLATION_CODES = new HashSet<String>(8);
|
||||
private static final Set<String> DATA_INTEGRITY_VIOLATION_CODES = new HashSet<>(8);
|
||||
|
||||
private static final Set<String> DATA_ACCESS_RESOURCE_FAILURE_CODES = new HashSet<String>(8);
|
||||
private static final Set<String> DATA_ACCESS_RESOURCE_FAILURE_CODES = new HashSet<>(8);
|
||||
|
||||
private static final Set<String> TRANSIENT_DATA_ACCESS_RESOURCE_CODES = new HashSet<String>(8);
|
||||
private static final Set<String> TRANSIENT_DATA_ACCESS_RESOURCE_CODES = new HashSet<>(8);
|
||||
|
||||
private static final Set<String> CONCURRENCY_FAILURE_CODES = new HashSet<String>(4);
|
||||
private static final Set<String> CONCURRENCY_FAILURE_CODES = new HashSet<>(4);
|
||||
|
||||
|
||||
static {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,9 +50,9 @@ public class TemporaryLobCreator implements LobCreator {
|
||||
|
||||
protected static final Log logger = LogFactory.getLog(TemporaryLobCreator.class);
|
||||
|
||||
private final Set<Blob> temporaryBlobs = new LinkedHashSet<Blob>(1);
|
||||
private final Set<Blob> temporaryBlobs = new LinkedHashSet<>(1);
|
||||
|
||||
private final Set<Clob> temporaryClobs = new LinkedHashSet<Clob>(1);
|
||||
private final Set<Clob> temporaryClobs = new LinkedHashSet<>(1);
|
||||
|
||||
|
||||
@Override
|
||||
|
||||
@@ -96,7 +96,7 @@ public class ResultSetWrappingSqlRowSet implements SqlRowSet {
|
||||
ResultSetMetaData rsmd = resultSet.getMetaData();
|
||||
if (rsmd != null) {
|
||||
int columnCount = rsmd.getColumnCount();
|
||||
this.columnLabelMap = new HashMap<String, Integer>(columnCount);
|
||||
this.columnLabelMap = new HashMap<>(columnCount);
|
||||
for (int i = 1; i <= columnCount; i++) {
|
||||
String key = rsmd.getColumnLabel(i);
|
||||
// Make sure to preserve first matching column for any given name,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2012 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
|
||||
@Test
|
||||
public void testOverridingSameClassDefinedForMapping() {
|
||||
BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<Person>(Person.class);
|
||||
BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class);
|
||||
mapper.setMappedClass(Person.class);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
Mock mock = new Mock();
|
||||
List<Person> result = mock.getJdbcTemplate().query(
|
||||
"select name, age, birth_date, balance from people",
|
||||
new BeanPropertyRowMapper<Person>(Person.class));
|
||||
new BeanPropertyRowMapper<>(Person.class));
|
||||
assertEquals(1, result.size());
|
||||
verifyPerson(result.get(0));
|
||||
mock.verifyClosed();
|
||||
@@ -70,7 +70,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
Mock mock = new Mock();
|
||||
List<ConcretePerson> result = mock.getJdbcTemplate().query(
|
||||
"select name, age, birth_date, balance from people",
|
||||
new BeanPropertyRowMapper<ConcretePerson>(ConcretePerson.class));
|
||||
new BeanPropertyRowMapper<>(ConcretePerson.class));
|
||||
assertEquals(1, result.size());
|
||||
verifyConcretePerson(result.get(0));
|
||||
mock.verifyClosed();
|
||||
@@ -81,7 +81,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
Mock mock = new Mock();
|
||||
List<ConcretePerson> result = mock.getJdbcTemplate().query(
|
||||
"select name, age, birth_date, balance from people",
|
||||
new BeanPropertyRowMapper<ConcretePerson>(ConcretePerson.class, true));
|
||||
new BeanPropertyRowMapper<>(ConcretePerson.class, true));
|
||||
assertEquals(1, result.size());
|
||||
verifyConcretePerson(result.get(0));
|
||||
mock.verifyClosed();
|
||||
@@ -92,7 +92,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
Mock mock = new Mock();
|
||||
List<ExtendedPerson> result = mock.getJdbcTemplate().query(
|
||||
"select name, age, birth_date, balance from people",
|
||||
new BeanPropertyRowMapper<ExtendedPerson>(ExtendedPerson.class));
|
||||
new BeanPropertyRowMapper<>(ExtendedPerson.class));
|
||||
assertEquals(1, result.size());
|
||||
ExtendedPerson bean = result.get(0);
|
||||
verifyConcretePerson(bean);
|
||||
@@ -105,12 +105,12 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
thrown.expect(InvalidDataAccessApiUsageException.class);
|
||||
mock.getJdbcTemplate().query(
|
||||
"select name, age, birth_date, balance from people",
|
||||
new BeanPropertyRowMapper<ExtendedPerson>(ExtendedPerson.class, true));
|
||||
new BeanPropertyRowMapper<>(ExtendedPerson.class, true));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMappingNullValue() throws Exception {
|
||||
BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<Person>(Person.class);
|
||||
BeanPropertyRowMapper<Person> mapper = new BeanPropertyRowMapper<>(Person.class);
|
||||
Mock mock = new Mock(MockType.TWO);
|
||||
thrown.expect(TypeMismatchException.class);
|
||||
mock.getJdbcTemplate().query(
|
||||
@@ -122,7 +122,7 @@ public class BeanPropertyRowMapperTests extends AbstractRowMapperTests {
|
||||
Mock mock = new Mock(MockType.THREE);
|
||||
List<SpacePerson> result = mock.getJdbcTemplate().query(
|
||||
"select last_name as \"Last Name\", age, birth_date, balance from people",
|
||||
new BeanPropertyRowMapper<SpacePerson>(SpacePerson.class));
|
||||
new BeanPropertyRowMapper<>(SpacePerson.class));
|
||||
assertEquals(1, result.size());
|
||||
verifySpacePerson(result.get(0));
|
||||
mock.verifyClosed();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -224,7 +224,7 @@ public class JdbcTemplateTests {
|
||||
String[] results = { "rod", "gary", " portia" };
|
||||
|
||||
class StringHandler implements RowCallbackHandler {
|
||||
private List<String> list = new LinkedList<String>();
|
||||
private List<String> list = new LinkedList<>();
|
||||
@Override
|
||||
public void processRow(ResultSet rs) throws SQLException {
|
||||
this.list.add(rs.getString(1));
|
||||
@@ -742,7 +742,7 @@ public class JdbcTemplateTests {
|
||||
public void testBatchUpdateWithListOfObjectArrays() throws Exception {
|
||||
|
||||
final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?";
|
||||
final List<Object[]> ids = new ArrayList<Object[]>();
|
||||
final List<Object[]> ids = new ArrayList<>();
|
||||
ids.add(new Object[] {100});
|
||||
ids.add(new Object[] {200});
|
||||
final int[] rowsAffected = new int[] { 1, 2 };
|
||||
@@ -768,7 +768,7 @@ public class JdbcTemplateTests {
|
||||
@Test
|
||||
public void testBatchUpdateWithListOfObjectArraysPlusTypeInfo() throws Exception {
|
||||
final String sql = "UPDATE NOSUCHTABLE SET DATE_DISPATCHED = SYSDATE WHERE ID = ?";
|
||||
final List<Object[]> ids = new ArrayList<Object[]>();
|
||||
final List<Object[]> ids = new ArrayList<>();
|
||||
ids.add(new Object[] {100});
|
||||
ids.add(new Object[] {200});
|
||||
final int[] sqlTypes = new int[] {Types.NUMERIC};
|
||||
@@ -1185,7 +1185,7 @@ public class JdbcTemplateTests {
|
||||
public CallableStatement createCallableStatement(Connection con) {
|
||||
return callableStatement;
|
||||
}
|
||||
}, new ArrayList<SqlParameter>());
|
||||
}, new ArrayList<>());
|
||||
|
||||
verify(this.resultSet, times(2)).close();
|
||||
verify(this.statement).close();
|
||||
@@ -1246,7 +1246,7 @@ public class JdbcTemplateTests {
|
||||
given(this.callableStatement.execute()).willReturn(true);
|
||||
given(this.callableStatement.getUpdateCount()).willReturn(-1);
|
||||
|
||||
List<SqlParameter> params = new ArrayList<SqlParameter>();
|
||||
List<SqlParameter> params = new ArrayList<>();
|
||||
params.add(new SqlReturnResultSet("", new RowCallbackHandler() {
|
||||
@Override
|
||||
public void processRow(ResultSet rs) {
|
||||
@@ -1286,7 +1286,7 @@ public class JdbcTemplateTests {
|
||||
assertTrue("now it should have been set to case insensitive",
|
||||
this.template.isResultsMapCaseInsensitive());
|
||||
|
||||
List<SqlParameter> params = new ArrayList<SqlParameter>();
|
||||
List<SqlParameter> params = new ArrayList<>();
|
||||
params.add(new SqlOutParameter("a", 12));
|
||||
|
||||
Map<String, Object> out = this.template.call(new CallableStatementCreator() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,7 +76,7 @@ public class NamedParameterJdbcTemplateTests {
|
||||
private PreparedStatement preparedStatement;
|
||||
private ResultSet resultSet;
|
||||
private DatabaseMetaData databaseMetaData;
|
||||
private Map<String, Object> params = new HashMap<String, Object>();
|
||||
private Map<String, Object> params = new HashMap<>();
|
||||
private NamedParameterJdbcTemplate namedParameterTemplate;
|
||||
|
||||
@Before
|
||||
@@ -242,7 +242,7 @@ public class NamedParameterJdbcTemplateTests {
|
||||
|
||||
params.put("id", new SqlParameterValue(Types.DECIMAL, 1));
|
||||
params.put("country", "UK");
|
||||
final List<Customer> customers = new LinkedList<Customer>();
|
||||
final List<Customer> customers = new LinkedList<>();
|
||||
namedParameterTemplate.query(SELECT_NAMED_PARAMETERS, params, new RowCallbackHandler() {
|
||||
@Override
|
||||
public void processRow(ResultSet rs) throws SQLException {
|
||||
@@ -269,7 +269,7 @@ public class NamedParameterJdbcTemplateTests {
|
||||
given(resultSet.getInt("id")).willReturn(1);
|
||||
given(resultSet.getString("forename")).willReturn("rod");
|
||||
|
||||
final List<Customer> customers = new LinkedList<Customer>();
|
||||
final List<Customer> customers = new LinkedList<>();
|
||||
namedParameterTemplate.query(SELECT_NO_PARAMETERS, new RowCallbackHandler() {
|
||||
@Override
|
||||
public void processRow(ResultSet rs) throws SQLException {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -190,7 +190,7 @@ public class NamedParameterQueryTests {
|
||||
given(resultSet.next()).willReturn(true, false);
|
||||
given(resultSet.getInt(1)).willReturn(22);
|
||||
|
||||
Map<String, Object> parms = new HashMap<String, Object>();
|
||||
Map<String, Object> parms = new HashMap<>();
|
||||
parms.put("id", 3);
|
||||
Object o = template.queryForObject("SELECT AGE FROM CUSTMR WHERE ID = :id",
|
||||
parms, Integer.class);
|
||||
@@ -240,7 +240,7 @@ public class NamedParameterQueryTests {
|
||||
given(resultSet.getInt(1)).willReturn(22);
|
||||
|
||||
MapSqlParameterSource parms = new MapSqlParameterSource();
|
||||
List<Object[]> l1 = new ArrayList<Object[]>();
|
||||
List<Object[]> l1 = new ArrayList<>();
|
||||
l1.add(new Object[] {3, "Rod"});
|
||||
l1.add(new Object[] {4, "Juergen"});
|
||||
parms.addValue("multiExpressionList", l1);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -70,7 +70,7 @@ public class NamedParameterUtilsTests {
|
||||
|
||||
@Test
|
||||
public void convertParamMapToArray() {
|
||||
Map<String, String> paramMap = new HashMap<String, String>();
|
||||
Map<String, String> paramMap = new HashMap<>();
|
||||
paramMap.put("a", "a");
|
||||
paramMap.put("b", "b");
|
||||
paramMap.put("c", "c");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -76,7 +76,7 @@ public class CallMetaDataContextTests {
|
||||
given(databaseMetaData.getUserName()).willReturn(USER);
|
||||
given(databaseMetaData.storesLowerCaseIdentifiers()).willReturn(true);
|
||||
|
||||
List<SqlParameter> parameters = new ArrayList<SqlParameter>();
|
||||
List<SqlParameter> parameters = new ArrayList<>();
|
||||
parameters.add(new SqlParameter("id", Types.NUMERIC));
|
||||
parameters.add(new SqlInOutParameter("name", Types.NUMERIC));
|
||||
parameters.add(new SqlOutParameter("customer_no", Types.NUMERIC));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -79,7 +79,7 @@ public class SimpleJdbcInsertTests {
|
||||
// Shouldn't succeed in inserting into table which doesn't exist
|
||||
thrown.expect(InvalidDataAccessApiUsageException.class);
|
||||
try {
|
||||
insert.execute(new HashMap<String, Object>());
|
||||
insert.execute(new HashMap<>());
|
||||
}
|
||||
finally {
|
||||
verify(resultSet).close();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -98,7 +98,7 @@ public class TableMetaDataContextTests {
|
||||
map.registerSqlType("version", Types.NUMERIC);
|
||||
|
||||
context.setTableName(TABLE);
|
||||
context.processMetaData(dataSource, new ArrayList<String>(), new String[] {});
|
||||
context.processMetaData(dataSource, new ArrayList<>(), new String[] {});
|
||||
|
||||
List<Object> values = context.matchInParameterValuesWithInsertColumns(map);
|
||||
|
||||
@@ -142,7 +142,7 @@ public class TableMetaDataContextTests {
|
||||
MapSqlParameterSource map = new MapSqlParameterSource();
|
||||
String[] keyCols = new String[] { "id" };
|
||||
context.setTableName(TABLE);
|
||||
context.processMetaData(dataSource, new ArrayList<String>(), keyCols);
|
||||
context.processMetaData(dataSource, new ArrayList<>(), keyCols);
|
||||
List<Object> values = context.matchInParameterValuesWithInsertColumns(map);
|
||||
String insertString = context.createInsertString(keyCols);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -36,7 +36,7 @@ public class JdbcDaoSupportTests {
|
||||
@Test
|
||||
public void testJdbcDaoSupportWithDataSource() throws Exception {
|
||||
DataSource ds = mock(DataSource.class);
|
||||
final List<String> test = new ArrayList<String>();
|
||||
final List<String> test = new ArrayList<>();
|
||||
JdbcDaoSupport dao = new JdbcDaoSupport() {
|
||||
@Override
|
||||
protected void initDao() {
|
||||
@@ -53,7 +53,7 @@ public class JdbcDaoSupportTests {
|
||||
@Test
|
||||
public void testJdbcDaoSupportWithJdbcTemplate() throws Exception {
|
||||
JdbcTemplate template = new JdbcTemplate();
|
||||
final List<String> test = new ArrayList<String>();
|
||||
final List<String> test = new ArrayList<>();
|
||||
JdbcDaoSupport dao = new JdbcDaoSupport() {
|
||||
@Override
|
||||
protected void initDao() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -672,7 +672,7 @@ given( userTransaction.getStatus()).willReturn(Status.STATUS_NO_TRANSACTION, St
|
||||
given(dataSource2.getConnection()).willReturn(connection2);
|
||||
|
||||
final IsolationLevelDataSourceRouter dsToUse = new IsolationLevelDataSourceRouter();
|
||||
Map<Object, Object> targetDataSources = new HashMap<Object, Object>();
|
||||
Map<Object, Object> targetDataSources = new HashMap<>();
|
||||
if (dataSourceLookup) {
|
||||
targetDataSources.put("ISOLATION_REPEATABLE_READ", "ds2");
|
||||
dsToUse.setDefaultTargetDataSource("ds1");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public class ScriptUtilsUnitTests {
|
||||
String cleanedStatement3 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)";
|
||||
char delim = ';';
|
||||
String script = rawStatement1 + delim + rawStatement2 + delim + rawStatement3 + delim;
|
||||
List<String> statements = new ArrayList<String>();
|
||||
List<String> statements = new ArrayList<>();
|
||||
splitSqlScript(script, delim, statements);
|
||||
assertEquals("wrong number of statements", 3, statements.size());
|
||||
assertEquals("statement 1 not split correctly", cleanedStatement1, statements.get(0));
|
||||
@@ -65,7 +65,7 @@ public class ScriptUtilsUnitTests {
|
||||
String statement3 = "insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2)";
|
||||
char delim = '\n';
|
||||
String script = statement1 + delim + statement2 + delim + statement3 + delim;
|
||||
List<String> statements = new ArrayList<String>();
|
||||
List<String> statements = new ArrayList<>();
|
||||
splitSqlScript(script, delim, statements);
|
||||
assertEquals("wrong number of statements", 3, statements.size());
|
||||
assertEquals("statement 1 not split correctly", statement1, statements.get(0));
|
||||
@@ -79,7 +79,7 @@ public class ScriptUtilsUnitTests {
|
||||
String statement2 = "do something else";
|
||||
char delim = '\n';
|
||||
String script = statement1 + delim + statement2 + delim;
|
||||
List<String> statements = new ArrayList<String>();
|
||||
List<String> statements = new ArrayList<>();
|
||||
splitSqlScript(script, DEFAULT_STATEMENT_SEPARATOR, statements);
|
||||
assertEquals("wrong number of statements", 1, statements.size());
|
||||
assertEquals("script should have been 'stripped' but not actually 'split'", script.replace('\n', ' '),
|
||||
@@ -95,7 +95,7 @@ public class ScriptUtilsUnitTests {
|
||||
String statement2 = "select '2' as \"Dilbert's\" from dual";
|
||||
char delim = ';';
|
||||
String script = statement1 + delim + statement2 + delim;
|
||||
List<String> statements = new ArrayList<String>();
|
||||
List<String> statements = new ArrayList<>();
|
||||
splitSqlScript(script, ';', statements);
|
||||
assertEquals("wrong number of statements", 2, statements.size());
|
||||
assertEquals("statement 1 not split correctly", statement1, statements.get(0));
|
||||
@@ -108,7 +108,7 @@ public class ScriptUtilsUnitTests {
|
||||
@Test
|
||||
public void readAndSplitScriptWithMultipleNewlinesAsSeparator() throws Exception {
|
||||
String script = readScript("db-test-data-multi-newline.sql");
|
||||
List<String> statements = new ArrayList<String>();
|
||||
List<String> statements = new ArrayList<>();
|
||||
splitSqlScript(script, "\n\n", statements);
|
||||
|
||||
String statement1 = "insert into T_TEST (NAME) values ('Keith')";
|
||||
@@ -122,7 +122,7 @@ public class ScriptUtilsUnitTests {
|
||||
@Test
|
||||
public void readAndSplitScriptContainingComments() throws Exception {
|
||||
String script = readScript("test-data-with-comments.sql");
|
||||
List<String> statements = new ArrayList<String>();
|
||||
List<String> statements = new ArrayList<>();
|
||||
splitSqlScript(script, ';', statements);
|
||||
|
||||
String statement1 = "insert into customer (id, name) values (1, 'Rod; Johnson'), (2, 'Adrian Collier')";
|
||||
@@ -144,7 +144,7 @@ public class ScriptUtilsUnitTests {
|
||||
@Test
|
||||
public void readAndSplitScriptContainingCommentsWithLeadingTabs() throws Exception {
|
||||
String script = readScript("test-data-with-comments-and-leading-tabs.sql");
|
||||
List<String> statements = new ArrayList<String>();
|
||||
List<String> statements = new ArrayList<>();
|
||||
splitSqlScript(script, ';', statements);
|
||||
|
||||
String statement1 = "insert into customer (id, name) values (1, 'Sam Brannen')";
|
||||
@@ -163,7 +163,7 @@ public class ScriptUtilsUnitTests {
|
||||
@Test
|
||||
public void readAndSplitScriptContainingMuliLineComments() throws Exception {
|
||||
String script = readScript("test-data-with-multi-line-comments.sql");
|
||||
List<String> statements = new ArrayList<String>();
|
||||
List<String> statements = new ArrayList<>();
|
||||
splitSqlScript(script, ';', statements);
|
||||
|
||||
String statement1 = "INSERT INTO users(first_name, last_name) VALUES('Juergen', 'Hoeller')";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -50,7 +50,7 @@ public final class MapDataSourceLookupTests {
|
||||
|
||||
@Test
|
||||
public void lookupSunnyDay() throws Exception {
|
||||
Map<String, DataSource> dataSources = new HashMap<String, DataSource>();
|
||||
Map<String, DataSource> dataSources = new HashMap<>();
|
||||
StubDataSource expectedDataSource = new StubDataSource();
|
||||
dataSources.put(DATA_SOURCE_NAME, expectedDataSource);
|
||||
MapDataSourceLookup lookup = new MapDataSourceLookup();
|
||||
@@ -62,7 +62,7 @@ public final class MapDataSourceLookupTests {
|
||||
|
||||
@Test
|
||||
public void setDataSourcesIsAnIdempotentOperation() throws Exception {
|
||||
Map<String, DataSource> dataSources = new HashMap<String, DataSource>();
|
||||
Map<String, DataSource> dataSources = new HashMap<>();
|
||||
StubDataSource expectedDataSource = new StubDataSource();
|
||||
dataSources.put(DATA_SOURCE_NAME, expectedDataSource);
|
||||
MapDataSourceLookup lookup = new MapDataSourceLookup();
|
||||
@@ -75,7 +75,7 @@ public final class MapDataSourceLookupTests {
|
||||
|
||||
@Test
|
||||
public void addingDataSourcePermitsOverride() throws Exception {
|
||||
Map<String, DataSource> dataSources = new HashMap<String, DataSource>();
|
||||
Map<String, DataSource> dataSources = new HashMap<>();
|
||||
StubDataSource overridenDataSource = new StubDataSource();
|
||||
StubDataSource expectedDataSource = new StubDataSource();
|
||||
dataSources.put(DATA_SOURCE_NAME, overridenDataSource);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -93,7 +93,7 @@ public class GenericSqlQueryTests {
|
||||
|
||||
List<?> queryResults;
|
||||
if (namedParameters) {
|
||||
Map<String, Object> params = new HashMap<String, Object>(2);
|
||||
Map<String, Object> params = new HashMap<>(2);
|
||||
params.put("id", 1);
|
||||
params.put("country", "UK");
|
||||
queryResults = query.executeByNamedParam(params);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -57,7 +57,7 @@ public class GenericStoredProcedureTests {
|
||||
given(connection.prepareCall("{call " + "add_invoice" + "(?, ?, ?)}")).willReturn(callableStatement);
|
||||
|
||||
StoredProcedure adder = (StoredProcedure) bf.getBean("genericProcedure");
|
||||
Map<String, Object> in = new HashMap<String, Object>(2);
|
||||
Map<String, Object> in = new HashMap<>(2);
|
||||
in.put("amount", 1106);
|
||||
in.put("custid", 3);
|
||||
Map<String, Object> out = adder.execute(in);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2015 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -109,7 +109,7 @@ public class RdbmsOperationTests {
|
||||
@Test
|
||||
public void unspecifiedMapParameters() {
|
||||
operation.setSql("select * from mytable");
|
||||
Map<String, String> params = new HashMap<String, String>();
|
||||
Map<String, String> params = new HashMap<>();
|
||||
params.put("col1", "value");
|
||||
exception.expect(InvalidDataAccessApiUsageException.class);
|
||||
operation.validateNamedParameters(params);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2014 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -498,7 +498,7 @@ public class SqlQueryTests {
|
||||
}
|
||||
|
||||
public Customer findCustomer(int id) {
|
||||
Map<String, Integer> params = new HashMap<String, Integer>();
|
||||
Map<String, Integer> params = new HashMap<>();
|
||||
params.put("id", id);
|
||||
return executeByNamedParam(params).get(0);
|
||||
}
|
||||
@@ -556,7 +556,7 @@ public class SqlQueryTests {
|
||||
}
|
||||
|
||||
public Customer findCustomer(int id, String country) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id", id);
|
||||
params.put("country", country);
|
||||
return executeByNamedParam(params).get(0);
|
||||
@@ -602,14 +602,14 @@ public class SqlQueryTests {
|
||||
}
|
||||
|
||||
public List<Customer> findCustomers(List<Integer> ids) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("ids", ids);
|
||||
return executeByNamedParam(params);
|
||||
}
|
||||
}
|
||||
|
||||
CustomerQuery query = new CustomerQuery(dataSource);
|
||||
List<Integer> ids = new ArrayList<Integer>();
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
ids.add(1);
|
||||
ids.add(2);
|
||||
List<Customer> cust = query.findCustomers(ids);
|
||||
@@ -654,7 +654,7 @@ public class SqlQueryTests {
|
||||
}
|
||||
|
||||
public List<Customer> findCustomers(Integer id) {
|
||||
Map<String, Object> params = new HashMap<String, Object>();
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("id1", id);
|
||||
return executeByNamedParam(params);
|
||||
}
|
||||
@@ -701,7 +701,7 @@ public class SqlQueryTests {
|
||||
}
|
||||
|
||||
public List<Customer> findCustomers(Integer id1) {
|
||||
Map<String, Integer> params = new HashMap<String, Integer>();
|
||||
Map<String, Integer> params = new HashMap<>();
|
||||
params.put("id1", id1);
|
||||
return executeByNamedParam(params);
|
||||
}
|
||||
@@ -737,7 +737,7 @@ public class SqlQueryTests {
|
||||
}
|
||||
|
||||
CustomerUpdateQuery query = new CustomerUpdateQuery(dataSource);
|
||||
Map<Integer, String> values = new HashMap<Integer, String>(2);
|
||||
Map<Integer, String> values = new HashMap<>(2);
|
||||
values.put(1, "Rod");
|
||||
values.put(2, "Thomas");
|
||||
query.execute(2, values);
|
||||
|
||||
@@ -166,7 +166,7 @@ public class SqlUpdateTests {
|
||||
}
|
||||
|
||||
public int run(int performanceId, int type) {
|
||||
Map<String, Integer> params = new HashMap<String, Integer>();
|
||||
Map<String, Integer> params = new HashMap<>();
|
||||
params.put("perfId", performanceId);
|
||||
params.put("priceId", type);
|
||||
return updateByNamedParam(params);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -447,7 +447,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public int execute(int intIn) {
|
||||
Map<String, Integer> in = new HashMap<String, Integer>();
|
||||
Map<String, Integer> in = new HashMap<>();
|
||||
in.put("intIn", intIn);
|
||||
Map<String, Object> out = execute(in);
|
||||
return ((Number) out.get("intOut")).intValue();
|
||||
@@ -468,7 +468,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public int execute(int amount, int custid) {
|
||||
Map<String, Integer> in = new HashMap<String, Integer>();
|
||||
Map<String, Integer> in = new HashMap<>();
|
||||
in.put("amount", amount);
|
||||
in.put("custid", custid);
|
||||
Map<String, Object> out = execute(in);
|
||||
@@ -507,7 +507,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public void execute(String s) {
|
||||
Map<String, String> in = new HashMap<String, String>();
|
||||
Map<String, String> in = new HashMap<>();
|
||||
in.put("ptest", s);
|
||||
execute(in);
|
||||
}
|
||||
@@ -524,7 +524,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
execute(new HashMap<String, Object>());
|
||||
execute(new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -548,7 +548,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
execute(new HashMap<String, Object>());
|
||||
execute(new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -566,7 +566,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
execute(new HashMap<String, Object>());
|
||||
execute(new HashMap<>());
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
@@ -593,7 +593,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public Map<String, Object> execute() {
|
||||
return execute(new HashMap<String, Object>());
|
||||
return execute(new HashMap<>());
|
||||
}
|
||||
|
||||
private static class RowMapperImpl implements RowMapper<String> {
|
||||
@@ -628,7 +628,7 @@ public class StoredProcedureTests {
|
||||
|
||||
@Override
|
||||
public Map<String, ?> createMap(Connection con) throws SQLException {
|
||||
Map<String, Object> inParms = new HashMap<String, Object>();
|
||||
Map<String, Object> inParms = new HashMap<>();
|
||||
String testValue = con.toString();
|
||||
inParms.put("in", testValue);
|
||||
return inParms;
|
||||
@@ -649,7 +649,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public Map<String, Object> executeTest(final int[] inValue) {
|
||||
Map<String, AbstractSqlTypeValue> in = new HashMap<String, AbstractSqlTypeValue>();
|
||||
Map<String, AbstractSqlTypeValue> in = new HashMap<>();
|
||||
in.put("in", new AbstractSqlTypeValue() {
|
||||
@Override
|
||||
public Object createTypeValue(Connection con, int type, String typeName) {
|
||||
@@ -675,7 +675,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public Map<String, Object> executeTest() {
|
||||
return execute(new HashMap<String, Object>());
|
||||
return execute(new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ public class StoredProcedureTests {
|
||||
}
|
||||
|
||||
public void execute() {
|
||||
execute(new HashMap<String, Object>());
|
||||
execute(new HashMap<>());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user