Cleanup and format code

This commit is contained in:
Phillip Webb
2017-03-06 16:44:31 -08:00
parent c7b46e4d1c
commit d8f827d224
649 changed files with 1922 additions and 2003 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -80,7 +80,7 @@ public final class SpringCli {
}
private static URL[] getExtensionURLs() {
List<URL> urls = new ArrayList<URL>();
List<URL> urls = new ArrayList<>();
String home = SystemPropertyUtils
.resolvePlaceholders("${spring.home:${SPRING_HOME:.}}");
File extDirectory = new File(new File(home, "lib"), "ext");

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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 SpringApplicationLauncher {
* @throws Exception if the launch fails
*/
public Object launch(Object[] sources, String[] args) throws Exception {
Map<String, Object> defaultProperties = new HashMap<String, Object>();
Map<String, Object> defaultProperties = new HashMap<>();
defaultProperties.put("spring.groovy.template.check-template-location", "false");
Class<?> applicationClass = this.classLoader
.loadClass(getSpringApplicationClassName());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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 @@ public class CommandRunner implements Iterable<Command> {
private final String name;
private final List<Command> commands = new ArrayList<Command>();
private final List<Command> commands = new ArrayList<>();
private Class<?>[] optionCommandClasses = {};
@@ -185,7 +185,7 @@ public class CommandRunner implements Iterable<Command> {
}
private String[] removeDebugFlags(String[] args) {
List<String> rtn = new ArrayList<String>(args.length);
List<String> rtn = new ArrayList<>(args.length);
boolean appArgsDetected = false;
for (String arg : args) {
// Allow apps to have a -d argument

View File

@@ -168,7 +168,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
}
private List<URL> getClassPathUrls(GroovyCompiler compiler) {
return new ArrayList<URL>(Arrays.asList(compiler.getLoader().getURLs()));
return new ArrayList<>(Arrays.asList(compiler.getLoader().getURLs()));
}
private List<MatchedResource> findMatchingClasspathEntries(List<URL> classpath,
@@ -176,7 +176,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
ResourceMatcher matcher = new ResourceMatcher(
options.valuesOf(this.includeOption),
options.valuesOf(this.excludeOption));
List<File> roots = new ArrayList<File>();
List<File> roots = new ArrayList<>();
for (URL classpathEntry : classpath) {
roots.add(new File(URI.create(classpathEntry.toString())));
}
@@ -215,7 +215,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private List<Library> createLibraries(List<URL> dependencies)
throws URISyntaxException {
List<Library> libraries = new ArrayList<Library>();
List<Library> libraries = new ArrayList<>();
for (URL dependency : dependencies) {
File file = new File(dependency.toURI());
libraries.add(new Library(file, getLibraryScope(file)));
@@ -277,7 +277,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private List<Library> addClasspathEntries(JarWriter writer,
List<MatchedResource> entries) throws IOException {
List<Library> libraries = new ArrayList<Library>();
List<Library> libraries = new ArrayList<>();
for (MatchedResource entry : entries) {
if (entry.isRoot()) {
libraries.add(new Library(entry.getFile(), LibraryScope.COMPILE));
@@ -329,7 +329,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private void disableGrabResolvers(List<? extends AnnotatedNode> nodes) {
for (AnnotatedNode classNode : nodes) {
List<AnnotationNode> annotations = classNode.getAnnotations();
for (AnnotationNode node : new ArrayList<AnnotationNode>(annotations)) {
for (AnnotationNode node : new ArrayList<>(annotations)) {
if (node.getClassNode().getNameWithoutPackage()
.equals("GrabResolver")) {
node.setMember("initClass", new ConstantExpression(false));

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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.
@@ -60,7 +60,7 @@ class ResourceMatcher {
}
public List<MatchedResource> find(List<File> roots) throws IOException {
List<MatchedResource> matchedResources = new ArrayList<MatchedResource>();
List<MatchedResource> matchedResources = new ArrayList<>();
for (File root : roots) {
if (root.isFile()) {
matchedResources.add(new MatchedResource(root));
@@ -73,7 +73,7 @@ class ResourceMatcher {
}
private List<MatchedResource> findInFolder(File folder) throws IOException {
List<MatchedResource> matchedResources = new ArrayList<MatchedResource>();
List<MatchedResource> matchedResources = new ArrayList<>();
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(
new FolderResourceLoader(folder));
@@ -103,8 +103,8 @@ class ResourceMatcher {
}
private List<String> getOptions(List<String> values, String[] defaults) {
Set<String> result = new LinkedHashSet<String>();
Set<String> minus = new LinkedHashSet<String>();
Set<String> result = new LinkedHashSet<>();
Set<String> minus = new LinkedHashSet<>();
boolean deltasFound = false;
for (String value : values) {
if (value.startsWith("+")) {
@@ -126,7 +126,7 @@ class ResourceMatcher {
result.add(value);
}
}
return new ArrayList<String>(result);
return new ArrayList<>(result);
}
/**

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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 HelpCommand extends AbstractCommand {
@Override
public Collection<OptionHelp> getOptionsHelp() {
List<OptionHelp> help = new ArrayList<OptionHelp>();
List<OptionHelp> help = new ArrayList<>();
for (final Command command : this.commandRunner) {
if (isHelpShown(command)) {
help.add(new OptionHelp() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -46,7 +46,7 @@ public class HintCommand extends AbstractCommand {
public ExitStatus run(String... args) throws Exception {
try {
int index = (args.length == 0 ? 0 : Integer.valueOf(args[0]) - 1);
List<String> arguments = new ArrayList<String>(args.length);
List<String> arguments = new ArrayList<>(args.length);
for (int i = 2; i < args.length; i++) {
arguments.add(args[i]);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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.
@@ -59,7 +59,7 @@ public class InitCommand extends OptionParsingCommand {
@Override
public Collection<HelpExample> getExamples() {
List<HelpExample> examples = new ArrayList<HelpExample>();
List<HelpExample> examples = new ArrayList<>();
examples.add(new HelpExample("To list all the capabilities of the service",
"spring init --list"));
examples.add(new HelpExample("To creates a default project", "spring init"));

View File

@@ -68,12 +68,12 @@ class InitializrServiceMetadata {
}
InitializrServiceMetadata(ProjectType defaultProjectType) {
this.dependencies = new HashMap<String, Dependency>();
this.projectTypes = new MetadataHolder<String, ProjectType>();
this.dependencies = new HashMap<>();
this.projectTypes = new MetadataHolder<>();
this.projectTypes.getContent().put(defaultProjectType.getId(),
defaultProjectType);
this.projectTypes.setDefaultItem(defaultProjectType);
this.defaults = new HashMap<String, String>();
this.defaults = new HashMap<>();
}
/**
@@ -128,7 +128,7 @@ class InitializrServiceMetadata {
private Map<String, Dependency> parseDependencies(JSONObject root)
throws JSONException {
Map<String, Dependency> result = new HashMap<String, Dependency>();
Map<String, Dependency> result = new HashMap<>();
if (!root.has(DEPENDENCIES_EL)) {
return result;
}
@@ -143,7 +143,7 @@ class InitializrServiceMetadata {
private MetadataHolder<String, ProjectType> parseProjectTypes(JSONObject root)
throws JSONException {
MetadataHolder<String, ProjectType> result = new MetadataHolder<String, ProjectType>();
MetadataHolder<String, ProjectType> result = new MetadataHolder<>();
if (!root.has(TYPE_EL)) {
return result;
}
@@ -163,7 +163,7 @@ class InitializrServiceMetadata {
}
private Map<String, String> parseDefaults(JSONObject root) throws JSONException {
Map<String, String> result = new HashMap<String, String>();
Map<String, String> result = new HashMap<>();
Iterator<?> keys = root.keys();
while (keys.hasNext()) {
String key = (String) keys.next();
@@ -202,7 +202,7 @@ class InitializrServiceMetadata {
String name = getStringValue(object, NAME_ATTRIBUTE, null);
String action = getStringValue(object, ACTION_ATTRIBUTE, null);
boolean defaultType = id.equals(defaultId);
Map<String, String> tags = new HashMap<String, String>();
Map<String, String> tags = new HashMap<>();
if (object.has("tags")) {
JSONObject jsonTags = object.getJSONObject("tags");
tags.putAll(parseStringItems(jsonTags));
@@ -216,7 +216,7 @@ class InitializrServiceMetadata {
}
private Map<String, String> parseStringItems(JSONObject json) throws JSONException {
Map<String, String> result = new HashMap<String, String>();
Map<String, String> result = new HashMap<>();
for (Iterator<?> iterator = json.keys(); iterator.hasNext();) {
String key = (String) iterator.next();
Object value = json.get(key);
@@ -234,7 +234,7 @@ class InitializrServiceMetadata {
private T defaultItem;
private MetadataHolder() {
this.content = new HashMap<K, T>();
this.content = new HashMap<>();
}
public Map<K, T> getContent() {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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.
@@ -73,7 +73,7 @@ class ProjectGenerationRequest {
private String bootVersion;
private List<String> dependencies = new ArrayList<String>();
private List<String> dependencies = new ArrayList<>();
/**
* The URL of the service to use.
@@ -374,8 +374,7 @@ class ProjectGenerationRequest {
return result;
}
else if (isDetectType()) {
Map<String, ProjectType> types = new HashMap<String, ProjectType>(
metadata.getProjectTypes());
Map<String, ProjectType> types = new HashMap<>(metadata.getProjectTypes());
if (this.build != null) {
filter(types, "build", this.build);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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 @@ class ProjectType {
private final boolean defaultType;
private final Map<String, String> tags = new HashMap<String, String>();
private final Map<String, String> tags = new HashMap<>();
ProjectType(String id, String name, String action, boolean defaultType,
Map<String, String> tags) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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,8 +93,7 @@ class ServiceCapabilitiesReportGenerator {
}
private List<Dependency> getSortedDependencies(InitializrServiceMetadata metadata) {
ArrayList<Dependency> dependencies = new ArrayList<Dependency>(
metadata.getDependencies());
ArrayList<Dependency> dependencies = new ArrayList<>(metadata.getDependencies());
Collections.sort(dependencies, new Comparator<Dependency>() {
@Override
public int compare(Dependency o1, Dependency o2) {
@@ -108,7 +107,7 @@ class ServiceCapabilitiesReportGenerator {
StringBuilder report) {
report.append("Available project types:" + NEW_LINE);
report.append("------------------------" + NEW_LINE);
SortedSet<Entry<String, ProjectType>> entries = new TreeSet<Entry<String, ProjectType>>(
SortedSet<Entry<String, ProjectType>> entries = new TreeSet<>(
new Comparator<Entry<String, ProjectType>>() {
@Override
@@ -150,8 +149,7 @@ class ServiceCapabilitiesReportGenerator {
InitializrServiceMetadata metadata) {
report.append("Defaults:" + NEW_LINE);
report.append("---------" + NEW_LINE);
List<String> defaultsKeys = new ArrayList<String>(
metadata.getDefaults().keySet());
List<String> defaultsKeys = new ArrayList<>(metadata.getDefaults().keySet());
Collections.sort(defaultsKeys);
for (String defaultsKey : defaultsKeys) {
String defaultsValue = metadata.getDefaults().get(defaultsKey);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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 @@ class GroovyGrabDependencyResolver implements DependencyResolver {
public List<File> resolve(List<String> artifactIdentifiers)
throws CompilationFailedException, IOException {
GroovyCompiler groovyCompiler = new GroovyCompiler(this.configuration);
List<File> artifactFiles = new ArrayList<File>();
List<File> artifactFiles = new ArrayList<>();
if (!artifactIdentifiers.isEmpty()) {
List<URL> initialUrls = getClassPathUrls(groovyCompiler);
groovyCompiler.compile(createSources(artifactIdentifiers));
@@ -64,7 +64,7 @@ class GroovyGrabDependencyResolver implements DependencyResolver {
}
private List<URL> getClassPathUrls(GroovyCompiler compiler) {
return new ArrayList<URL>(Arrays.asList(compiler.getLoader().getURLs()));
return new ArrayList<>(Arrays.asList(compiler.getLoader().getURLs()));
}
private String createSources(List<String> artifactIdentifiers) throws IOException {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -126,7 +126,7 @@ public class OptionHandler {
private static class OptionHelpFormatter implements HelpFormatter {
private final List<OptionHelp> help = new ArrayList<OptionHelp>();
private final List<OptionHelp> help = new ArrayList<>();
@Override
public String format(Map<String, ? extends OptionDescriptor> options) {
@@ -138,7 +138,7 @@ public class OptionHandler {
}
};
Set<OptionDescriptor> sorted = new TreeSet<OptionDescriptor>(comparator);
Set<OptionDescriptor> sorted = new TreeSet<>(comparator);
sorted.addAll(options.values());
for (OptionDescriptor descriptor : sorted) {
@@ -162,7 +162,7 @@ public class OptionHandler {
private final String description;
OptionHelpAdapter(OptionDescriptor descriptor) {
this.options = new LinkedHashSet<String>();
this.options = new LinkedHashSet<>();
for (String option : descriptor.options()) {
this.options.add((option.length() == 1 ? "-" : "--") + option);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -71,7 +71,7 @@ public class SourceOptions {
}
private SourceOptions(List<?> nonOptionArguments, ClassLoader classLoader) {
List<String> sources = new ArrayList<String>();
List<String> sources = new ArrayList<>();
int sourceArgCount = 0;
for (Object option : nonOptionArguments) {
if (option instanceof String) {
@@ -79,7 +79,7 @@ public class SourceOptions {
if ("--".equals(filename)) {
break;
}
List<String> urls = new ArrayList<String>();
List<String> urls = new ArrayList<>();
File fileCandidate = new File(filename);
if (fileCandidate.isFile()) {
urls.add(fileCandidate.getAbsoluteFile().toURI().toString());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -230,7 +230,7 @@ public class SpringApplicationRunner {
}
private List<File> getSourceFiles() {
List<File> sources = new ArrayList<File>();
List<File> sources = new ArrayList<>();
for (String source : SpringApplicationRunner.this.sources) {
List<String> paths = ResourceUtils.getUrls(source,
SpringApplicationRunner.this.compiler.getLoader());

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -42,20 +42,20 @@ import org.springframework.boot.cli.util.Log;
*/
public class CommandCompleter extends StringsCompleter {
private final Map<String, Completer> commandCompleters = new HashMap<String, Completer>();
private final Map<String, Completer> commandCompleters = new HashMap<>();
private final List<Command> commands = new ArrayList<Command>();
private final List<Command> commands = new ArrayList<>();
private final ConsoleReader console;
public CommandCompleter(ConsoleReader consoleReader,
ArgumentDelimiter argumentDelimiter, Iterable<Command> commands) {
this.console = consoleReader;
List<String> names = new ArrayList<String>();
List<String> names = new ArrayList<>();
for (Command command : commands) {
this.commands.add(command);
names.add(command.getName());
List<String> options = new ArrayList<String>();
List<String> options = new ArrayList<>();
for (OptionHelp optionHelp : command.getOptionsHelp()) {
options.addAll(optionHelp.getOptions());
}
@@ -95,7 +95,7 @@ public class CommandCompleter extends StringsCompleter {
private void printUsage(Command command) {
try {
int maxOptionsLength = 0;
List<OptionHelpLine> optionHelpLines = new ArrayList<OptionHelpLine>();
List<OptionHelpLine> optionHelpLines = new ArrayList<>();
for (OptionHelp optionHelp : command.getOptionsHelp()) {
OptionHelpLine optionHelpLine = new OptionHelpLine(optionHelp);
optionHelpLines.add(optionHelpLine);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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 @@ class ForkProcessCommand extends RunProcessCommand {
@Override
public ExitStatus run(String... args) throws Exception {
List<String> fullArgs = new ArrayList<String>();
List<String> fullArgs = new ArrayList<>();
fullArgs.add("-cp");
fullArgs.add(System.getProperty("java.class.path"));
fullArgs.add(MAIN_CLASS);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -51,7 +51,7 @@ public class Shell {
private static final Set<Class<?>> NON_FORKED_COMMANDS;
static {
Set<Class<?>> nonForked = new HashSet<Class<?>>();
Set<Class<?>> nonForked = new HashSet<>();
nonForked.add(VersionCommand.class);
NON_FORKED_COMMANDS = Collections.unmodifiableSet(nonForked);
}
@@ -86,7 +86,7 @@ public class Shell {
}
private Iterable<Command> getCommands() {
List<Command> commands = new ArrayList<Command>();
List<Command> commands = new ArrayList<>();
ServiceLoader<CommandFactory> factories = ServiceLoader.load(CommandFactory.class,
getClass().getClassLoader());
for (CommandFactory factory : factories) {
@@ -193,7 +193,7 @@ public class Shell {
private volatile Command lastCommand;
private final Map<String, String> aliases = new HashMap<String, String>();
private final Map<String, String> aliases = new HashMap<>();
ShellCommandRunner() {
super(null);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -27,7 +27,7 @@ public class ShellPrompts {
private static final String DEFAULT_PROMPT = "$ ";
private final Stack<String> prompts = new Stack<String>();
private final Stack<String> prompts = new Stack<>();
/**
* Push a new prompt to be used by the shell.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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 class TestRunner {
}
private Class<?>[] getTestClasses(Object[] sources) {
List<Class<?>> testClasses = new ArrayList<Class<?>>();
List<Class<?>> testClasses = new ArrayList<>();
for (Object source : sources) {
if ((source instanceof Class) && isTestable((Class<?>) source)) {
testClasses.add((Class<?>) source);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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 abstract class AnnotatedNodeASTTransformation implements ASTTransformatio
@Override
public void visit(ASTNode[] nodes, SourceUnit source) {
this.sourceUnit = source;
List<AnnotationNode> annotationNodes = new ArrayList<AnnotationNode>();
List<AnnotationNode> annotationNodes = new ArrayList<>();
ClassVisitor classVisitor = new ClassVisitor(source, annotationNodes);
for (ASTNode node : nodes) {
if (node instanceof ModuleNode) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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 abstract class AstUtils {
* @return {@code true} if at least one of the types is found, otherwise {@code false}
*/
public static boolean hasAtLeastOneFieldOrMethod(ClassNode node, String... types) {
Set<String> typesSet = new HashSet<String>(Arrays.asList(types));
Set<String> typesSet = new HashSet<>(Arrays.asList(types));
for (FieldNode field : node.getFields()) {
if (typesSet.contains(field.getType().getName())) {
return true;
@@ -130,7 +130,7 @@ public abstract class AstUtils {
}
public static boolean hasAtLeastOneInterface(ClassNode classNode, String... types) {
Set<String> typesSet = new HashSet<String>(Arrays.asList(types));
Set<String> typesSet = new HashSet<>(Arrays.asList(types));
for (ClassNode inter : classNode.getInterfaces()) {
if (typesSet.contains(inter.getName())) {
return true;
@@ -167,7 +167,7 @@ public abstract class AstUtils {
private static List<ExpressionStatement> getExpressionStatements(
BlockStatement block) {
ArrayList<ExpressionStatement> statements = new ArrayList<ExpressionStatement>();
ArrayList<ExpressionStatement> statements = new ArrayList<>();
for (Statement statement : block.getStatements()) {
if (statement instanceof ExpressionStatement) {
statements.add((ExpressionStatement) statement);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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,8 +70,8 @@ public class DependencyManagementBomTransformation
public static final int ORDER = Ordered.HIGHEST_PRECEDENCE + 100;
private static final Set<String> DEPENDENCY_MANAGEMENT_BOM_ANNOTATION_NAMES = Collections
.unmodifiableSet(new HashSet<String>(
Arrays.asList(DependencyManagementBom.class.getName(),
.unmodifiableSet(
new HashSet<>(Arrays.asList(DependencyManagementBom.class.getName(),
DependencyManagementBom.class.getSimpleName())));
private final DependencyResolutionContext resolutionContext;
@@ -106,14 +106,14 @@ public class DependencyManagementBomTransformation
Map<String, String> dependency = null;
List<ConstantExpression> constantExpressions = getConstantExpressions(
valueExpression);
List<Map<String, String>> dependencies = new ArrayList<Map<String, String>>(
List<Map<String, String>> dependencies = new ArrayList<>(
constantExpressions.size());
for (ConstantExpression expression : constantExpressions) {
Object value = expression.getValue();
if (value instanceof String) {
String[] components = ((String) expression.getValue()).split(":");
if (components.length == 3) {
dependency = new HashMap<String, String>();
dependency = new HashMap<>();
dependency.put("group", components[0]);
dependency.put("module", components[1]);
dependency.put("version", components[2]);
@@ -143,7 +143,7 @@ public class DependencyManagementBomTransformation
private List<ConstantExpression> getConstantExpressions(
ListExpression valueExpression) {
List<ConstantExpression> expressions = new ArrayList<ConstantExpression>();
List<ConstantExpression> expressions = new ArrayList<>();
for (Expression expression : valueExpression.getExpressions()) {
if (expression instanceof ConstantExpression
&& ((ConstantExpression) expression).getValue() instanceof String) {
@@ -213,7 +213,7 @@ public class DependencyManagementBomTransformation
@Override
public ModelSource resolveModel(String groupId, String artifactId, String version)
throws UnresolvableModelException {
Map<String, String> dependency = new HashMap<String, String>();
Map<String, String> dependency = new HashMap<>();
dependency.put("group", groupId);
dependency.put("module", artifactId);
dependency.put("version", version);

View File

@@ -53,7 +53,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
private static final URL[] NO_URLS = new URL[] {};
private final Map<String, byte[]> classResources = new HashMap<String, byte[]>();
private final Map<String, byte[]> classResources = new HashMap<>();
private final GroovyCompilerScope scope;
@@ -183,13 +183,13 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
}
private URL[] getGroovyJars(final ClassLoader parent) {
Set<URL> urls = new HashSet<URL>();
Set<URL> urls = new HashSet<>();
findGroovyJarsDirectly(parent, urls);
if (urls.isEmpty()) {
findGroovyJarsFromClassPath(parent, urls);
}
Assert.state(!urls.isEmpty(), "Unable to find groovy JAR");
return new ArrayList<URL>(urls).toArray(new URL[urls.size()]);
return new ArrayList<>(urls).toArray(new URL[urls.size()]);
}
private void findGroovyJarsDirectly(ClassLoader classLoader, Set<URL> urls) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -81,7 +81,7 @@ public abstract class GenericBomAstTransformation
AnnotatedNode annotated = getAnnotatedNode(node);
if (annotated != null) {
AnnotationNode bom = getAnnotation(annotated);
List<Expression> expressions = new ArrayList<Expression>(
List<Expression> expressions = new ArrayList<>(
getConstantExpressions(bom.getMember("value")));
expressions.add(new ConstantExpression(module));
bom.setMember("value", new ListExpression(expressions));
@@ -122,7 +122,7 @@ public abstract class GenericBomAstTransformation
private List<ConstantExpression> getConstantExpressions(
ListExpression valueExpression) {
List<ConstantExpression> expressions = new ArrayList<ConstantExpression>();
List<ConstantExpression> expressions = new ArrayList<>();
for (Expression expression : valueExpression.getExpressions()) {
if (expression instanceof ConstantExpression
&& ((ConstantExpression) expression).getValue() instanceof String) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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.
@@ -53,8 +53,7 @@ public class GroovyBeansTransformation implements ASTTransformation {
for (ASTNode node : nodes) {
if (node instanceof ModuleNode) {
ModuleNode module = (ModuleNode) node;
for (ClassNode classNode : new ArrayList<ClassNode>(
module.getClasses())) {
for (ClassNode classNode : new ArrayList<>(module.getClasses())) {
if (classNode.isScript()) {
classNode.visitContents(new ClassVisitor(source, classNode));
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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 GroovyCompiler {
this.compilerAutoConfigurations = Collections.emptySet();
}
this.transformations = new ArrayList<ASTTransformation>();
this.transformations = new ArrayList<>();
this.transformations
.add(new DependencyManagementBomTransformation(resolutionContext));
this.transformations.add(new DependencyAutoConfigurationTransformation(
@@ -184,7 +184,7 @@ public class GroovyCompiler {
throws CompilationFailedException, IOException {
this.loader.clearCache();
List<Class<?>> classes = new ArrayList<Class<?>>();
List<Class<?>> classes = new ArrayList<>();
CompilerConfiguration configuration = this.loader.getConfiguration();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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.
@@ -59,7 +59,7 @@ public final class RepositoryConfigurationFactory {
*/
public static List<RepositoryConfiguration> createDefaultRepositoryConfiguration() {
MavenSettings mavenSettings = new MavenSettingsReader().readSettings();
List<RepositoryConfiguration> repositoryConfiguration = new ArrayList<RepositoryConfiguration>();
List<RepositoryConfiguration> repositoryConfiguration = new ArrayList<>();
repositoryConfiguration.add(MAVEN_CENTRAL);
if (!Boolean.getBoolean("disableSpringSnapshotRepos")) {
repositoryConfiguration.add(SPRING_MILESTONE);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -47,7 +47,7 @@ public class ResolveDependencyCoordinatesTransformation
public static final int ORDER = DependencyManagementBomTransformation.ORDER + 300;
private static final Set<String> GRAB_ANNOTATION_NAMES = Collections
.unmodifiableSet(new HashSet<String>(
.unmodifiableSet(new HashSet<>(
Arrays.asList(Grab.class.getName(), Grab.class.getSimpleName())));
private final DependencyResolutionContext resolutionContext;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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.
@@ -31,7 +31,7 @@ public class CompositeDependencyManagement implements DependencyManagement {
private final List<DependencyManagement> delegates;
private final List<Dependency> dependencies = new ArrayList<Dependency>();
private final List<Dependency> dependencies = new ArrayList<>();
public CompositeDependencyManagement(DependencyManagement... delegates) {
this.delegates = Arrays.asList(delegates);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2015 the original author or authors.
* Copyright 2012-2017 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 MavenModelDependencyManagement implements DependencyManagement {
private final List<Dependency> dependencies;
private final Map<String, Dependency> byArtifactId = new LinkedHashMap<String, Dependency>();
private final Map<String, Dependency> byArtifactId = new LinkedHashMap<>();
public MavenModelDependencyManagement(Model model) {
this.dependencies = extractDependenciesFromModel(model);
@@ -45,10 +45,10 @@ public class MavenModelDependencyManagement implements DependencyManagement {
}
private static List<Dependency> extractDependenciesFromModel(Model model) {
List<Dependency> dependencies = new ArrayList<Dependency>();
List<Dependency> dependencies = new ArrayList<>();
for (org.apache.maven.model.Dependency mavenDependency : model
.getDependencyManagement().getDependencies()) {
List<Exclusion> exclusions = new ArrayList<Exclusion>();
List<Exclusion> exclusions = new ArrayList<>();
for (org.apache.maven.model.Exclusion mavenExclusion : mavenDependency
.getExclusions()) {
exclusions.add(new Exclusion(mavenExclusion.getGroupId(),

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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 AetherGrapeEngine implements GrapeEngine {
private static final Collection<Exclusion> WILDCARD_EXCLUSION;
static {
List<Exclusion> exclusions = new ArrayList<Exclusion>();
List<Exclusion> exclusions = new ArrayList<>();
exclusions.add(new Exclusion("*", "*", "*", "*"));
WILDCARD_EXCLUSION = Collections.unmodifiableList(exclusions);
}
@@ -82,9 +82,8 @@ public class AetherGrapeEngine implements GrapeEngine {
this.repositorySystem = repositorySystem;
this.session = repositorySystemSession;
this.resolutionContext = resolutionContext;
this.repositories = new ArrayList<RemoteRepository>();
List<RemoteRepository> remotes = new ArrayList<RemoteRepository>(
remoteRepositories);
this.repositories = new ArrayList<>();
List<RemoteRepository> remotes = new ArrayList<>(remoteRepositories);
Collections.reverse(remotes); // priority is reversed in addRepository
for (RemoteRepository repository : remotes) {
addRepository(repository);
@@ -141,7 +140,7 @@ public class AetherGrapeEngine implements GrapeEngine {
@SuppressWarnings("unchecked")
private List<Exclusion> createExclusions(Map<?, ?> args) {
List<Exclusion> exclusions = new ArrayList<Exclusion>();
List<Exclusion> exclusions = new ArrayList<>();
if (args != null) {
List<Map<String, Object>> exclusionMaps = (List<Map<String, Object>>) args
.get("excludes");
@@ -162,7 +161,7 @@ public class AetherGrapeEngine implements GrapeEngine {
private List<Dependency> createDependencies(Map<?, ?>[] dependencyMaps,
List<Exclusion> exclusions) {
List<Dependency> dependencies = new ArrayList<Dependency>(dependencyMaps.length);
List<Dependency> dependencies = new ArrayList<>(dependencyMaps.length);
for (Map<?, ?> dependencyMap : dependencyMaps) {
dependencies.add(createDependency(dependencyMap, exclusions));
}
@@ -212,7 +211,7 @@ public class AetherGrapeEngine implements GrapeEngine {
}
private List<Dependency> getDependencies(DependencyResult dependencyResult) {
List<Dependency> dependencies = new ArrayList<Dependency>();
List<Dependency> dependencies = new ArrayList<>();
for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
dependencies.add(
new Dependency(artifactResult.getArtifact(), JavaScopes.COMPILE));
@@ -221,7 +220,7 @@ public class AetherGrapeEngine implements GrapeEngine {
}
private List<File> getFiles(DependencyResult dependencyResult) {
List<File> files = new ArrayList<File>();
List<File> files = new ArrayList<>();
for (ArtifactResult result : dependencyResult.getArtifactResults()) {
files.add(result.getArtifact().getFile());
}
@@ -297,7 +296,7 @@ public class AetherGrapeEngine implements GrapeEngine {
List<Dependency> dependencies = createDependencies(dependencyMaps, exclusions);
try {
List<File> files = resolve(dependencies);
List<URI> uris = new ArrayList<URI>(files.size());
List<URI> uris = new ArrayList<>(files.size());
for (File file : files) {
uris.add(file.toURI());
}
@@ -328,7 +327,7 @@ public class AetherGrapeEngine implements GrapeEngine {
private CollectRequest getCollectRequest(List<Dependency> dependencies) {
CollectRequest collectRequest = new CollectRequest((Dependency) null,
dependencies, new ArrayList<RemoteRepository>(this.repositories));
dependencies, new ArrayList<>(this.repositories));
collectRequest
.setManagedDependencies(this.resolutionContext.getManagedDependencies());
return collectRequest;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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 abstract class AetherGrapeEngineFactory {
private static List<RemoteRepository> createRepositories(
List<RepositoryConfiguration> repositoryConfigurations) {
List<RemoteRepository> repositories = new ArrayList<RemoteRepository>(
List<RemoteRepository> repositories = new ArrayList<>(
repositoryConfigurations.size());
for (RepositoryConfiguration repositoryConfiguration : repositoryConfigurations) {
RemoteRepository.Builder builder = new RemoteRepository.Builder(

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2014 the original author or authors.
* Copyright 2012-2017 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.
@@ -31,7 +31,7 @@ import org.eclipse.aether.repository.RemoteRepository;
*/
public class CompositeProxySelector implements ProxySelector {
private List<ProxySelector> selectors = new ArrayList<ProxySelector>();
private List<ProxySelector> selectors = new ArrayList<>();
public CompositeProxySelector(List<ProxySelector> selectors) {
this.selectors = selectors;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -40,9 +40,9 @@ import org.springframework.boot.cli.compiler.dependencies.DependencyManagementAr
*/
public class DependencyResolutionContext {
private final Map<String, Dependency> managedDependencyByGroupAndArtifact = new HashMap<String, Dependency>();
private final Map<String, Dependency> managedDependencyByGroupAndArtifact = new HashMap<>();
private final List<Dependency> managedDependencies = new ArrayList<Dependency>();
private final List<Dependency> managedDependencies = new ArrayList<>();
private DependencyManagement dependencyManagement = null;
@@ -90,7 +90,7 @@ public class DependencyResolutionContext {
public void addDependencyManagement(DependencyManagement dependencyManagement) {
for (org.springframework.boot.cli.compiler.dependencies.Dependency dependency : dependencyManagement
.getDependencies()) {
List<Exclusion> aetherExclusions = new ArrayList<Exclusion>();
List<Exclusion> aetherExclusions = new ArrayList<>();
for (org.springframework.boot.cli.compiler.dependencies.Dependency.Exclusion exclusion : dependency
.getExclusions()) {
aetherExclusions.add(new Exclusion(exclusion.getGroupId(),

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -137,7 +137,7 @@ public class MavenSettings {
if (!problemCollector.getProblems().isEmpty()) {
throw new IllegalStateException(createFailureMessage(problemCollector));
}
List<Profile> activeProfiles = new ArrayList<Profile>();
List<Profile> activeProfiles = new ArrayList<>();
Map<String, Profile> profiles = settings.getProfilesAsMap();
for (org.apache.maven.model.Profile modelProfile : activeModelProfiles) {
activeProfiles.add(profiles.get(modelProfile.getId()));
@@ -200,7 +200,7 @@ public class MavenSettings {
private List<org.apache.maven.model.Profile> createModelProfiles(
List<Profile> profiles) {
List<org.apache.maven.model.Profile> modelProfiles = new ArrayList<org.apache.maven.model.Profile>();
List<org.apache.maven.model.Profile> modelProfiles = new ArrayList<>();
for (Profile profile : profiles) {
org.apache.maven.model.Profile modelProfile = new org.apache.maven.model.Profile();
modelProfile.setId(profile.getId());
@@ -310,7 +310,7 @@ public class MavenSettings {
private static final class SpringBootCliModelProblemCollector
implements ModelProblemCollector {
private final List<ModelProblemCollectorRequest> problems = new ArrayList<ModelProblemCollectorRequest>();
private final List<ModelProblemCollectorRequest> problems = new ArrayList<>();
@Override
public void add(ModelProblemCollectorRequest req) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2016 the original author or authors.
* Copyright 2012-2017 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.
@@ -84,7 +84,7 @@ public abstract class ResourceUtils {
if (path.contains(":")) {
return getUrlsFromPrefixedWildcardPath(path, classLoader);
}
Set<String> result = new LinkedHashSet<String>();
Set<String> result = new LinkedHashSet<>();
try {
result.addAll(getUrls(FILE_URL_PREFIX + path, classLoader));
}
@@ -93,14 +93,14 @@ public abstract class ResourceUtils {
}
path = stripLeadingSlashes(path);
result.addAll(getUrls(ALL_CLASSPATH_URL_PREFIX + path, classLoader));
return new ArrayList<String>(result);
return new ArrayList<>(result);
}
private static List<String> getUrlsFromPrefixedWildcardPath(String path,
ClassLoader classLoader) throws IOException {
Resource[] resources = new PathMatchingResourcePatternResolver(
new FileSearchResourceLoader(classLoader)).getResources(path);
List<String> result = new ArrayList<String>();
List<String> result = new ArrayList<>();
for (Resource resource : resources) {
if (resource.exists()) {
if (resource.getURI().getScheme().equals("file")) {
@@ -118,7 +118,7 @@ public abstract class ResourceUtils {
private static List<String> getChildFiles(Resource resource) throws IOException {
Resource[] children = new PathMatchingResourcePatternResolver()
.getResources(resource.getURL() + "/**");
List<String> childFiles = new ArrayList<String>();
List<String> childFiles = new ArrayList<>();
for (Resource child : children) {
if (!child.getFile().isDirectory()) {
childFiles.add(absolutePath(child));