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

@@ -46,7 +46,7 @@ class BootArchiveSupport {
private static final Set<String> DEFAULT_LAUNCHER_CLASSES;
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.PropertiesLauncher");
defaultLauncherClasses.add("org.springframework.boot.loader.WarLauncher");
@@ -121,7 +121,7 @@ class BootArchiveSupport {
}
private void configureExclusions() {
Set<String> excludes = new HashSet<String>();
Set<String> excludes = new HashSet<>();
if (this.excludeDevtools) {
excludes.add("**/spring-boot-devtools-*.jar");
}

View File

@@ -132,7 +132,7 @@ class BootZipCopyAction implements CopyAction {
private Spec<FileTreeElement> writeLoaderClasses(ZipArchiveOutputStream out) {
try (ZipInputStream in = new ZipInputStream(getClass()
.getResourceAsStream("/META-INF/loader/spring-boot-loader.jar"))) {
Set<String> entries = new HashSet<String>();
Set<String> entries = new HashSet<>();
java.util.zip.ZipEntry entry;
while ((entry = in.getNextEntry()) != null) {
if (entry.isDirectory() && !entry.getName().startsWith("META-INF/")) {

View File

@@ -34,7 +34,7 @@ public class LaunchScriptConfiguration implements Serializable {
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;

View File

@@ -40,7 +40,7 @@ class PomCondition extends Condition<File> {
private Set<String> notExpectedContents;
PomCondition() {
this(new HashSet<String>(), new HashSet<String>());
this(new HashSet<>(), new HashSet<>());
}
private PomCondition(Set<String> expectedContents, Set<String> notExpectedContents) {

View File

@@ -160,7 +160,7 @@ public class GradleBuild implements TestRule {
if (this.gradleVersion != null) {
gradleRunner.withGradleVersion(this.gradleVersion);
}
List<String> allArguments = new ArrayList<String>();
List<String> allArguments = new ArrayList<>();
allArguments.add("-PpluginClasspath=" + pluginClasspath());
allArguments.add("-PbootVersion=" + getBootVersion());
allArguments.add("--stacktrace");

View File

@@ -330,7 +330,7 @@ public class PropertiesLauncher extends Launcher {
@Override
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) {
urls.add(archive.getUrl());
}
@@ -522,7 +522,7 @@ public class PropertiesLauncher extends Launcher {
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")
&& parent != this.parent) {
// You can't find the root with an entry filter so it has to be added

View File

@@ -66,7 +66,7 @@ public abstract class SystemPropertyUtils {
if (text == null) {
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 {
if (text == null) {
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,

View File

@@ -266,7 +266,7 @@ public class PropertiesLauncherTests {
}
private List<Archive> archives() throws Exception {
List<Archive> archives = new ArrayList<Archive>();
List<Archive> archives = new ArrayList<>();
String path = System.getProperty("java.class.path");
for (String url : path.split(File.pathSeparator)) {
archives.add(archive(url));

View File

@@ -100,7 +100,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
}
private URL[] extractUrls(URLClassLoader classLoader) throws Exception {
List<URL> extractedUrls = new ArrayList<URL>();
List<URL> extractedUrls = new ArrayList<>();
for (URL url : classLoader.getURLs()) {
if (isSurefireBooterJar(url)) {
extractedUrls.addAll(extractUrlsFromManifestClassPath(url));
@@ -117,7 +117,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
}
private List<URL> extractUrlsFromManifestClassPath(URL booterJar) throws Exception {
List<URL> urls = new ArrayList<URL>();
List<URL> urls = new ArrayList<>();
for (String entry : getClassPath(booterJar)) {
urls.add(new URL(entry));
}
@@ -133,7 +133,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
private URL[] processUrls(URL[] urls, Class<?> testClass) throws Exception {
ClassPathEntryFilter filter = new ClassPathEntryFilter(testClass);
List<URL> processedUrls = new ArrayList<URL>();
List<URL> processedUrls = new ArrayList<>();
processedUrls.addAll(getAdditionalUrls(testClass));
for (URL url : urls) {
if (!filter.isExcluded(url)) {
@@ -173,7 +173,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
DependencyRequest dependencyRequest = new DependencyRequest(collectRequest, null);
DependencyResult result = repositorySystem.resolveDependencies(session,
dependencyRequest);
List<URL> resolvedArtifacts = new ArrayList<URL>();
List<URL> resolvedArtifacts = new ArrayList<>();
for (ArtifactResult artifact : result.getArtifactResults()) {
resolvedArtifacts.add(artifact.getArtifact().getFile().toURI().toURL());
}
@@ -181,7 +181,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
}
private List<Dependency> createDependencies(String[] allCoordinates) {
List<Dependency> dependencies = new ArrayList<Dependency>();
List<Dependency> dependencies = new ArrayList<>();
for (String coordinate : allCoordinates) {
dependencies.add(new Dependency(new DefaultArtifact(coordinate), null));
}
@@ -254,8 +254,7 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner {
private List<FrameworkMethod> wrapFrameworkMethods(
List<FrameworkMethod> methods) {
List<FrameworkMethod> wrapped = new ArrayList<FrameworkMethod>(
methods.size());
List<FrameworkMethod> wrapped = new ArrayList<>(methods.size());
for (FrameworkMethod frameworkMethod : methods) {
wrapped.add(new ModifiedClassPathFrameworkMethod(
frameworkMethod.getMethod()));