From aeb885192e6f181f2338688a6a7fa73575f6ffcb Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Sun, 29 Jul 2018 09:16:06 +0100 Subject: [PATCH] Polish ternary expressions --- .../condition/ConditionsReportEndpoint.java | 2 +- .../autoconfigure/metrics/PropertiesMeterFilter.java | 2 +- .../endpoint/annotation/EndpointDiscoverer.java | 2 +- .../actuate/endpoint/web/ServletEndpointRegistrar.java | 2 +- .../web/jersey/JerseyEndpointResourceFactory.java | 2 +- .../boot/actuate/metrics/MetricsEndpoint.java | 2 +- .../boot/actuate/metrics/web/servlet/WebMvcTags.java | 2 +- .../boot/actuate/trace/http/HttpExchangeTracer.java | 2 +- .../boot/autoconfigure/amqp/RabbitProperties.java | 2 +- .../boot/autoconfigure/condition/ConditionMessage.java | 2 +- .../boot/autoconfigure/condition/ConditionOutcome.java | 2 +- .../autoconfigure/h2/H2ConsoleAutoConfiguration.java | 2 +- .../info/ProjectInfoAutoConfiguration.java | 2 +- .../autoconfigure/jersey/JerseyAutoConfiguration.java | 2 +- .../boot/autoconfigure/web/ResourceProperties.java | 2 +- .../autoconfigure/web/format/WebConversionService.java | 2 +- .../webservices/WebServicesAutoConfiguration.java | 4 ++-- .../boot/cli/command/CommandRunner.java | 2 +- .../cli/command/init/InitializrServiceMetadata.java | 2 +- .../boot/cli/command/shell/ShellPrompts.java | 2 +- .../boot/cli/compiler/GroovyCompiler.java | 2 +- .../java/org/springframework/boot/cli/CliTester.java | 2 +- .../devtools/tunnel/client/HttpTunnelConnection.java | 2 +- .../tunnel/client/HttpTunnelConnectionTests.java | 3 +-- .../properties/AnnotationsPropertySource.java | 2 +- .../boot/test/json/JsonContentAssert.java | 6 +++--- .../boot/configurationmetadata/JsonReader.java | 2 +- .../ConfigurationMetadataAnnotationProcessor.java | 4 ++-- .../metadata/JsonMarshaller.java | 2 +- .../boot/loader/tools/JavaExecutable.java | 2 +- .../boot/loader/PropertiesLauncher.java | 2 +- .../org/springframework/boot/loader/jar/Handler.java | 4 ++-- .../boot/loader/jar/JarURLConnection.java | 4 ++-- .../java/org/springframework/boot/ImageBanner.java | 2 +- .../java/org/springframework/boot/ResourceBanner.java | 2 +- .../boot/SpringApplicationBannerPrinter.java | 2 +- .../ContextIdApplicationContextInitializer.java | 2 +- .../context/config/ConfigFileApplicationListener.java | 2 +- .../context/logging/LoggingApplicationListener.java | 2 +- .../boot/context/properties/bind/MapBinder.java | 2 +- .../properties/source/ConfigurationPropertyName.java | 10 +++++----- .../source/FilteredConfigurationPropertiesSource.java | 2 +- .../source/SystemEnvironmentPropertyMapper.java | 2 +- .../springframework/boot/system/ApplicationHome.java | 2 +- .../ServerPortInfoApplicationContextInitializer.java | 2 +- .../boot/web/embedded/tomcat/TomcatWebServer.java | 2 +- .../web/servlet/ServletContextInitializerBeans.java | 2 +- .../server/AbstractServletWebServerFactoryTests.java | 2 +- .../src/main/java/sample/atmosphere/ChatService.java | 2 +- 49 files changed, 59 insertions(+), 60 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java index 35818c14e9..4430d4b95a 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java @@ -209,7 +209,7 @@ public class ConditionsReportEndpoint { this.message = outcome.getMessage(); } else { - this.message = (outcome.isMatch() ? "matched" : "did not match"); + this.message = outcome.isMatch() ? "matched" : "did not match"; } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java index 757fd2b7e9..fee3568ed5 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java @@ -51,7 +51,7 @@ public class PropertiesMeterFilter implements MeterFilter { @Override public MeterFilterReply accept(Meter.Id id) { boolean enabled = lookup(this.properties.getEnable(), id, true); - return (enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY); + return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY; } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java index e01b0a91bd..57aac62bc9 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java @@ -224,7 +224,7 @@ public abstract class EndpointDiscoverer, O exten } private T getLast(List list) { - return (CollectionUtils.isEmpty(list) ? null : list.get(list.size() - 1)); + return CollectionUtils.isEmpty(list) ? null : list.get(list.size() - 1); } private void assertNoDuplicateOperations(EndpointBean endpointBean, diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java index bc4daca0a3..cc660abc7a 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java @@ -61,7 +61,7 @@ public class ServletEndpointRegistrar implements ServletContextInitializer { ExposableServletEndpoint endpoint) { String name = endpoint.getId() + "-actuator-endpoint"; String path = this.basePath + "/" + endpoint.getRootPath(); - String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); + String urlMapping = path.endsWith("/") ? path + "*" : path + "/*"; EndpointServlet endpointServlet = endpoint.getEndpointServlet(); Dynamic registration = servletContext.addServlet(name, endpointServlet.getServlet()); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java index b007915524..3c6bff7df5 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java @@ -188,7 +188,7 @@ public class JerseyEndpointResourceFactory { private Response convertToJaxRsResponse(Object response, String httpMethod) { if (response == null) { boolean isGet = HttpMethod.GET.equals(httpMethod); - Status status = (isGet ? Status.NOT_FOUND : Status.NO_CONTENT); + Status status = isGet ? Status.NOT_FOUND : Status.NO_CONTENT; return Response.status(status).build(); } try { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java index a80f1ae3ea..fbe4da8f49 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/MetricsEndpoint.java @@ -132,7 +132,7 @@ public class MetricsEndpoint { } private BiFunction mergeFunction(Statistic statistic) { - return (Statistic.MAX.equals(statistic) ? Double::max : Double::sum); + return Statistic.MAX.equals(statistic) ? Double::max : Double::sum; } private Map> getAvailableTags(List meters) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java index c64c644cbd..74249012d2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java @@ -123,7 +123,7 @@ public final class WebMvcTags { private static String getPathInfo(HttpServletRequest request) { String pathInfo = request.getPathInfo(); - String uri = (StringUtils.hasText(pathInfo) ? pathInfo : "/"); + String uri = StringUtils.hasText(pathInfo) ? pathInfo : "/"; return uri.replaceAll("//+", "/").replaceAll("/$", ""); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java index afbd23672b..1873fd1e8e 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java @@ -86,7 +86,7 @@ public class HttpExchangeTracer { } private T getIfIncluded(Include include, Supplier valueSupplier) { - return (this.includes.contains(include) ? valueSupplier.get() : null); + return this.includes.contains(include) ? valueSupplier.get() : null; } private void setIfIncluded(Include include, Supplier supplier, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 9cc6d68f85..abf24b7650 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -260,7 +260,7 @@ public class RabbitProperties { } public void setVirtualHost(String virtualHost) { - this.virtualHost = ("".equals(virtualHost) ? "/" : virtualHost); + this.virtualHost = "".equals(virtualHost) ? "/" : virtualHost; } public Duration getRequestedHeartbeat() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java index c2cd484287..8fee3038ba 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java @@ -48,7 +48,7 @@ public final class ConditionMessage { } private ConditionMessage(ConditionMessage prior, String message) { - this.message = (prior.isEmpty() ? message : prior + "; " + message); + this.message = prior.isEmpty() ? message : prior + "; " + message; } /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java index 6e9b7604af..82a6fa9a01 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java @@ -111,7 +111,7 @@ public class ConditionOutcome { * @return the message or {@code null} */ public String getMessage() { - return (this.message.isEmpty() ? null : this.message.toString()); + return this.message.isEmpty() ? null : this.message.toString(); } /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java index 96f78c72a3..8bac156fbd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfiguration.java @@ -52,7 +52,7 @@ public class H2ConsoleAutoConfiguration { @Bean public ServletRegistrationBean h2Console() { String path = this.properties.getPath(); - String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); + String urlMapping = path.endsWith("/") ? path + "*" : path + "/*"; ServletRegistrationBean registration = new ServletRegistrationBean<>( new WebServlet(), urlMapping); H2ConsoleProperties.Settings settings = this.properties.getSettings(); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java index 7d88679549..8be72a8577 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java @@ -72,7 +72,7 @@ public class ProjectInfoAutoConfiguration { } protected Properties loadFrom(Resource location, String prefix) throws IOException { - String p = (prefix.endsWith(".") ? prefix : prefix + "."); + String p = prefix.endsWith(".") ? prefix : prefix + "."; Properties source = PropertiesLoaderUtils.loadProperties(location); Properties target = new Properties(); for (String key : source.stringPropertyNames()) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java index af61046450..fd8a54779f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java @@ -195,7 +195,7 @@ public class JerseyAutoConfiguration implements ServletContextAware { if (!applicationPath.startsWith("/")) { applicationPath = "/" + applicationPath; } - return (applicationPath.equals("/") ? "/*" : applicationPath + "/*"); + return applicationPath.equals("/") ? "/*" : applicationPath + "/*"; } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java index a6546d8ed2..087b6fe2d1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java @@ -69,7 +69,7 @@ public class ResourceProperties { String[] normalized = new String[staticLocations.length]; for (int i = 0; i < staticLocations.length; i++) { String location = staticLocations[i]; - normalized[i] = (location.endsWith("/") ? location : location + "/"); + normalized[i] = location.endsWith("/") ? location : location + "/"; } return normalized; } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/format/WebConversionService.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/format/WebConversionService.java index 3269ed3f4a..65da2183da 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/format/WebConversionService.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/format/WebConversionService.java @@ -61,7 +61,7 @@ public class WebConversionService extends DefaultFormattingConversionService { */ public WebConversionService(String dateFormat) { super(false); - this.dateFormat = (StringUtils.hasText(dateFormat) ? dateFormat : null); + this.dateFormat = StringUtils.hasText(dateFormat) ? dateFormat : null; if (this.dateFormat != null) { addFormatters(); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.java index eb5d5cc906..5d20b2d097 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/webservices/WebServicesAutoConfiguration.java @@ -77,7 +77,7 @@ public class WebServicesAutoConfiguration { MessageDispatcherServlet servlet = new MessageDispatcherServlet(); servlet.setApplicationContext(applicationContext); String path = this.properties.getPath(); - String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); + String urlMapping = path.endsWith("/") ? path + "*" : path + "/*"; ServletRegistrationBean registration = new ServletRegistrationBean<>( servlet, urlMapping); WebServicesProperties.Servlet servletProperties = this.properties.getServlet(); @@ -152,7 +152,7 @@ public class WebServicesAutoConfiguration { } private String ensureTrailingSlash(String path) { - return (path.endsWith("/") ? path : path + "/"); + return path.endsWith("/") ? path : path + "/"; } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java index b3693f42bf..f330e9eeaa 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java @@ -54,7 +54,7 @@ public class CommandRunner implements Iterable { * @param name the name of the runner or {@code null} */ public CommandRunner(String name) { - this.name = (StringUtils.hasLength(name) ? name + " " : ""); + this.name = StringUtils.hasLength(name) ? name + " " : ""; } /** diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java index aee43aba19..ef015ebcc9 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java @@ -212,7 +212,7 @@ class InitializrServiceMetadata { private String getStringValue(JSONObject object, String name, String defaultValue) throws JSONException { - return (object.has(name) ? object.getString(name) : defaultValue); + return object.has(name) ? object.getString(name) : defaultValue; } private Map parseStringItems(JSONObject json) throws JSONException { diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java index 19d41d429e..793e66ea03 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java @@ -54,7 +54,7 @@ public class ShellPrompts { * @return the current prompt */ public String getPrompt() { - return (this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek()); + return this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek(); } } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java index 8558bbe53a..c149bdac40 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/GroovyCompiler.java @@ -322,7 +322,7 @@ public class GroovyCompiler { return node; } } - return (classes.isEmpty() ? null : classes.get(0)); + return classes.isEmpty() ? null : classes.get(0); } } diff --git a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java index e18d5500fb..af218ce23a 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java @@ -154,7 +154,7 @@ public class CliTester implements TestRule { } } else { - sources[i] = (new File(arg).isAbsolute() ? arg : this.prefix + arg); + sources[i] = new File(arg).isAbsolute() ? arg : this.prefix + arg; } } return sources; diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java index 8d56dfa1cd..d4cbe76585 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java @@ -101,7 +101,7 @@ public class HttpTunnelConnection implements TunnelConnection { protected final ClientHttpRequest createRequest(boolean hasPayload) throws IOException { - HttpMethod method = (hasPayload ? HttpMethod.POST : HttpMethod.GET); + HttpMethod method = hasPayload ? HttpMethod.POST : HttpMethod.GET; return this.requestFactory.createRequest(this.uri, method); } diff --git a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java index 8fc588ca30..a2fe159a2a 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java @@ -161,8 +161,7 @@ public class HttpTunnelConnectionTests { private TunnelChannel openTunnel(boolean singleThreaded) throws Exception { HttpTunnelConnection connection = new HttpTunnelConnection(this.url, - this.requestFactory, - (singleThreaded ? new CurrentThreadExecutor() : null)); + this.requestFactory, singleThreaded ? new CurrentThreadExecutor() : null); return connection.open(this.incomingChannel, this.closeable); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java index 6cfaa96377..40a04d0c86 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java @@ -164,7 +164,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource private String dotAppend(String prefix, String postfix) { if (StringUtils.hasText(prefix)) { - return (prefix.endsWith(".") ? prefix + postfix : prefix + "." + postfix); + return prefix.endsWith(".") ? prefix + postfix : prefix + "." + postfix; } return postfix; } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java index cee123ebb5..166e2765bf 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java @@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert "Unable to find java in " + javaHome); return command; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 66bde9b39f..1d9c62933e 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -304,7 +304,7 @@ public class PropertiesLauncher extends Launcher { for (String path : commaSeparatedPaths.split(",")) { path = cleanupPath(path); // "" means the user wants root of archive but not current directory - path = ("".equals(path) ? "/" : path); + path = "".equals(path) ? "/" : path; paths.add(path); } if (paths.isEmpty()) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java index 39cf82d6e6..2f4bf9155e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java @@ -124,8 +124,8 @@ public class Handler extends URLStreamHandler { private void log(boolean warning, String message, Exception cause) { try { - Logger.getLogger(getClass().getName()) - .log((warning ? Level.WARNING : Level.FINEST), message, cause); + Level level = warning ? Level.WARNING : Level.FINEST; + Logger.getLogger(getClass().getName()).log(level, message, cause); } catch (Exception ex) { if (warning) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 343a90523c..db34f47c0e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -214,7 +214,7 @@ final class JarURLConnection extends java.net.JarURLConnection { @Override public Object getContent() throws IOException { connect(); - return (this.jarEntryName.isEmpty() ? this.jarFile : super.getContent()); + return this.jarEntryName.isEmpty() ? this.jarFile : super.getContent(); } @Override @@ -386,7 +386,7 @@ final class JarURLConnection extends java.net.JarURLConnection { private String deduceContentType() { // Guess the content type, don't bother with streams as mark is not supported - String type = (isEmpty() ? "x-java/jar" : null); + String type = isEmpty() ? "x-java/jar" : null; type = (type != null) ? type : guessContentTypeFromName(toString()); type = (type != null) ? type : "content/unknown"; return type; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java index 76f64f532e..640af1c434 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java @@ -200,7 +200,7 @@ public class ImageBanner implements Banner { private void printBanner(BufferedImage image, int margin, boolean invert, PrintStream out) { - AnsiElement background = (invert ? AnsiBackground.BLACK : AnsiBackground.DEFAULT); + AnsiElement background = invert ? AnsiBackground.BLACK : AnsiBackground.DEFAULT; out.print(AnsiOutput.encode(AnsiColor.DEFAULT)); out.print(AnsiOutput.encode(background)); out.println(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java index 77b0b64dab..a719d0914c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java @@ -119,7 +119,7 @@ public class ResourceBanner implements Banner { if (version == null) { return ""; } - return (format ? " (v" + version + ")" : version); + return format ? " (v" + version + ")" : version; } private PropertyResolver getAnsiResolver() { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java index 46c0af194f..828a9d85f9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java @@ -99,7 +99,7 @@ class SpringApplicationBannerPrinter { String location = environment.getProperty(BANNER_IMAGE_LOCATION_PROPERTY); if (StringUtils.hasLength(location)) { Resource resource = this.resourceLoader.getResource(location); - return (resource.exists() ? new ImageBanner(resource) : null); + return resource.exists() ? new ImageBanner(resource) : null; } for (String ext : IMAGE_EXTENSION) { Resource resource = this.resourceLoader.getResource("banner." + ext); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ContextIdApplicationContextInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ContextIdApplicationContextInitializer.java index fc73b68688..be1b8ce4c3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ContextIdApplicationContextInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ContextIdApplicationContextInitializer.java @@ -66,7 +66,7 @@ public class ContextIdApplicationContextInitializer implements private String getApplicationId(ConfigurableEnvironment environment) { String name = environment.getProperty("spring.application.name"); - return (StringUtils.hasText(name) ? name : "application"); + return StringUtils.hasText(name) ? name : "application"; } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index 1ecda01dd5..db673909cd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -445,7 +445,7 @@ public class ConfigFileApplicationListener DocumentConsumer consumer) { getSearchLocations().forEach((location) -> { boolean isFolder = location.endsWith("/"); - Set names = (isFolder ? getSearchNames() : NO_SEARCH_NAMES); + Set names = isFolder ? getSearchNames() : NO_SEARCH_NAMES; names.forEach( (name) -> load(location, name, profile, filterFactory, consumer)); }); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java index 15d512e663..4e59f2c788 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/logging/LoggingApplicationListener.java @@ -310,7 +310,7 @@ public class LoggingApplicationListener implements GenericApplicationListener { private void setLogLevel(LoggingSystem system, String name, String level) { try { - name = (name.equalsIgnoreCase(LoggingSystem.ROOT_LOGGER_NAME) ? null : name); + name = name.equalsIgnoreCase(LoggingSystem.ROOT_LOGGER_NAME) ? null : name; system.setLogLevel(name, coerceLogLevel(level)); } catch (RuntimeException ex) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java index 807a9b4b14..47e788c44c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java @@ -71,7 +71,7 @@ class MapBinder extends AggregateBinder> { } new EntryBinder(name, resolvedTarget, elementBinder).bindEntries(source, map); } - return (map.isEmpty() ? null : map); + return map.isEmpty() ? null : map; } private Bindable resolveTarget(Bindable target) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index 34326b6769..7624797a90 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -319,17 +319,17 @@ public final class ConfigurationPropertyName int l1 = e1.length(); int l2 = e2.length(); boolean indexed1 = isIndexed(e1); - int offset1 = (indexed1 ? 1 : 0); + int offset1 = indexed1 ? 1 : 0; boolean indexed2 = isIndexed(e2); - int offset2 = (indexed2 ? 1 : 0); + int offset2 = indexed2 ? 1 : 0; int i1 = offset1; int i2 = offset2; while (i1 < l1 - offset1) { if (i2 >= l2 - offset2) { return false; } - char ch1 = (indexed1 ? e1.charAt(i1) : Character.toLowerCase(e1.charAt(i1))); - char ch2 = (indexed2 ? e2.charAt(i2) : Character.toLowerCase(e2.charAt(i2))); + char ch1 = indexed1 ? e1.charAt(i1) : Character.toLowerCase(e1.charAt(i1)); + char ch2 = indexed2 ? e2.charAt(i2) : Character.toLowerCase(e2.charAt(i2)); if (ch1 == '-' || ch1 == '_') { i1++; } @@ -372,7 +372,7 @@ public final class ConfigurationPropertyName private int getElementHashCode(CharSequence element) { int hash = 0; boolean indexed = isIndexed(element); - int offset = (indexed ? 1 : 0); + int offset = indexed ? 1 : 0; for (int i = 0 + offset; i < element.length() - offset; i++) { char ch = (indexed ? element.charAt(i) : Character.toLowerCase(element.charAt(i))); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSource.java index 33c73538cf..3d3e3ad009 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/FilteredConfigurationPropertiesSource.java @@ -44,7 +44,7 @@ class FilteredConfigurationPropertiesSource implements ConfigurationPropertySour public ConfigurationProperty getConfigurationProperty( ConfigurationPropertyName name) { boolean filtered = getFilter().test(name); - return (filtered ? getSource().getConfigurationProperty(name) : null); + return filtered ? getSource().getConfigurationProperty(name) : null; } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java index 85ea9b75ff..c851aff760 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SystemEnvironmentPropertyMapper.java @@ -100,7 +100,7 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper { private CharSequence processElementValue(CharSequence value) { String result = value.toString().toLowerCase(Locale.ENGLISH); - return (isNumber(result) ? "[" + result + "]" : result); + return isNumber(result) ? "[" + result + "]" : result; } private static boolean isNumber(String string) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java index 95848c3813..f2cf5bc1f4 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java @@ -140,7 +140,7 @@ public class ApplicationHome { if (homeDir.isFile()) { homeDir = homeDir.getParentFile(); } - homeDir = (homeDir.exists() ? homeDir : new File(".")); + homeDir = homeDir.exists() ? homeDir : new File("."); return homeDir.getAbsoluteFile(); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java index d139f9feb6..94d6bf7cf3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/context/ServerPortInfoApplicationContextInitializer.java @@ -67,7 +67,7 @@ public class ServerPortInfoApplicationContextInitializer private String getName(WebServerApplicationContext context) { String name = context.getServerNamespace(); - return (StringUtils.hasText(name) ? name : "server"); + return StringUtils.hasText(name) ? name : "server"; } private void setPortProperty(ApplicationContext context, String propertyName, diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java index c95ab77010..5ad0344a4c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java @@ -320,7 +320,7 @@ public class TomcatWebServer implements WebServer { StringBuilder ports = new StringBuilder(); for (Connector connector : this.tomcat.getService().findConnectors()) { ports.append((ports.length() != 0) ? " " : ""); - int port = (localPort ? connector.getLocalPort() : connector.getPort()); + int port = localPort ? connector.getLocalPort() : connector.getPort(); ports.append(port + " (" + connector.getScheme() + ")"); } return ports.toString(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java index 559dc9baa6..a753e0859d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java @@ -169,7 +169,7 @@ public class ServletContextInitializerBeans private MultipartConfigElement getMultipartConfig(ListableBeanFactory beanFactory) { List> beans = getOrderedBeansOfType( beanFactory, MultipartConfigElement.class); - return (beans.isEmpty() ? null : beans.get(0).getValue()); + return beans.isEmpty() ? null : beans.get(0).getValue(); } private void addAsRegistrationBean(ListableBeanFactory beanFactory, Class type, diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java index 9d0ee14e84..ee07ede7c0 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java @@ -712,7 +712,7 @@ public abstract class AbstractServletWebServerFactoryTests { } private String getStoreType(String keyStore) { - return (keyStore.endsWith(".p12") ? "pkcs12" : null); + return keyStore.endsWith(".p12") ? "pkcs12" : null; } @Test diff --git a/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/ChatService.java b/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/ChatService.java index 769951ae72..145bf753d2 100644 --- a/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/ChatService.java +++ b/spring-boot-samples/spring-boot-sample-atmosphere/src/main/java/sample/atmosphere/ChatService.java @@ -42,7 +42,7 @@ public class ChatService { @Disconnect public void onDisconnect(AtmosphereResourceEvent event) { this.logger.info("Client {} disconnected [{}]", event.getResource().uuid(), - (event.isCancelled() ? "cancelled" : "closed")); + event.isCancelled() ? "cancelled" : "closed"); } @org.atmosphere.config.service.Message(encoders = JacksonEncoderDecoder.class, decoders = JacksonEncoderDecoder.class)