Replace relevant code with lambda

See gh-1454
This commit is contained in:
diguage
2017-06-08 00:07:34 +08:00
committed by Stephane Nicoll
parent 738160538e
commit 4b1478d830
52 changed files with 522 additions and 845 deletions

View File

@@ -77,15 +77,12 @@ public class SortedResourcesFactoryBean extends AbstractFactoryBean<Resource[]>
for (String location : this.locations) {
List<Resource> resources = new ArrayList<>(
Arrays.asList(this.resourcePatternResolver.getResources(location)));
Collections.sort(resources, new Comparator<Resource>() {
@Override
public int compare(Resource r1, Resource r2) {
try {
return r1.getURL().toString().compareTo(r2.getURL().toString());
}
catch (IOException ex) {
return 0;
}
Collections.sort(resources, (r1, r2) -> {
try {
return r1.getURL().toString().compareTo(r2.getURL().toString());
}
catch (IOException ex) {
return 0;
}
});
for (Resource resource : resources) {

View File

@@ -105,15 +105,12 @@ public class JdbcBeanDefinitionReader {
public void loadBeanDefinitions(String sql) {
Assert.notNull(this.jdbcTemplate, "Not fully configured - specify DataSource or JdbcTemplate");
final Properties props = new Properties();
this.jdbcTemplate.query(sql, new RowCallbackHandler() {
@Override
public void processRow(ResultSet rs) throws SQLException {
String beanName = rs.getString(1);
String property = rs.getString(2);
String value = rs.getString(3);
// Make a properties entry by combining bean name and property.
props.setProperty(beanName + '.' + property, value);
}
this.jdbcTemplate.query(sql, resultSet -> {
String beanName = resultSet.getString(1);
String property = resultSet.getString(2);
String value = resultSet.getString(3);
// Make a properties entry by combining bean name and property.
props.setProperty(beanName + '.' + property, value);
});
this.propReader.registerBeanDefinitions(props);
}