Replace explicit generics with diamond operator

Where possible, explicit generic declarations to use the Java 8 diamond
operator.

See gh-9781
This commit is contained in:
Emanuel Campolo
2017-07-18 11:50:10 -03:00
committed by Phillip Webb
parent eb35fc9fa6
commit 04fdec6f8b
44 changed files with 64 additions and 68 deletions

View File

@@ -169,7 +169,7 @@ public class ManagementServerProperties implements SecurityPrerequisite {
/**
* Comma-separated list of roles that can access the management endpoint.
*/
private List<String> roles = new ArrayList<String>(
private List<String> roles = new ArrayList<>(
Collections.singletonList("ACTUATOR"));
/**

View File

@@ -89,7 +89,7 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
}
private Map<String, PropertySource<?>> getPropertySourcesAsMap() {
Map<String, PropertySource<?>> map = new LinkedHashMap<String, PropertySource<?>>();
Map<String, PropertySource<?>> map = new LinkedHashMap<>();
for (PropertySource<?> source : getPropertySources()) {
extract("", map, source);
}

View File

@@ -40,7 +40,7 @@ public class CompositeHealthIndicator implements HealthIndicator {
* @param healthAggregator the health aggregator
*/
public CompositeHealthIndicator(HealthAggregator healthAggregator) {
this(healthAggregator, new LinkedHashMap<String, HealthIndicator>());
this(healthAggregator, new LinkedHashMap<>());
}
/**

View File

@@ -191,7 +191,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
}
private Map<String, String[]> getParameterMapCopy(HttpServletRequest request) {
return new LinkedHashMap<String, String[]>(request.getParameterMap());
return new LinkedHashMap<>(request.getParameterMap());
}
/**

View File

@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.entry;
*/
public class CachePublicMetricsTests {
private Map<String, CacheManager> cacheManagers = new HashMap<String, CacheManager>();
private Map<String, CacheManager> cacheManagers = new HashMap<>();
@Before
public void setup() {
@@ -98,7 +98,7 @@ public class CachePublicMetricsTests {
private Map<String, Number> metrics(CachePublicMetrics cpm) {
Collection<Metric<?>> metrics = cpm.metrics();
assertThat(metrics).isNotNull();
Map<String, Number> result = new HashMap<String, Number>();
Map<String, Number> result = new HashMap<>();
for (Metric<?> metric : metrics) {
result.put(metric.getName(), metric.getValue());
}

View File

@@ -435,9 +435,9 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
public static class InitializedMapAndListProperties extends Foo {
private Map<String, Boolean> map = new HashMap<String, Boolean>();
private Map<String, Boolean> map = new HashMap<>();
private List<String> list = new ArrayList<String>();
private List<String> list = new ArrayList<>();
public Map<String, Boolean> getMap() {
return this.map;

View File

@@ -268,7 +268,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
this.context = new AnnotationConfigApplicationContext();
MutablePropertySources propertySources = this.context.getEnvironment()
.getPropertySources();
Map<String, Object> source = new HashMap<String, Object>();
Map<String, Object> source = new HashMap<>();
source.put("foo", Collections.singletonMap("bar", "baz"));
propertySources.addFirst(new MapPropertySource("test", source));
this.context.register(Config.class);

View File

@@ -142,7 +142,7 @@ public class EnvironmentMvcEndpointTests {
@Test
public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty()
throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("my.foo", "${my.bar}");
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
.addFirst(new MapPropertySource("unresolved-placeholder", map));
@@ -152,7 +152,7 @@ public class EnvironmentMvcEndpointTests {
@Test
public void nestedPathWithSensitivePlaceholderShouldSanitize() throws Exception {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("my.foo", "${my.password}");
map.put("my.password", "hello");
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
@@ -165,7 +165,7 @@ public class EnvironmentMvcEndpointTests {
public void propertyWithTypeOtherThanStringShouldNotFail() throws Exception {
MutablePropertySources propertySources = ((ConfigurableEnvironment) this.context
.getEnvironment()).getPropertySources();
Map<String, Object> source = new HashMap<String, Object>();
Map<String, Object> source = new HashMap<>();
source.put("foo", Collections.singletonMap("bar", "baz"));
propertySources.addFirst(new MapPropertySource("test", source));
this.mvc.perform(get("/application/env/foo.*")).andExpect(status().isOk())

View File

@@ -97,7 +97,7 @@ public class StatsdMetricWriterTests {
@Test
public void incrementMetricWithInvalidCharsInName() throws Exception {
this.writer.increment(new Delta<Long>("counter.fo:o", 3L));
this.writer.increment(new Delta<>("counter.fo:o", 3L));
this.server.waitForMessage();
assertThat(this.server.messagesReceived().get(0))
.isEqualTo("me.counter.fo-o:3|c");
@@ -105,7 +105,7 @@ public class StatsdMetricWriterTests {
@Test
public void setMetricWithInvalidCharsInName() throws Exception {
this.writer.set(new Metric<Long>("gauge.f:o:o", 3L));
this.writer.set(new Metric<>("gauge.f:o:o", 3L));
this.server.waitForMessage();
assertThat(this.server.messagesReceived().get(0)).isEqualTo("me.gauge.f-o-o:3|g");
}