Polish lambda formatting

pull/9851/head
Phillip Webb 7 years ago
parent 7b2b8dc4a3
commit 3a01f4a6da

@ -51,7 +51,7 @@ public class AutoConfigurations extends Configurations implements Ordered {
.collect(Collectors.toCollection(ArrayList::new));
List<String> sorted = SORTER.getInPriorityOrder(names);
return sorted.stream()
.map(className -> ClassUtils.resolveClassName(className, null))
.map((className) -> ClassUtils.resolveClassName(className, null))
.collect(Collectors.toCollection(ArrayList::new));
}

@ -136,7 +136,7 @@ public class QuartzAutoConfiguration {
public SchedulerFactoryBeanCustomizer dataSourceCustomizer(
QuartzProperties properties, DataSource dataSource,
ObjectProvider<PlatformTransactionManager> transactionManager) {
return schedulerFactoryBean -> {
return (schedulerFactoryBean) -> {
if (properties.getJobStoreType() == JobStoreType.JDBC) {
schedulerFactoryBean.setDataSource(dataSource);
PlatformTransactionManager txManager = transactionManager

@ -62,7 +62,7 @@ public class WebClientAutoConfiguration {
customizers = new ArrayList<>(customizers);
AnnotationAwareOrderComparator.sort(customizers);
customizers
.forEach(customizer -> customizer.customize(this.webClientBuilder));
.forEach((customizer) -> customizer.customize(this.webClientBuilder));
}
}

@ -40,7 +40,7 @@ public class WebClientCodecCustomizer implements WebClientCustomizer {
@Override
public void customize(WebClient.Builder webClientBuilder) {
webClientBuilder
.exchangeStrategies(ExchangeStrategies.builder().codecs(codecs -> {
.exchangeStrategies(ExchangeStrategies.builder().codecs((codecs) -> {
this.codecCustomizers
.forEach((customizer) -> customizer.customize(codecs));
}).build());

@ -646,7 +646,7 @@ public class DefaultServletWebServerFactoryCustomizer
private static void customizeAccessLog(JettyServletWebServerFactory factory,
final ServerProperties.Jetty.Accesslog properties) {
factory.addServerCustomizers(server -> {
factory.addServerCustomizers((server) -> {
NCSARequestLog log = new NCSARequestLog();
if (properties.getFilename() != null) {
log.setFilename(properties.getFilename());

@ -84,7 +84,7 @@ public class WebMvcProperties {
private boolean logResolvedException = false;
/**
* Maps file extensions to media types for content negotiation, e.g. yml->text/yaml.
* Maps file extensions to media types for content negotiation, e.g. yml to text/yaml.
*/
private Map<String, MediaType> mediaTypes = new LinkedHashMap<>();

@ -66,8 +66,7 @@ public class DataSourceAutoConfigurationTests {
@Test
public void testDefaultDataSourceExists() throws Exception {
this.context
.run((loaded) -> assertThat(loaded).hasSingleBean(DataSource.class));
this.context.run((loaded) -> assertThat(loaded).hasSingleBean(DataSource.class));
}
@Test
@ -110,7 +109,7 @@ public class DataSourceAutoConfigurationTests {
@Test
public void hikariValidatesConnectionByDefault() throws Exception {
assertDataSource(HikariDataSource.class,
Collections.singletonList("org.apache.tomcat"), dataSource ->
Collections.singletonList("org.apache.tomcat"), (dataSource) ->
// Use Connection#isValid()
assertThat(dataSource.getConnectionTestQuery()).isNull());
}

@ -225,7 +225,7 @@ public class ActiveMQAutoConfigurationTests {
@Bean
public ActiveMQConnectionFactoryCustomizer activeMQConnectionFactoryCustomizer() {
return factory -> {
return (factory) -> {
factory.setBrokerURL(
"vm://localhost?useJmx=false&broker.persistent=false");
factory.setUserName("foobar");

@ -277,7 +277,7 @@ public class ArtemisAutoConfigurationTests {
"spring.artemis.embedded.serverId=93",
// Do not start a specific one
"spring.artemis.embedded.enabled=false")
.run(secondContext -> {
.run((secondContext) -> {
DestinationChecker firstChecker = new DestinationChecker(first);
firstChecker.checkQueue("Queue1", true);
DestinationChecker secondChecker = new DestinationChecker(

@ -157,7 +157,7 @@ public class MongoReactiveAutoConfigurationTests {
@Bean
public MongoClientSettingsBuilderCustomizer customizer() {
return clientSettingsBuilder -> clientSettingsBuilder
return (clientSettingsBuilder) -> clientSettingsBuilder
.applicationName("overridden-name");
}

@ -331,7 +331,7 @@ public class QuartzAutoConfigurationTests {
@Bean
public SchedulerFactoryBeanCustomizer customizer() {
return schedulerFactoryBean -> schedulerFactoryBean
return (schedulerFactoryBean) -> schedulerFactoryBean
.setTaskExecutor(yetAnotherExecutor());
}
@ -342,7 +342,7 @@ public class QuartzAutoConfigurationTests {
@Bean
public SchedulerFactoryBeanCustomizer customizer() {
return schedulerFactoryBean -> schedulerFactoryBean
return (schedulerFactoryBean) -> schedulerFactoryBean
.setSchedulerName("fooScheduler");
}

@ -139,9 +139,9 @@ class WebTestClientContextCustomizer implements ContextCustomizer {
.getBeansOfType(CodecCustomizer.class).values();
if (!CollectionUtils.isEmpty(codecCustomizers)) {
clientBuilder.exchangeStrategies(
ExchangeStrategies.builder().codecs(codecs -> {
codecCustomizers.forEach(
codecCustomizer -> codecCustomizer.customize(codecs));
ExchangeStrategies.builder().codecs((codecs) -> {
codecCustomizers.forEach((codecCustomizer) -> codecCustomizer
.customize(codecs));
}).build());
}
}

@ -51,7 +51,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp
public void runWithSystemPropertiesShouldSetAndRemoveProperties() {
String key = "test." + UUID.randomUUID().toString();
assertThat(System.getProperties().containsKey(key)).isFalse();
get().withSystemProperties(key + "=value").run(loaded -> {
get().withSystemProperties(key + "=value").run((loaded) -> {
assertThat(System.getProperties()).containsEntry(key, "value");
});
assertThat(System.getProperties().containsKey(key)).isFalse();
@ -63,7 +63,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp
String key = "test." + UUID.randomUUID().toString();
assertThat(System.getProperties().containsKey(key)).isFalse();
get().withSystemProperties(key + "=value")
.withUserConfiguration(FailingConfig.class).run(loaded -> {
.withUserConfiguration(FailingConfig.class).run((loaded) -> {
assertThat(loaded).hasFailed();
});
assertThat(System.getProperties().containsKey(key)).isFalse();
@ -76,7 +76,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp
System.setProperty(key, "value");
try {
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
get().withSystemProperties(key + "=newValue").run(loaded -> {
get().withSystemProperties(key + "=newValue").run((loaded) -> {
assertThat(System.getProperties()).containsEntry(key, "newValue");
});
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
@ -93,7 +93,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp
System.setProperty(key, "value");
try {
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
get().withSystemProperty(key, null).run(loaded -> {
get().withSystemProperty(key, null).run((loaded) -> {
assertThat(System.getProperties()).doesNotContainKey(key);
});
assertThat(System.getProperties().getProperty(key)).isEqualTo("value");
@ -106,7 +106,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp
@Test
public void runWithMultiplePropertyValuesShouldAllAllValues() throws Exception {
get().withPropertyValues("test.foo=1").withPropertyValues("test.bar=2")
.run(loaded -> {
.run((loaded) -> {
Environment environment = loaded.getEnvironment();
assertThat(environment.getProperty("test.foo")).isEqualTo("1");
assertThat(environment.getProperty("test.bar")).isEqualTo("2");
@ -117,7 +117,7 @@ public abstract class AbstractApplicationContextTesterTests<T extends AbstractAp
public void runWithPropertyValuesWhenHasExistingShouldReplaceValue()
throws Exception {
get().withPropertyValues("test.foo=1").withPropertyValues("test.foo=2")
.run(loaded -> {
.run((loaded) -> {
Environment environment = loaded.getEnvironment();
assertThat(environment.getProperty("test.foo")).isEqualTo("2");
});

@ -19,16 +19,17 @@ package org.springframework.boot.gradle.dsl;
import java.io.File;
import java.util.concurrent.Callable;
import org.gradle.api.Action;
import javax.swing.Action;
import org.gradle.api.Project;
import org.gradle.api.plugins.BasePlugin;
import org.gradle.api.plugins.JavaPlugin;
import org.gradle.api.plugins.JavaPluginConvention;
import org.gradle.api.tasks.SourceSet;
import org.gradle.api.tasks.bundling.Jar;
import org.springframework.boot.gradle.tasks.buildinfo.BuildInfo;
import org.springframework.boot.gradle.tasks.buildinfo.BuildInfoProperties;
import org.springframework.boot.loader.tools.Layouts.Jar;
/**
* Entry point to Spring Boot's Gradle DSL.
@ -78,10 +79,10 @@ public class SpringBootExtension {
BuildInfo.class);
bootBuildInfo.setGroup(BasePlugin.BUILD_GROUP);
bootBuildInfo.setDescription("Generates a META-INF/build-info.properties file.");
this.project.getPlugins().withType(JavaPlugin.class, plugin -> {
this.project.getPlugins().withType(JavaPlugin.class, (plugin) -> {
this.project.getTasks().getByName(JavaPlugin.CLASSES_TASK_NAME)
.dependsOn(bootBuildInfo);
this.project.afterEvaluate(evaluated -> {
this.project.afterEvaluate((evaluated) -> {
BuildInfoProperties properties = bootBuildInfo.getProperties();
if (properties.getArtifact() == null) {
properties.setArtifact(determineArtifactBaseName());

@ -23,7 +23,6 @@ import java.io.StringWriter;
import java.util.concurrent.Callable;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.distribution.Distribution;
import org.gradle.api.distribution.DistributionContainer;
@ -59,7 +58,7 @@ final class ApplicationPluginAction implements PluginApplicationAction {
((TemplateBasedScriptGenerator) bootStartScripts.getWindowsStartScriptGenerator())
.setTemplate(project.getResources().getText()
.fromString(loadResource("/windowsStartScript.txt")));
project.getConfigurations().all(configuration -> {
project.getConfigurations().all((configuration) -> {
if ("bootArchives".equals(configuration.getName())) {
distribution.getContents()
.with(project.copySpec().into("lib")

@ -18,8 +18,6 @@ package org.springframework.boot.gradle.plugin;
import io.spring.gradle.dependencymanagement.DependencyManagementPlugin;
import io.spring.gradle.dependencymanagement.dsl.DependencyManagementExtension;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
/**
@ -39,7 +37,7 @@ final class DependencyManagementPluginAction implements PluginApplicationAction
@Override
public void execute(Project project) {
project.getExtensions().findByType(DependencyManagementExtension.class)
.imports(importsHandler -> importsHandler.mavenBom(SPRING_BOOT_BOM));
.imports((importsHandler) -> importsHandler.mavenBom(SPRING_BOOT_BOM));
}
@Override

@ -19,8 +19,6 @@ package org.springframework.boot.gradle.plugin;
import java.util.Collections;
import java.util.concurrent.Callable;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.file.FileCollection;
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact;
@ -113,8 +111,8 @@ final class JavaPluginAction implements PluginApplicationAction {
}
private void configureUtf8Encoding(Project project) {
project.afterEvaluate(
evaluated -> evaluated.getTasks().withType(JavaCompile.class, compile -> {
project.afterEvaluate(evaluated -> evaluated.getTasks()
.withType(JavaCompile.class, (compile) -> {
if (compile.getOptions().getEncoding() == null) {
compile.getOptions().setEncoding("UTF-8");
}

@ -16,8 +16,6 @@
package org.springframework.boot.gradle.plugin;
import org.gradle.api.Action;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.maven.MavenResolver;
import org.gradle.api.plugins.MavenPlugin;
@ -43,16 +41,16 @@ final class MavenPluginAction implements PluginApplicationAction {
@Override
public void execute(Project project) {
project.getTasks().withType(Upload.class, upload -> {
project.getTasks().withType(Upload.class, (upload) -> {
if (this.uploadTaskName.equals(upload.getName())) {
project.afterEvaluate(evaluated -> clearConfigurationMappings(upload));
project.afterEvaluate((evaluated) -> clearConfigurationMappings(upload));
}
});
}
private void clearConfigurationMappings(Upload upload) {
upload.getRepositories().withType(MavenResolver.class,
resolver -> resolver.getPom().getScopeMappings().getMappings().clear());
(resolver) -> resolver.getPom().getScopeMappings().getMappings().clear());
}
}

@ -19,10 +19,9 @@ package org.springframework.boot.gradle.plugin;
import java.util.Arrays;
import java.util.List;
import net.bytebuddy.build.Plugin;
import org.gradle.api.GradleException;
import org.gradle.api.Plugin;
import org.gradle.api.Project;
import org.gradle.api.artifacts.Configuration;
import org.gradle.util.GradleVersion;
import org.springframework.boot.gradle.dsl.SpringBootExtension;
@ -96,19 +95,19 @@ public class SpringBootPlugin implements Plugin<Project> {
new DependencyManagementPluginAction(), new ApplicationPluginAction());
for (PluginApplicationAction action : actions) {
project.getPlugins().withType(action.getPluginClass(),
plugin -> action.execute(project));
(plugin) -> action.execute(project));
}
}
private void unregisterUnresolvedDependenciesAnalyzer(Project project) {
UnresolvedDependenciesAnalyzer unresolvedDependenciesAnalyzer = new UnresolvedDependenciesAnalyzer();
project.getConfigurations().all(configuration -> configuration.getIncoming()
.afterResolve(resolvableDependencies -> unresolvedDependenciesAnalyzer
project.getConfigurations().all((configuration) -> configuration.getIncoming()
.afterResolve((resolvableDependencies) -> unresolvedDependenciesAnalyzer
.analyze(configuration.getResolvedConfiguration()
.getLenientConfiguration()
.getUnresolvedModuleDependencies())));
project.getGradle().buildFinished(
buildResult -> unresolvedDependenciesAnalyzer.buildFinished(project));
(buildResult) -> unresolvedDependenciesAnalyzer.buildFinished(project));
}
}

@ -42,7 +42,7 @@ class UnresolvedDependenciesAnalyzer {
void analyze(Set<UnresolvedDependency> unresolvedDependencies) {
this.dependenciesWithNoVersion = unresolvedDependencies.stream()
.map(unresolvedDependency -> unresolvedDependency.getSelector())
.map((unresolvedDependency) -> unresolvedDependency.getSelector())
.filter(this::hasNoVersion).collect(Collectors.toSet());
}
@ -53,7 +53,7 @@ class UnresolvedDependenciesAnalyzer {
message.append("\nDuring the build, one or more dependencies that were "
+ "declared without a version failed to resolve:\n");
this.dependenciesWithNoVersion.stream()
.forEach(dependency -> message.append(" " + dependency + "\n"));
.forEach((dependency) -> message.append(" " + dependency + "\n"));
message.append("\nDid you forget to apply the "
+ "io.spring.dependency-management plugin to the " + project.getName()
+ " project?\n");

@ -23,18 +23,19 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.function.Function;
import javax.swing.text.DefaultEditorKit.CopyAction;
import io.spring.gradle.dependencymanagement.org.apache.maven.model.PatternSet;
import org.gradle.api.file.FileCopyDetails;
import org.gradle.api.file.FileTreeElement;
import org.gradle.api.file.RelativePath;
import org.gradle.api.internal.file.copy.CopyAction;
import org.gradle.api.internal.file.copy.CopyActionProcessingStream;
import org.gradle.api.internal.file.copy.FileCopyDetailsInternal;
import org.gradle.api.java.archives.Attributes;
import org.gradle.api.specs.Spec;
import org.gradle.api.specs.Specs;
import org.gradle.api.tasks.WorkResult;
import org.gradle.api.tasks.bundling.Jar;
import org.gradle.api.tasks.util.PatternSet;
import org.springframework.boot.loader.tools.Layouts.Jar;
/**
* Support class for implementations of {@link BootArchive}.
@ -138,10 +139,10 @@ class BootArchiveSupport {
@Override
public WorkResult execute(CopyActionProcessingStream stream) {
return this.delegate.execute(action -> {
return this.delegate.execute((action) -> {
Map<RelativePath, FileCopyDetailsInternal> detailsByPath = new TreeMap<>();
stream.process(
details -> detailsByPath.put(details.getRelativePath(), details));
stream.process((details) -> detailsByPath.put(details.getRelativePath(),
details));
detailsByPath.values().stream().forEach(action::processFile);
});
}

@ -20,14 +20,16 @@ import java.io.File;
import java.util.Collections;
import java.util.concurrent.Callable;
import org.gradle.api.Action;
import javax.swing.Action;
import javax.swing.text.DefaultEditorKit.CopyAction;
import org.gradle.api.file.CopySpec;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.FileCopyDetails;
import org.gradle.api.file.FileTreeElement;
import org.gradle.api.internal.file.copy.CopyAction;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.bundling.Jar;
import org.springframework.boot.loader.tools.Layouts.Jar;
/**
* A custom {@link Jar} task that produces a Spring Boot executable jar.
@ -55,7 +57,7 @@ public class BootJar extends Jar implements BootArchive {
}
private Action<CopySpec> classpathFiles(Spec<File> filter) {
return copySpec -> copySpec
return (copySpec) -> copySpec
.from((Callable<Iterable<File>>) () -> this.classpath == null
? Collections.emptyList() : this.classpath.filter(filter));

@ -20,15 +20,17 @@ import java.io.File;
import java.util.Collections;
import java.util.concurrent.Callable;
import org.gradle.api.Action;
import javax.swing.Action;
import javax.swing.text.DefaultEditorKit.CopyAction;
import org.gradle.api.Project;
import org.gradle.api.file.FileCollection;
import org.gradle.api.file.FileCopyDetails;
import org.gradle.api.file.FileTreeElement;
import org.gradle.api.internal.file.copy.CopyAction;
import org.gradle.api.specs.Spec;
import org.gradle.api.tasks.Optional;
import org.gradle.api.tasks.bundling.War;
import org.springframework.boot.loader.tools.Layouts.War;
/**
* A custom {@link War} task that produces a Spring Boot executable war.
@ -50,7 +52,7 @@ public class BootWar extends War implements BootArchive {
*/
public BootWar() {
getWebInf().into("lib-provided",
copySpec -> copySpec
(copySpec) -> copySpec
.from((Callable<Iterable<File>>) () -> this.providedClasspath == null
? Collections.emptyList() : this.providedClasspath));
}

@ -40,7 +40,7 @@ public class BootRun extends JavaExec {
public void sourceResources(SourceSet sourceSet) {
setClasspath(getProject()
.files(sourceSet.getResources().getSrcDirs(), getClasspath())
.filter(file -> !file.equals(sourceSet.getOutput().getResourcesDir())));
.filter((file) -> !file.equals(sourceSet.getOutput().getResourcesDir())));
}
@Override

@ -55,7 +55,7 @@ import org.springframework.util.Assert;
public abstract class Configurations {
private static final Comparator<Object> COMPARATOR = OrderComparator.INSTANCE
.thenComparing(o -> o.getClass().getName());
.thenComparing((other) -> other.getClass().getName());
private Set<Class<?>> classes;
@ -117,7 +117,7 @@ public abstract class Configurations {
List<Configurations> orderedConfigurations = new ArrayList<>(configurations);
orderedConfigurations.sort(COMPARATOR);
List<Configurations> collated = collate(orderedConfigurations);
return collated.stream().flatMap(c -> c.getClasses().stream())
return collated.stream().flatMap((c) -> c.getClasses().stream())
.collect(Collectors.toCollection(LinkedHashSet::new))
.toArray(new Class<?>[0]);
}

@ -109,7 +109,7 @@ public class NettyWebServer implements WebServer {
this.nettyContext.shutdown();
// temporary fix for gh-9146
this.nettyContext.getContext().onClose()
.doOnSuccess(aVoid -> HttpResources.reset()).block();
.doOnSuccess((o) -> HttpResources.reset()).block();
this.nettyContext = null;
}
}

@ -112,9 +112,10 @@ public class NoUnboundElementsBindHandlerTests {
source.put("example.other", "baz");
this.sources.add(source);
this.binder = new Binder(this.sources);
NoUnboundElementsBindHandler handler = new NoUnboundElementsBindHandler(BindHandler.DEFAULT, (configurationPropertySource -> false));
Example bound = this.binder.bind("example", Bindable.of(Example.class),
handler).get();
NoUnboundElementsBindHandler handler = new NoUnboundElementsBindHandler(
BindHandler.DEFAULT, ((configurationPropertySource) -> false));
Example bound = this.binder.bind("example", Bindable.of(Example.class), handler)
.get();
assertThat(bound.getFoo()).isEqualTo("bar");
}

@ -78,7 +78,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
Mono<String> result = getWebClient().post().uri("/test")
.contentType(MediaType.TEXT_PLAIN)
.body(BodyInserters.fromObject("Hello World")).exchange()
.flatMap(response -> response.bodyToMono(String.class));
.flatMap((response) -> response.bodyToMono(String.class));
assertThat(result.block()).isEqualTo("Hello World");
this.webServer.stop();
Mono<ClientResponse> response = getWebClient().post().uri("/test")
@ -97,7 +97,7 @@ public abstract class AbstractReactiveWebServerFactoryTests {
Mono<String> result = WebClient.create("http://localhost:" + specificPort).post()
.uri("/test").contentType(MediaType.TEXT_PLAIN)
.body(BodyInserters.fromObject("Hello World")).exchange()
.flatMap(response -> response.bodyToMono(String.class));
.flatMap((response) -> response.bodyToMono(String.class));
assertThat(result.block()).isEqualTo("Hello World");
assertThat(this.webServer.getPort()).isEqualTo(specificPort);
}

Loading…
Cancel
Save