Commit 04fdec6f authored by Emanuel Campolo's avatar Emanuel Campolo Committed by Phillip Webb

Replace explicit generics with diamond operator

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

See gh-9781
parent eb35fc9f
...@@ -169,7 +169,7 @@ public class ManagementServerProperties implements SecurityPrerequisite { ...@@ -169,7 +169,7 @@ public class ManagementServerProperties implements SecurityPrerequisite {
/** /**
* Comma-separated list of roles that can access the management endpoint. * 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")); Collections.singletonList("ACTUATOR"));
/** /**
......
...@@ -89,7 +89,7 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> { ...@@ -89,7 +89,7 @@ public class EnvironmentEndpoint extends AbstractEndpoint<Map<String, Object>> {
} }
private Map<String, PropertySource<?>> getPropertySourcesAsMap() { private Map<String, PropertySource<?>> getPropertySourcesAsMap() {
Map<String, PropertySource<?>> map = new LinkedHashMap<String, PropertySource<?>>(); Map<String, PropertySource<?>> map = new LinkedHashMap<>();
for (PropertySource<?> source : getPropertySources()) { for (PropertySource<?> source : getPropertySources()) {
extract("", map, source); extract("", map, source);
} }
......
...@@ -40,7 +40,7 @@ public class CompositeHealthIndicator implements HealthIndicator { ...@@ -40,7 +40,7 @@ public class CompositeHealthIndicator implements HealthIndicator {
* @param healthAggregator the health aggregator * @param healthAggregator the health aggregator
*/ */
public CompositeHealthIndicator(HealthAggregator healthAggregator) { public CompositeHealthIndicator(HealthAggregator healthAggregator) {
this(healthAggregator, new LinkedHashMap<String, HealthIndicator>()); this(healthAggregator, new LinkedHashMap<>());
} }
/** /**
......
...@@ -191,7 +191,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order ...@@ -191,7 +191,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
} }
private Map<String, String[]> getParameterMapCopy(HttpServletRequest request) { private Map<String, String[]> getParameterMapCopy(HttpServletRequest request) {
return new LinkedHashMap<String, String[]>(request.getParameterMap()); return new LinkedHashMap<>(request.getParameterMap());
} }
/** /**
......
...@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.entry; ...@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.entry;
*/ */
public class CachePublicMetricsTests { public class CachePublicMetricsTests {
private Map<String, CacheManager> cacheManagers = new HashMap<String, CacheManager>(); private Map<String, CacheManager> cacheManagers = new HashMap<>();
@Before @Before
public void setup() { public void setup() {
...@@ -98,7 +98,7 @@ public class CachePublicMetricsTests { ...@@ -98,7 +98,7 @@ public class CachePublicMetricsTests {
private Map<String, Number> metrics(CachePublicMetrics cpm) { private Map<String, Number> metrics(CachePublicMetrics cpm) {
Collection<Metric<?>> metrics = cpm.metrics(); Collection<Metric<?>> metrics = cpm.metrics();
assertThat(metrics).isNotNull(); assertThat(metrics).isNotNull();
Map<String, Number> result = new HashMap<String, Number>(); Map<String, Number> result = new HashMap<>();
for (Metric<?> metric : metrics) { for (Metric<?> metric : metrics) {
result.put(metric.getName(), metric.getValue()); result.put(metric.getName(), metric.getValue());
} }
......
...@@ -435,9 +435,9 @@ public class ConfigurationPropertiesReportEndpointSerializationTests { ...@@ -435,9 +435,9 @@ public class ConfigurationPropertiesReportEndpointSerializationTests {
public static class InitializedMapAndListProperties extends Foo { 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() { public Map<String, Boolean> getMap() {
return this.map; return this.map;
......
...@@ -268,7 +268,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE ...@@ -268,7 +268,7 @@ public class EnvironmentEndpointTests extends AbstractEndpointTests<EnvironmentE
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
MutablePropertySources propertySources = this.context.getEnvironment() MutablePropertySources propertySources = this.context.getEnvironment()
.getPropertySources(); .getPropertySources();
Map<String, Object> source = new HashMap<String, Object>(); Map<String, Object> source = new HashMap<>();
source.put("foo", Collections.singletonMap("bar", "baz")); source.put("foo", Collections.singletonMap("bar", "baz"));
propertySources.addFirst(new MapPropertySource("test", source)); propertySources.addFirst(new MapPropertySource("test", source));
this.context.register(Config.class); this.context.register(Config.class);
......
...@@ -142,7 +142,7 @@ public class EnvironmentMvcEndpointTests { ...@@ -142,7 +142,7 @@ public class EnvironmentMvcEndpointTests {
@Test @Test
public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty() public void nestedPathWhenPlaceholderCannotBeResolvedShouldReturnUnresolvedProperty()
throws Exception { throws Exception {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<>();
map.put("my.foo", "${my.bar}"); map.put("my.foo", "${my.bar}");
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources() ((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
.addFirst(new MapPropertySource("unresolved-placeholder", map)); .addFirst(new MapPropertySource("unresolved-placeholder", map));
...@@ -152,7 +152,7 @@ public class EnvironmentMvcEndpointTests { ...@@ -152,7 +152,7 @@ public class EnvironmentMvcEndpointTests {
@Test @Test
public void nestedPathWithSensitivePlaceholderShouldSanitize() throws Exception { 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.foo", "${my.password}");
map.put("my.password", "hello"); map.put("my.password", "hello");
((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources() ((ConfigurableEnvironment) this.context.getEnvironment()).getPropertySources()
...@@ -165,7 +165,7 @@ public class EnvironmentMvcEndpointTests { ...@@ -165,7 +165,7 @@ public class EnvironmentMvcEndpointTests {
public void propertyWithTypeOtherThanStringShouldNotFail() throws Exception { public void propertyWithTypeOtherThanStringShouldNotFail() throws Exception {
MutablePropertySources propertySources = ((ConfigurableEnvironment) this.context MutablePropertySources propertySources = ((ConfigurableEnvironment) this.context
.getEnvironment()).getPropertySources(); .getEnvironment()).getPropertySources();
Map<String, Object> source = new HashMap<String, Object>(); Map<String, Object> source = new HashMap<>();
source.put("foo", Collections.singletonMap("bar", "baz")); source.put("foo", Collections.singletonMap("bar", "baz"));
propertySources.addFirst(new MapPropertySource("test", source)); propertySources.addFirst(new MapPropertySource("test", source));
this.mvc.perform(get("/application/env/foo.*")).andExpect(status().isOk()) this.mvc.perform(get("/application/env/foo.*")).andExpect(status().isOk())
......
...@@ -97,7 +97,7 @@ public class StatsdMetricWriterTests { ...@@ -97,7 +97,7 @@ public class StatsdMetricWriterTests {
@Test @Test
public void incrementMetricWithInvalidCharsInName() throws Exception { 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(); this.server.waitForMessage();
assertThat(this.server.messagesReceived().get(0)) assertThat(this.server.messagesReceived().get(0))
.isEqualTo("me.counter.fo-o:3|c"); .isEqualTo("me.counter.fo-o:3|c");
...@@ -105,7 +105,7 @@ public class StatsdMetricWriterTests { ...@@ -105,7 +105,7 @@ public class StatsdMetricWriterTests {
@Test @Test
public void setMetricWithInvalidCharsInName() throws Exception { 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(); this.server.waitForMessage();
assertThat(this.server.messagesReceived().get(0)).isEqualTo("me.gauge.f-o-o:3|g"); assertThat(this.server.messagesReceived().get(0)).isEqualTo("me.gauge.f-o-o:3|g");
} }
......
...@@ -134,7 +134,7 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec ...@@ -134,7 +134,7 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec
AnnotationMetadata metadata) { AnnotationMetadata metadata) {
MultiValueMap<Class<?>, Annotation> annotations = new LinkedMultiValueMap<>(); MultiValueMap<Class<?>, Annotation> annotations = new LinkedMultiValueMap<>();
Class<?> source = ClassUtils.resolveClassName(metadata.getClassName(), null); Class<?> source = ClassUtils.resolveClassName(metadata.getClassName(), null);
collectAnnotations(source, annotations, new HashSet<Class<?>>()); collectAnnotations(source, annotations, new HashSet<>());
return Collections.unmodifiableMap(annotations); return Collections.unmodifiableMap(annotations);
} }
......
...@@ -34,7 +34,7 @@ public class JestProperties { ...@@ -34,7 +34,7 @@ public class JestProperties {
/** /**
* Comma-separated list of the Elasticsearch instances to use. * Comma-separated list of the Elasticsearch instances to use.
*/ */
private List<String> uris = new ArrayList<String>( private List<String> uris = new ArrayList<>(
Collections.singletonList("http://localhost:9200")); Collections.singletonList("http://localhost:9200"));
/** /**
......
...@@ -73,7 +73,7 @@ public class FlywayProperties { ...@@ -73,7 +73,7 @@ public class FlywayProperties {
* SQL statements to execute to initialize a connection immediately after obtaining * SQL statements to execute to initialize a connection immediately after obtaining
* it. * it.
*/ */
private List<String> initSqls = new ArrayList<String>(); private List<String> initSqls = new ArrayList<>();
public void setLocations(List<String> locations) { public void setLocations(List<String> locations) {
this.locations = locations; this.locations = locations;
......
...@@ -41,7 +41,7 @@ public class FreeMarkerTemplateAvailabilityProvider ...@@ -41,7 +41,7 @@ public class FreeMarkerTemplateAvailabilityProvider
static final class FreeMarkerTemplateAvailabilityProperties static final class FreeMarkerTemplateAvailabilityProperties
extends TemplateAvailabilityProperties { extends TemplateAvailabilityProperties {
private List<String> templateLoaderPath = new ArrayList<String>( private List<String> templateLoaderPath = new ArrayList<>(
Arrays.asList(FreeMarkerProperties.DEFAULT_TEMPLATE_LOADER_PATH)); Arrays.asList(FreeMarkerProperties.DEFAULT_TEMPLATE_LOADER_PATH));
FreeMarkerTemplateAvailabilityProperties() { FreeMarkerTemplateAvailabilityProperties() {
......
...@@ -41,7 +41,7 @@ public class GroovyTemplateAvailabilityProvider ...@@ -41,7 +41,7 @@ public class GroovyTemplateAvailabilityProvider
static final class GroovyTemplateAvailabilityProperties static final class GroovyTemplateAvailabilityProperties
extends TemplateAvailabilityProperties { extends TemplateAvailabilityProperties {
private List<String> resourceLoaderPath = new ArrayList<String>( private List<String> resourceLoaderPath = new ArrayList<>(
Arrays.asList(GroovyTemplateProperties.DEFAULT_RESOURCE_LOADER_PATH)); Arrays.asList(GroovyTemplateProperties.DEFAULT_RESOURCE_LOADER_PATH));
GroovyTemplateAvailabilityProperties() { GroovyTemplateAvailabilityProperties() {
......
...@@ -181,8 +181,7 @@ public class EmbeddedLdapAutoConfiguration { ...@@ -181,8 +181,7 @@ public class EmbeddedLdapAutoConfiguration {
private Map<String, Object> getLdapPorts(MutablePropertySources sources) { private Map<String, Object> getLdapPorts(MutablePropertySources sources) {
PropertySource<?> propertySource = sources.get(PROPERTY_SOURCE_NAME); PropertySource<?> propertySource = sources.get(PROPERTY_SOURCE_NAME);
if (propertySource == null) { if (propertySource == null) {
propertySource = new MapPropertySource(PROPERTY_SOURCE_NAME, propertySource = new MapPropertySource(PROPERTY_SOURCE_NAME, new HashMap<>());
new HashMap<String, Object>());
sources.addFirst(propertySource); sources.addFirst(propertySource);
} }
return (Map<String, Object>) propertySource.getSource(); return (Map<String, Object>) propertySource.getSource();
......
...@@ -179,8 +179,7 @@ public class EmbeddedMongoAutoConfiguration { ...@@ -179,8 +179,7 @@ public class EmbeddedMongoAutoConfiguration {
private Map<String, Object> getMongoPorts(MutablePropertySources sources) { private Map<String, Object> getMongoPorts(MutablePropertySources sources) {
PropertySource<?> propertySource = sources.get("mongo.ports"); PropertySource<?> propertySource = sources.get("mongo.ports");
if (propertySource == null) { if (propertySource == null) {
propertySource = new MapPropertySource("mongo.ports", propertySource = new MapPropertySource("mongo.ports", new HashMap<>());
new HashMap<String, Object>());
sources.addFirst(propertySource); sources.addFirst(propertySource);
} }
return (Map<String, Object>) propertySource.getSource(); return (Map<String, Object>) propertySource.getSource();
......
...@@ -64,7 +64,7 @@ public class UserInfoTokenServicesTests { ...@@ -64,7 +64,7 @@ public class UserInfoTokenServicesTests {
public void init() { public void init() {
this.resource.setClientId("foo"); this.resource.setClientId("foo");
given(this.template.getForEntity(any(String.class), eq(Map.class))) given(this.template.getForEntity(any(String.class), eq(Map.class)))
.willReturn(new ResponseEntity<Map>(this.map, HttpStatus.OK)); .willReturn(new ResponseEntity<>(this.map, HttpStatus.OK));
given(this.template.getAccessToken()) given(this.template.getAccessToken())
.willReturn(new DefaultOAuth2AccessToken("FOO")); .willReturn(new DefaultOAuth2AccessToken("FOO"));
given(this.template.getResource()).willReturn(this.resource); given(this.template.getResource()).willReturn(this.resource);
......
...@@ -120,7 +120,7 @@ public class ServerPropertiesTests { ...@@ -120,7 +120,7 @@ public class ServerPropertiesTests {
@Test @Test
public void redirectContextRootIsNotConfiguredByDefault() throws Exception { public void redirectContextRootIsNotConfiguredByDefault() throws Exception {
bind(new HashMap<String, String>()); bind(new HashMap<>());
ServerProperties.Tomcat tomcat = this.properties.getTomcat(); ServerProperties.Tomcat tomcat = this.properties.getTomcat();
assertThat(tomcat.getRedirectContextRoot()).isNull(); assertThat(tomcat.getRedirectContextRoot()).isNull();
} }
...@@ -164,7 +164,7 @@ public class ServerPropertiesTests { ...@@ -164,7 +164,7 @@ public class ServerPropertiesTests {
@Test @Test
public void testCustomizeJettyAccessLog() throws Exception { public void testCustomizeJettyAccessLog() throws Exception {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<>();
map.put("server.jetty.accesslog.enabled", "true"); map.put("server.jetty.accesslog.enabled", "true");
map.put("server.jetty.accesslog.filename", "foo.txt"); map.put("server.jetty.accesslog.filename", "foo.txt");
map.put("server.jetty.accesslog.file-date-format", "yyyymmdd"); map.put("server.jetty.accesslog.file-date-format", "yyyymmdd");
......
...@@ -107,7 +107,7 @@ public class DefaultServletWebServerFactoryCustomizerTests { ...@@ -107,7 +107,7 @@ public class DefaultServletWebServerFactoryCustomizerTests {
@Test @Test
public void tomcatAccessLogFileDateFormatByDefault() { public void tomcatAccessLogFileDateFormatByDefault() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<>();
map.put("server.tomcat.accesslog.enabled", "true"); map.put("server.tomcat.accesslog.enabled", "true");
bindProperties(map); bindProperties(map);
this.customizer.customize(factory); this.customizer.customize(factory);
...@@ -118,7 +118,7 @@ public class DefaultServletWebServerFactoryCustomizerTests { ...@@ -118,7 +118,7 @@ public class DefaultServletWebServerFactoryCustomizerTests {
@Test @Test
public void tomcatAccessLogFileDateFormatCanBeRedefined() { public void tomcatAccessLogFileDateFormatCanBeRedefined() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(); TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<>();
map.put("server.tomcat.accesslog.enabled", "true"); map.put("server.tomcat.accesslog.enabled", "true");
map.put("server.tomcat.accesslog.file-date-format", "yyyy-MM-dd.HH"); map.put("server.tomcat.accesslog.file-date-format", "yyyy-MM-dd.HH");
bindProperties(map); bindProperties(map);
...@@ -397,7 +397,7 @@ public class DefaultServletWebServerFactoryCustomizerTests { ...@@ -397,7 +397,7 @@ public class DefaultServletWebServerFactoryCustomizerTests {
@Test @Test
public void customTomcatDisableMaxHttpPostSize() { public void customTomcatDisableMaxHttpPostSize() {
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new HashMap<>();
map.put("server.tomcat.max-http-post-size", "-1"); map.put("server.tomcat.max-http-post-size", "-1");
bindProperties(map); bindProperties(map);
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0); TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
......
...@@ -126,8 +126,7 @@ public class DevToolsDataSourceAutoConfiguration { ...@@ -126,8 +126,7 @@ public class DevToolsDataSourceAutoConfiguration {
InMemoryDatabase(String urlPrefix, String... driverClassNames) { InMemoryDatabase(String urlPrefix, String... driverClassNames) {
this.urlPrefix = urlPrefix; this.urlPrefix = urlPrefix;
this.driverClassNames = new HashSet<String>( this.driverClassNames = new HashSet<>(Arrays.asList(driverClassNames));
Arrays.asList(driverClassNames));
} }
boolean matches(DataSourceProperties properties) { boolean matches(DataSourceProperties properties) {
......
...@@ -58,7 +58,7 @@ public abstract class AbstractEmbeddedServletContainerIntegrationTests { ...@@ -58,7 +58,7 @@ public abstract class AbstractEmbeddedServletContainerIntegrationTests {
private static List<Object> createParameters(String packaging, String container, private static List<Object> createParameters(String packaging, String container,
List<Class<? extends AbstractApplicationLauncher>> applicationLaunchers) { List<Class<? extends AbstractApplicationLauncher>> applicationLaunchers) {
List<Object> parameters = new ArrayList<Object>(); List<Object> parameters = new ArrayList<>();
ApplicationBuilder applicationBuilder = new ApplicationBuilder(temporaryFolder, ApplicationBuilder applicationBuilder = new ApplicationBuilder(temporaryFolder,
packaging, container); packaging, container);
for (Class<? extends AbstractApplicationLauncher> launcherClass : applicationLaunchers) { for (Class<? extends AbstractApplicationLauncher> launcherClass : applicationLaunchers) {
......
...@@ -56,7 +56,7 @@ class BootRunApplicationLauncher extends AbstractApplicationLauncher { ...@@ -56,7 +56,7 @@ class BootRunApplicationLauncher extends AbstractApplicationLauncher {
if (archive.getName().endsWith(".war")) { if (archive.getName().endsWith(".war")) {
populateSrcMainWebapp(); populateSrcMainWebapp();
} }
List<String> classpath = new ArrayList<String>(); List<String> classpath = new ArrayList<>();
classpath.add(targetClasses.getAbsolutePath()); classpath.add(targetClasses.getAbsolutePath());
for (File dependency : dependencies.listFiles()) { for (File dependency : dependencies.listFiles()) {
classpath.add(dependency.getAbsolutePath()); classpath.add(dependency.getAbsolutePath());
......
...@@ -67,7 +67,7 @@ class IdeApplicationLauncher extends AbstractApplicationLauncher { ...@@ -67,7 +67,7 @@ class IdeApplicationLauncher extends AbstractApplicationLauncher {
if (archive.getName().endsWith(".war")) { if (archive.getName().endsWith(".war")) {
populateSrcMainWebapp(); populateSrcMainWebapp();
} }
List<String> classpath = new ArrayList<String>(); List<String> classpath = new ArrayList<>();
classpath.add(targetClasses.getAbsolutePath()); classpath.add(targetClasses.getAbsolutePath());
for (File dependency : dependencies.listFiles()) { for (File dependency : dependencies.listFiles()) {
classpath.add(dependency.getAbsolutePath()); classpath.add(dependency.getAbsolutePath());
......
...@@ -60,7 +60,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?> ...@@ -60,7 +60,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
private Map<String, Object> getProperties(Class<?> source) { private Map<String, Object> getProperties(Class<?> source) {
Map<String, Object> properties = new LinkedHashMap<>(); Map<String, Object> properties = new LinkedHashMap<>();
collectProperties(source, source, properties, new HashSet<Class<?>>()); collectProperties(source, source, properties, new HashSet<>());
return Collections.unmodifiableMap(properties); return Collections.unmodifiableMap(properties);
} }
......
...@@ -219,7 +219,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr ...@@ -219,7 +219,7 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr
ContextConfiguration configuration) { ContextConfiguration configuration) {
ContextConfigurationAttributes attributes = new ContextConfigurationAttributes( ContextConfigurationAttributes attributes = new ContextConfigurationAttributes(
candidateConfig.getTestClass(), configuration); candidateConfig.getTestClass(), configuration);
Set<Class<?>> configurationClasses = new HashSet<Class<?>>( Set<Class<?>> configurationClasses = new HashSet<>(
Arrays.asList(attributes.getClasses())); Arrays.asList(attributes.getClasses()));
for (Class<?> candidate : candidateConfig.getClasses()) { for (Class<?> candidate : candidateConfig.getClasses()) {
if (configurationClasses.contains(candidate)) { if (configurationClasses.contains(candidate)) {
......
...@@ -60,7 +60,7 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa ...@@ -60,7 +60,7 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa
} }
private List<URL> findJsonObjects() { private List<URL> findJsonObjects() {
List<URL> jsonObjects = new ArrayList<URL>(); List<URL> jsonObjects = new ArrayList<>();
try { try {
Enumeration<URL> resources = getClass().getClassLoader() Enumeration<URL> resources = getClass().getClassLoader()
.getResources("org/json/JSONObject.class"); .getResources("org/json/JSONObject.class");
......
...@@ -158,7 +158,7 @@ public class JacksonTester<T> extends AbstractJsonMarshalTester<T> { ...@@ -158,7 +158,7 @@ public class JacksonTester<T> extends AbstractJsonMarshalTester<T> {
* @return the new instance * @return the new instance
*/ */
public JacksonTester<T> forView(Class<?> view) { public JacksonTester<T> forView(Class<?> view) {
return new JacksonTester<T>(this.getResourceLoadClass(), this.getType(), return new JacksonTester<>(this.getResourceLoadClass(), this.getType(),
this.objectMapper, view); this.objectMapper, view);
} }
......
...@@ -46,7 +46,7 @@ class BootArchiveSupport { ...@@ -46,7 +46,7 @@ class BootArchiveSupport {
private static final Set<String> DEFAULT_LAUNCHER_CLASSES; private static final Set<String> DEFAULT_LAUNCHER_CLASSES;
static { static {
Set<String> defaultLauncherClasses = new HashSet<String>(); Set<String> defaultLauncherClasses = new HashSet<>();
defaultLauncherClasses.add("org.springframework.boot.loader.JarLauncher"); defaultLauncherClasses.add("org.springframework.boot.loader.JarLauncher");
defaultLauncherClasses.add("org.springframework.boot.loader.PropertiesLauncher"); defaultLauncherClasses.add("org.springframework.boot.loader.PropertiesLauncher");
defaultLauncherClasses.add("org.springframework.boot.loader.WarLauncher"); defaultLauncherClasses.add("org.springframework.boot.loader.WarLauncher");
...@@ -121,7 +121,7 @@ class BootArchiveSupport { ...@@ -121,7 +121,7 @@ class BootArchiveSupport {
} }
private void configureExclusions() { private void configureExclusions() {
Set<String> excludes = new HashSet<String>(); Set<String> excludes = new HashSet<>();
if (this.excludeDevtools) { if (this.excludeDevtools) {
excludes.add("**/spring-boot-devtools-*.jar"); excludes.add("**/spring-boot-devtools-*.jar");
} }
......
...@@ -132,7 +132,7 @@ class BootZipCopyAction implements CopyAction { ...@@ -132,7 +132,7 @@ class BootZipCopyAction implements CopyAction {
private Spec<FileTreeElement> writeLoaderClasses(ZipArchiveOutputStream out) { private Spec<FileTreeElement> writeLoaderClasses(ZipArchiveOutputStream out) {
try (ZipInputStream in = new ZipInputStream(getClass() try (ZipInputStream in = new ZipInputStream(getClass()
.getResourceAsStream("/META-INF/loader/spring-boot-loader.jar"))) { .getResourceAsStream("/META-INF/loader/spring-boot-loader.jar"))) {
Set<String> entries = new HashSet<String>(); Set<String> entries = new HashSet<>();
java.util.zip.ZipEntry entry; java.util.zip.ZipEntry entry;
while ((entry = in.getNextEntry()) != null) { while ((entry = in.getNextEntry()) != null) {
if (entry.isDirectory() && !entry.getName().startsWith("META-INF/")) { if (entry.isDirectory() && !entry.getName().startsWith("META-INF/")) {
......
...@@ -34,7 +34,7 @@ public class LaunchScriptConfiguration implements Serializable { ...@@ -34,7 +34,7 @@ public class LaunchScriptConfiguration implements Serializable {
private boolean included = false; private boolean included = false;
private final Map<String, String> properties = new HashMap<String, String>(); private final Map<String, String> properties = new HashMap<>();
private File script; private File script;
......
...@@ -40,7 +40,7 @@ class PomCondition extends Condition<File> { ...@@ -40,7 +40,7 @@ class PomCondition extends Condition<File> {
private Set<String> notExpectedContents; private Set<String> notExpectedContents;
PomCondition() { PomCondition() {
this(new HashSet<String>(), new HashSet<String>()); this(new HashSet<>(), new HashSet<>());
} }
private PomCondition(Set<String> expectedContents, Set<String> notExpectedContents) { private PomCondition(Set<String> expectedContents, Set<String> notExpectedContents) {
......
...@@ -160,7 +160,7 @@ public class GradleBuild implements TestRule { ...@@ -160,7 +160,7 @@ public class GradleBuild implements TestRule {
if (this.gradleVersion != null) { if (this.gradleVersion != null) {
gradleRunner.withGradleVersion(this.gradleVersion); gradleRunner.withGradleVersion(this.gradleVersion);
} }
List<String> allArguments = new ArrayList<String>(); List<String> allArguments = new ArrayList<>();
allArguments.add("-PpluginClasspath=" + pluginClasspath()); allArguments.add("-PpluginClasspath=" + pluginClasspath());
allArguments.add("-PbootVersion=" + getBootVersion()); allArguments.add("-PbootVersion=" + getBootVersion());
allArguments.add("--stacktrace"); allArguments.add("--stacktrace");
......
...@@ -330,7 +330,7 @@ public class PropertiesLauncher extends Launcher { ...@@ -330,7 +330,7 @@ public class PropertiesLauncher extends Launcher {
@Override @Override
protected ClassLoader createClassLoader(List<Archive> archives) throws Exception { protected ClassLoader createClassLoader(List<Archive> archives) throws Exception {
Set<URL> urls = new LinkedHashSet<URL>(archives.size()); Set<URL> urls = new LinkedHashSet<>(archives.size());
for (Archive archive : archives) { for (Archive archive : archives) {
urls.add(archive.getUrl()); urls.add(archive.getUrl());
} }
...@@ -522,7 +522,7 @@ public class PropertiesLauncher extends Launcher { ...@@ -522,7 +522,7 @@ public class PropertiesLauncher extends Launcher {
root = ""; root = "";
} }
EntryFilter filter = new PrefixMatchingArchiveFilter(root); EntryFilter filter = new PrefixMatchingArchiveFilter(root);
List<Archive> archives = new ArrayList<Archive>(parent.getNestedArchives(filter)); List<Archive> archives = new ArrayList<>(parent.getNestedArchives(filter));
if (("".equals(root) || ".".equals(root)) && !path.endsWith(".jar") if (("".equals(root) || ".".equals(root)) && !path.endsWith(".jar")
&& parent != this.parent) { && parent != this.parent) {
// You can't find the root with an entry filter so it has to be added // You can't find the root with an entry filter so it has to be added
......
...@@ -66,7 +66,7 @@ public abstract class SystemPropertyUtils { ...@@ -66,7 +66,7 @@ public abstract class SystemPropertyUtils {
if (text == null) { if (text == null) {
return text; return text;
} }
return parseStringValue(null, text, text, new HashSet<String>()); return parseStringValue(null, text, text, new HashSet<>());
} }
/** /**
...@@ -83,7 +83,7 @@ public abstract class SystemPropertyUtils { ...@@ -83,7 +83,7 @@ public abstract class SystemPropertyUtils {
if (text == null) { if (text == null) {
return text; return text;
} }
return parseStringValue(properties, text, text, new HashSet<String>()); return parseStringValue(properties, text, text, new HashSet<>());
} }
private static String parseStringValue(Properties properties, String value, private static String parseStringValue(Properties properties, String value,
......
...@@ -266,7 +266,7 @@ public class PropertiesLauncherTests { ...@@ -266,7 +266,7 @@ public class PropertiesLauncherTests {
} }
private List<Archive> archives() throws Exception { private List<Archive> archives() throws Exception {
List<Archive> archives = new ArrayList<Archive>(); List<Archive> archives = new ArrayList<>();
String path = System.getProperty("java.class.path"); String path = System.getProperty("java.class.path");
for (String url : path.split(File.pathSeparator)) { for (String url : path.split(File.pathSeparator)) {
archives.add(archive(url)); archives.add(archive(url));
......
...@@ -100,7 +100,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner { ...@@ -100,7 +100,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
} }
private URL[] extractUrls(URLClassLoader classLoader) throws Exception { private URL[] extractUrls(URLClassLoader classLoader) throws Exception {
List<URL> extractedUrls = new ArrayList<URL>(); List<URL> extractedUrls = new ArrayList<>();
for (URL url : classLoader.getURLs()) { for (URL url : classLoader.getURLs()) {
if (isSurefireBooterJar(url)) { if (isSurefireBooterJar(url)) {
extractedUrls.addAll(extractUrlsFromManifestClassPath(url)); extractedUrls.addAll(extractUrlsFromManifestClassPath(url));
...@@ -117,7 +117,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner { ...@@ -117,7 +117,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
} }
private List<URL> extractUrlsFromManifestClassPath(URL booterJar) throws Exception { private List<URL> extractUrlsFromManifestClassPath(URL booterJar) throws Exception {
List<URL> urls = new ArrayList<URL>(); List<URL> urls = new ArrayList<>();
for (String entry : getClassPath(booterJar)) { for (String entry : getClassPath(booterJar)) {
urls.add(new URL(entry)); urls.add(new URL(entry));
} }
...@@ -133,7 +133,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner { ...@@ -133,7 +133,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
private URL[] processUrls(URL[] urls, Class<?> testClass) throws Exception { private URL[] processUrls(URL[] urls, Class<?> testClass) throws Exception {
ClassPathEntryFilter filter = new ClassPathEntryFilter(testClass); ClassPathEntryFilter filter = new ClassPathEntryFilter(testClass);
List<URL> processedUrls = new ArrayList<URL>(); List<URL> processedUrls = new ArrayList<>();
processedUrls.addAll(getAdditionalUrls(testClass)); processedUrls.addAll(getAdditionalUrls(testClass));
for (URL url : urls) { for (URL url : urls) {
if (!filter.isExcluded(url)) { if (!filter.isExcluded(url)) {
...@@ -173,7 +173,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner { ...@@ -173,7 +173,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null); DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
DependencyResult result = repositorySystem.resolveDependencies(session, DependencyResult result = repositorySystem.resolveDependencies(session,
dependencyRequest); dependencyRequest);
List<URL> resolvedArtifacts = new ArrayList<URL>(); List<URL> resolvedArtifacts = new ArrayList<>();
for (ArtifactResult artifact : result.getArtifactResults()) { for (ArtifactResult artifact : result.getArtifactResults()) {
resolvedArtifacts.add(artifact.getArtifact().getFile().toURI().toURL()); resolvedArtifacts.add(artifact.getArtifact().getFile().toURI().toURL());
} }
...@@ -181,7 +181,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner { ...@@ -181,7 +181,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
} }
private List<Dependency> createDependencies(String[] allCoordinates) { private List<Dependency> createDependencies(String[] allCoordinates) {
List<Dependency> dependencies = new ArrayList<Dependency>(); List<Dependency> dependencies = new ArrayList<>();
for (String coordinate : allCoordinates) { for (String coordinate : allCoordinates) {
dependencies.add(new Dependency(new DefaultArtifact(coordinate), null)); dependencies.add(new Dependency(new DefaultArtifact(coordinate), null));
} }
...@@ -254,8 +254,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner { ...@@ -254,8 +254,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
private List<FrameworkMethod> wrapFrameworkMethods( private List<FrameworkMethod> wrapFrameworkMethods(
List<FrameworkMethod> methods) { List<FrameworkMethod> methods) {
List<FrameworkMethod> wrapped = new ArrayList<FrameworkMethod>( List<FrameworkMethod> wrapped = new ArrayList<>(methods.size());
methods.size());
for (FrameworkMethod frameworkMethod : methods) { for (FrameworkMethod frameworkMethod : methods) {
wrapped.add(new ModifiedClassPathFrameworkMethod( wrapped.add(new ModifiedClassPathFrameworkMethod(
frameworkMethod.getMethod())); frameworkMethod.getMethod()));
......
...@@ -42,7 +42,7 @@ final class EnvironmentConverter { ...@@ -42,7 +42,7 @@ final class EnvironmentConverter {
private static final Set<String> SERVLET_ENVIRONMENT_SOURCE_NAMES; private static final Set<String> SERVLET_ENVIRONMENT_SOURCE_NAMES;
static { static {
final Set<String> names = new HashSet<String>(); final Set<String> names = new HashSet<>();
names.add(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME); names.add(StandardServletEnvironment.SERVLET_CONTEXT_PROPERTY_SOURCE_NAME);
names.add(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME); names.add(StandardServletEnvironment.SERVLET_CONFIG_PROPERTY_SOURCE_NAME);
names.add(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME); names.add(StandardServletEnvironment.JNDI_PROPERTY_SOURCE_NAME);
...@@ -109,7 +109,7 @@ final class EnvironmentConverter { ...@@ -109,7 +109,7 @@ final class EnvironmentConverter {
} }
private void removeAllPropertySources(MutablePropertySources propertySources) { private void removeAllPropertySources(MutablePropertySources propertySources) {
Set<String> names = new HashSet<String>(); Set<String> names = new HashSet<>();
for (PropertySource<?> propertySource : propertySources) { for (PropertySource<?> propertySource : propertySources) {
names.add(propertySource.getName()); names.add(propertySource.getName());
} }
......
...@@ -451,7 +451,7 @@ public final class ConfigurationPropertyName ...@@ -451,7 +451,7 @@ public final class ConfigurationPropertyName
if (name.length() == 0) { if (name.length() == 0) {
return EMPTY; return EMPTY;
} }
List<CharSequence> elements = new ArrayList<CharSequence>(10); List<CharSequence> elements = new ArrayList<>(10);
process(name, '.', (elementValue, start, end, indexed) -> { process(name, '.', (elementValue, start, end, indexed) -> {
if (elementValue.length() > 0) { if (elementValue.length() > 0) {
if (!indexed) { if (!indexed) {
...@@ -496,7 +496,7 @@ public final class ConfigurationPropertyName ...@@ -496,7 +496,7 @@ public final class ConfigurationPropertyName
if (name.length() == 0) { if (name.length() == 0) {
return EMPTY; return EMPTY;
} }
List<CharSequence> elements = new ArrayList<CharSequence>(10); List<CharSequence> elements = new ArrayList<>(10);
process(name, separator, (elementValue, start, end, indexed) -> { process(name, separator, (elementValue, start, end, indexed) -> {
elementValue = elementValueProcessor.apply(elementValue); elementValue = elementValueProcessor.apply(elementValue);
if (!isIndexed(elementValue)) { if (!isIndexed(elementValue)) {
......
...@@ -78,7 +78,7 @@ class OriginTrackedYamlLoader extends YamlProcessor { ...@@ -78,7 +78,7 @@ class OriginTrackedYamlLoader extends YamlProcessor {
} }
public Map<String, Object> load() { public Map<String, Object> load() {
final Map<String, Object> result = new LinkedHashMap<String, Object>(); final Map<String, Object> result = new LinkedHashMap<>();
process((properties, map) -> { process((properties, map) -> {
result.putAll(getFlattenedMap(map)); result.putAll(getFlattenedMap(map));
}); });
......
...@@ -91,21 +91,21 @@ public class NarayanaProperties { ...@@ -91,21 +91,21 @@ public class NarayanaProperties {
/** /**
* Comma-separated list of orphan filters. * Comma-separated list of orphan filters.
*/ */
private List<String> xaResourceOrphanFilters = new ArrayList<String>(Arrays.asList( private List<String> xaResourceOrphanFilters = new ArrayList<>(Arrays.asList(
"com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter", "com.arjuna.ats.internal.jta.recovery.arjunacore.JTATransactionLogXAResourceOrphanFilter",
"com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter")); "com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter"));
/** /**
* Comma-separated list of recovery modules. * Comma-separated list of recovery modules.
*/ */
private List<String> recoveryModules = new ArrayList<String>(Arrays.asList( private List<String> recoveryModules = new ArrayList<>(Arrays.asList(
"com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule", "com.arjuna.ats.internal.arjuna.recovery.AtomicActionRecoveryModule",
"com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule")); "com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule"));
/** /**
* Comma-separated list of expiry scanners. * Comma-separated list of expiry scanners.
*/ */
private List<String> expiryScanners = new ArrayList<String>(Collections.singletonList( private List<String> expiryScanners = new ArrayList<>(Collections.singletonList(
"com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner")); "com.arjuna.ats.internal.arjuna.recovery.ExpiredTransactionStatusManagerScanner"));
public String getLogDir() { public String getLogDir() {
......
...@@ -88,7 +88,7 @@ public class ServerPortInfoApplicationContextInitializer ...@@ -88,7 +88,7 @@ public class ServerPortInfoApplicationContextInitializer
MutablePropertySources sources = environment.getPropertySources(); MutablePropertySources sources = environment.getPropertySources();
PropertySource<?> source = sources.get("server.ports"); PropertySource<?> source = sources.get("server.ports");
if (source == null) { if (source == null) {
source = new MapPropertySource("server.ports", new HashMap<String, Object>()); source = new MapPropertySource("server.ports", new HashMap<>());
sources.addFirst(source); sources.addFirst(source);
} }
((Map<String, Object>) source.getSource()).put(propertyName, port); ((Map<String, Object>) source.getSource()).put(propertyName, port);
......
...@@ -489,7 +489,7 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac ...@@ -489,7 +489,7 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
File root = getValidDocumentRoot(); File root = getValidDocumentRoot();
File docBase = getCanonicalDocumentRoot(root); File docBase = getCanonicalDocumentRoot(root);
List<URL> metaInfResourceUrls = getUrlsOfJarsWithMetaInfResources(); List<URL> metaInfResourceUrls = getUrlsOfJarsWithMetaInfResources();
List<URL> resourceJarUrls = new ArrayList<URL>(); List<URL> resourceJarUrls = new ArrayList<>();
List<ResourceManager> resourceManagers = new ArrayList<ResourceManager>(); List<ResourceManager> resourceManagers = new ArrayList<ResourceManager>();
ResourceManager rootResourceManager = docBase.isDirectory() ResourceManager rootResourceManager = docBase.isDirectory()
? new FileResourceManager(docBase, 0) : new JarResourceManager(docBase); ? new FileResourceManager(docBase, 0) : new JarResourceManager(docBase);
......
...@@ -444,7 +444,7 @@ public class ConfigurationPropertiesBindingPostProcessorTests { ...@@ -444,7 +444,7 @@ public class ConfigurationPropertiesBindingPostProcessorTests {
this.context = new AnnotationConfigApplicationContext(); this.context = new AnnotationConfigApplicationContext();
MutablePropertySources sources = this.context.getEnvironment() MutablePropertySources sources = this.context.getEnvironment()
.getPropertySources(); .getPropertySources();
Map<String, Object> source = new LinkedHashMap<String, Object>(); Map<String, Object> source = new LinkedHashMap<>();
source.put("example.one", "foo"); source.put("example.one", "foo");
sources.addFirst(new MapPropertySource("test-source", source)); sources.addFirst(new MapPropertySource("test-source", source));
this.context.register(PrototypePropertiesConfig.class); this.context.register(PrototypePropertiesConfig.class);
......
...@@ -154,7 +154,7 @@ public class WebServerFactoryCustomizerBeanPostProcessorTests { ...@@ -154,7 +154,7 @@ public class WebServerFactoryCustomizerBeanPostProcessorTests {
WebServerFactoryCustomizer<WebServerFactoryOne> one = (f) -> called.add("one"); WebServerFactoryCustomizer<WebServerFactoryOne> one = (f) -> called.add("one");
WebServerFactoryCustomizer<WebServerFactoryTwo> two = (f) -> called.add("two"); WebServerFactoryCustomizer<WebServerFactoryTwo> two = (f) -> called.add("two");
WebServerFactoryCustomizer<WebServerFactory> all = (f) -> called.add("all"); WebServerFactoryCustomizer<WebServerFactory> all = (f) -> called.add("all");
Map<String, Object> beans = new LinkedHashMap<String, Object>(); Map<String, Object> beans = new LinkedHashMap<>();
beans.put("one", one); beans.put("one", one);
beans.put("two", two); beans.put("two", two);
beans.put("all", all); beans.put("all", all);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment