From 3ee777e1426ac308c74814a9eaf846377d3ccfba Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Wed, 2 May 2018 12:41:51 -0700 Subject: [PATCH] Polish ternary expressions Consistently format ternary expressions and always favor `!=` as the the check. --- .../EndpointAutoConfiguration.java | 20 +++++++++---------- ...ermediaManagementContextConfiguration.java | 6 +++--- ...tWebMvcManagementContextConfiguration.java | 5 ++--- .../HealthIndicatorAutoConfiguration.java | 2 +- .../actuate/autoconfigure/LinksEnhancer.java | 2 +- ...ntContextConfigurationsImportSelector.java | 6 +++--- .../MetricExportAutoConfiguration.java | 4 ++-- .../PublicMetricsAutoConfiguration.java | 7 ++++--- .../AbstractJmxCacheStatisticsProvider.java | 2 +- ...CloudFoundryActuatorAutoConfiguration.java | 4 ++-- .../AutoConfigurationReportEndpoint.java | 4 ++-- .../boot/actuate/endpoint/FlywayEndpoint.java | 2 +- .../actuate/endpoint/LoggersEndpoint.java | 4 ++-- .../actuate/endpoint/jmx/DataConverter.java | 2 +- .../endpoint/jmx/EndpointMBeanExporter.java | 2 +- .../mvc/AbstractEndpointHandlerMapping.java | 6 +++--- .../endpoint/mvc/LoggersMvcEndpoint.java | 6 +++--- .../health/OrderedHealthAggregator.java | 2 +- .../actuate/health/SolrHealthIndicator.java | 4 ++-- .../metrics/buffer/BufferMetricReader.java | 2 +- .../dropwizard/DropwizardMetricServices.java | 4 ++-- .../metrics/statsd/StatsdMetricWriter.java | 2 +- .../writer/MetricWriterMessageHandler.java | 2 +- .../actuate/trace/WebRequestTraceFilter.java | 8 ++++---- .../EndpointMvcIntegrationTests.java | 4 ++-- ...gurationPropertiesReportEndpointTests.java | 2 +- ...erMvcEndpointDisabledIntegrationTests.java | 2 +- ...ManagementContextPathIntegrationTests.java | 4 ++-- .../buffer/BufferGaugeServiceSpeedTests.java | 4 ++-- .../buffer/CounterServiceSpeedTests.java | 4 ++-- .../DefaultCounterServiceSpeedTests.java | 4 ++-- .../buffer/DefaultGaugeServiceSpeedTests.java | 4 ++-- .../DropwizardCounterServiceSpeedTests.java | 4 ++-- .../AutoConfigurationImportSelector.java | 4 ++-- .../AutoConfigurationSorter.java | 6 +++--- ...ImportAutoConfigurationImportSelector.java | 4 ++-- .../autoconfigure/amqp/RabbitProperties.java | 6 +++--- .../cache/CacheAutoConfiguration.java | 2 +- .../condition/BeanTypeRegistry.java | 4 ++-- .../condition/ConditionMessage.java | 6 +++--- .../condition/ConditionOutcome.java | 2 +- .../condition/OnExpressionCondition.java | 8 ++++---- .../condition/OnJavaCondition.java | 2 +- .../condition/OnResourceCondition.java | 4 ++-- .../data/redis/RedisAutoConfiguration.java | 4 ++-- .../NoSuchBeanDefinitionFailureAnalyzer.java | 8 ++++---- .../flyway/FlywayProperties.java | 2 +- .../info/ProjectInfoAutoConfiguration.java | 2 +- .../jdbc/DataSourceAutoConfiguration.java | 2 +- .../DataSourcePoolMetadataProviders.java | 6 +++--- .../TomcatDataSourcePoolMetadata.java | 2 +- .../jersey/JerseyAutoConfiguration.java | 2 +- .../autoconfigure/mongo/MongoProperties.java | 10 +++++----- .../EmbeddedMongoAutoConfiguration.java | 4 ++-- .../SpringBootWebSecurityConfiguration.java | 2 +- .../DefaultUserInfoRestTemplateFactory.java | 2 +- .../resource/UserInfoTokenServices.java | 2 +- .../social/FacebookAutoConfiguration.java | 2 +- .../social/LinkedInAutoConfiguration.java | 2 +- .../TemplateAvailabilityProviders.java | 6 +++--- .../TransactionManagerCustomizers.java | 5 +++-- .../web/BasicErrorController.java | 2 +- .../web/ErrorMvcAutoConfiguration.java | 4 ++-- .../web/HttpEncodingProperties.java | 2 +- ...ttpMessageConvertersAutoConfiguration.java | 4 ++-- .../autoconfigure/web/ServerProperties.java | 2 +- .../web/WebMvcAutoConfiguration.java | 4 ++-- ...stJpaDependencyAutoConfigurationTests.java | 4 ++-- ...gApplicationWebApplicationInitializer.java | 2 +- .../boot/cli/command/CommandRunner.java | 6 +++--- .../cli/command/archive/ArchiveCommand.java | 2 +- .../boot/cli/command/core/HelpCommand.java | 2 +- .../boot/cli/command/core/HintCommand.java | 2 +- .../init/InitializrServiceMetadata.java | 6 +++--- .../init/ProjectGenerationRequest.java | 2 +- .../cli/command/options/OptionHandler.java | 2 +- .../cli/command/shell/CommandCompleter.java | 4 ++-- .../boot/cli/command/shell/Shell.java | 2 +- .../boot/cli/command/shell/ShellPrompts.java | 2 +- .../compiler/ExtendedGroovyClassLoader.java | 2 +- ...ManagementArtifactCoordinatesResolver.java | 6 +++--- .../cli/compiler/grape/AetherGrapeEngine.java | 4 ++-- ...ositorySystemSessionAutoConfiguration.java | 5 +++-- .../grape/DependencyResolutionContext.java | 9 +++++---- .../init/AbstractHttpClientMockTests.java | 6 +++--- .../RemoteDevToolsAutoConfiguration.java | 12 +++++------ .../DevToolsHomePropertiesPostProcessor.java | 2 +- .../client/ClassPathChangeUploader.java | 10 +++++----- .../restart/classloader/ClassLoaderFile.java | 4 ++-- .../tunnel/client/HttpTunnelConnection.java | 4 ++-- .../client/ClassPathChangeUploaderTests.java | 2 +- .../spock/SpockTestRestTemplateExample.java | 4 ++-- .../embedded/AbstractApplicationLauncher.java | 5 +++-- .../embedded/BootRunApplicationLauncher.java | 8 ++++---- .../embedded/ExplodedApplicationLauncher.java | 4 ++-- .../embedded/IdeApplicationLauncher.java | 8 ++++---- .../sample/data/jpa/domain/HotelSummary.java | 2 +- .../hibernate4/domain/HotelSummary.java | 2 +- .../hibernate52/domain/HotelSummary.java | 2 +- .../properties/AnnotationsPropertySource.java | 8 ++++---- .../PropertyMappingContextCustomizer.java | 4 ++-- .../context/ImportsContextCustomizer.java | 8 ++++---- .../SpringBootConfigurationFinder.java | 2 +- .../test/context/SpringBootContextLoader.java | 9 +++++---- .../SpringBootTestContextBootstrapper.java | 10 +++++----- .../boot/test/json/JsonContent.java | 2 +- .../boot/test/json/JsonContentAssert.java | 8 ++++---- .../boot/test/json/JsonLoader.java | 2 +- .../boot/test/json/ObjectContent.java | 2 +- .../boot/test/util/EnvironmentTestUtils.java | 2 +- .../AbstractConfigurationMetadataTests.java | 2 +- ...figurationMetadataAnnotationProcessor.java | 2 +- .../TypeElementMembers.java | 4 ++-- .../configurationprocessor/TypeUtils.java | 4 ++-- .../fieldvalues/javac/Trees.java | 2 +- .../fieldvalues/javac/VariableTree.java | 2 +- .../metadata/ConfigurationMetadata.java | 2 +- .../metadata/ItemDeprecation.java | 2 +- .../metadata/ItemMetadata.java | 6 +++--- .../gradle/SpringBootPluginExtension.java | 2 +- .../gradle/repackage/ProjectLibraries.java | 8 ++++---- .../boot/gradle/repackage/RepackageTask.java | 16 +++++++-------- .../boot/gradle/run/BootRunTask.java | 4 ++-- .../loader/tools/DefaultLaunchScript.java | 2 +- .../boot/loader/tools/JarWriter.java | 6 +++--- .../boot/loader/tools/Library.java | 2 +- .../boot/loader/tools/MainClassFinder.java | 4 ++-- .../springframework/boot/loader/Launcher.java | 4 ++-- .../boot/loader/MainMethodRunner.java | 2 +- .../boot/loader/PropertiesLauncher.java | 5 +++-- .../data/ByteArrayRandomAccessData.java | 4 ++-- .../loader/data/RandomAccessDataFile.java | 4 ++-- .../jar/CentralDirectoryFileHeader.java | 2 +- .../boot/loader/jar/Handler.java | 4 ++-- .../boot/loader/jar/JarEntry.java | 2 +- .../boot/loader/jar/JarFile.java | 4 ++-- .../boot/loader/jar/JarFileEntries.java | 2 +- .../boot/loader/jar/JarURLConnection.java | 6 +++--- .../boot/loader/util/SystemPropertyUtils.java | 6 +++--- .../loader/archive/ExplodedArchiveTests.java | 4 ++-- .../boot/maven/AbstractRunMojo.java | 6 +++--- .../PropertiesMergingResourceTransformer.java | 2 +- .../boot/maven/RepackageMojo.java | 4 ++-- .../springframework/boot/maven/Verify.java | 2 +- .../classpath/ModifiedClassPathRunner.java | 12 +++++------ .../springframework/boot/ApplicationHome.java | 14 ++++++------- .../springframework/boot/ApplicationPid.java | 2 +- .../boot/DefaultApplicationArguments.java | 2 +- .../boot/ExitCodeGenerators.java | 2 +- .../springframework/boot/ResourceBanner.java | 10 +++++----- .../boot/SpringApplication.java | 6 +++--- .../boot/SpringApplicationBannerPrinter.java | 2 +- .../boot/SpringApplicationRunListeners.java | 2 +- .../boot/SpringBootBanner.java | 2 +- .../boot/StartupInfoLogger.java | 4 ++-- .../springframework/boot/ansi/AnsiColors.java | 2 +- .../boot/bind/OriginCapablePropertyValue.java | 6 +++--- .../PatternPropertyNamePatternsMatcher.java | 4 ++-- .../boot/bind/PropertySourceUtils.java | 2 +- .../boot/bind/RelaxedDataBinder.java | 4 ++-- .../boot/bind/RelaxedNames.java | 14 ++++++------- .../boot/bind/RelaxedPropertyResolver.java | 2 +- .../bind/YamlJavaBeanPropertyConstructor.java | 4 ++-- .../builder/SpringApplicationBuilder.java | 4 ++-- ...udFoundryVcapEnvironmentPostProcessor.java | 2 +- .../config/ConfigFileApplicationListener.java | 8 ++++---- ...stractEmbeddedServletContainerFactory.java | 8 ++++---- .../boot/context/embedded/MimeMappings.java | 6 +++--- .../jetty/JettyEmbeddedServletContainer.java | 2 +- .../JettyEmbeddedServletContainerFactory.java | 2 +- .../tomcat/SkipPatternJarScanner.java | 2 +- .../TomcatEmbeddedServletContainer.java | 2 +- .../TomcatEmbeddedWebappClassLoader.java | 8 ++++---- .../UndertowEmbeddedServletContainer.java | 4 ++-- ...dertowEmbeddedServletContainerFactory.java | 12 +++++------ .../ConfigurationBeanFactoryMetaData.java | 2 +- ...urationPropertiesBindingPostProcessor.java | 4 ++-- ...ConfigurationPropertiesImportSelector.java | 4 ++-- .../boot/diagnostics/FailureAnalyzers.java | 2 +- ...eanCurrentlyInCreationFailureAnalyzer.java | 4 ++-- .../boot/env/PropertySourcesLoader.java | 2 +- ...plicationJsonEnvironmentPostProcessor.java | 2 +- ...ikosDependsOnBeanFactoryPostProcessor.java | 2 +- .../boot/logging/java/SimpleFormatter.java | 2 +- .../boot/logging/log4j2/ColorConverter.java | 4 ++-- .../boot/logging/logback/ColorConverter.java | 2 +- .../logback/LevelRemappingAppender.java | 4 ++-- .../boot/system/ApplicationPidFileWriter.java | 2 +- .../boot/web/client/RestTemplateBuilder.java | 4 ++-- .../boot/web/servlet/ErrorPage.java | 4 ++-- .../ServletContextInitializerBeans.java | 2 +- .../boot/web/support/ErrorPageFilter.java | 2 +- .../yaml/SpringProfileDocumentMatcher.java | 11 +++++----- .../boot/SpringApplicationTests.java | 2 +- .../ConfigFileApplicationListenerTests.java | 2 +- .../MockEmbeddedServletContainerFactory.java | 10 +++++----- ...yEmbeddedServletContainerFactoryTests.java | 2 +- ...tEmbeddedServletContainerFactoryTests.java | 2 +- ...wEmbeddedServletContainerFactoryTests.java | 2 +- 199 files changed, 419 insertions(+), 412 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java index 2e7b0e4ebab..8c9170b314a 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfiguration.java @@ -114,12 +114,12 @@ public class EndpointAutoConfiguration { @Bean @ConditionalOnMissingBean public HealthEndpoint healthEndpoint() { - return new HealthEndpoint( - this.healthAggregator == null ? new OrderedHealthAggregator() - : this.healthAggregator, - this.healthIndicators == null - ? Collections.emptyMap() - : this.healthIndicators); + HealthAggregator healthAggregator = (this.healthAggregator != null + ? this.healthAggregator : new OrderedHealthAggregator()); + Map healthIndicators = (this.healthIndicators != null + ? this.healthIndicators + : Collections.emptyMap()); + return new HealthEndpoint(healthAggregator, healthIndicators); } @Bean @@ -131,8 +131,8 @@ public class EndpointAutoConfiguration { @Bean @ConditionalOnMissingBean public InfoEndpoint infoEndpoint() throws Exception { - return new InfoEndpoint(this.infoContributors == null - ? Collections.emptyList() : this.infoContributors); + return new InfoEndpoint(this.infoContributors != null ? this.infoContributors + : Collections.emptyList()); } @Bean @@ -156,8 +156,8 @@ public class EndpointAutoConfiguration { @Bean @ConditionalOnMissingBean public TraceEndpoint traceEndpoint() { - return new TraceEndpoint(this.traceRepository == null - ? new InMemoryTraceRepository() : this.traceRepository); + return new TraceEndpoint(this.traceRepository != null ? this.traceRepository + : new InMemoryTraceRepository()); } @Bean diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java index 0f6761368df..6b701a6d7da 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcHypermediaManagementContextConfiguration.java @@ -340,7 +340,7 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration { private String getPath(ServletServerHttpRequest request) { String path = (String) request.getServletRequest() .getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE); - return (path == null ? "" : path); + return (path != null ? path : ""); } } @@ -355,8 +355,8 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration { @SuppressWarnings("unchecked") EndpointResource(Object content, String path) { - this.content = content instanceof Map ? null : content; - this.embedded = (Map) (this.content == null ? content : null); + this.content = (content instanceof Map ? null : content); + this.embedded = (Map) (this.content != null ? null : content); add(linkTo(Object.class).slash(path).withSelfRel()); } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.java index 978ea185c2f..59e19272e77 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcManagementContextConfiguration.java @@ -89,9 +89,8 @@ public class EndpointWebMvcManagementContextConfiguration { this.corsProperties = corsProperties; List providedCustomizers = mappingCustomizers .getIfAvailable(); - this.mappingCustomizers = providedCustomizers == null - ? Collections.emptyList() - : providedCustomizers; + this.mappingCustomizers = (providedCustomizers != null ? providedCustomizers + : Collections.emptyList()); } @Bean diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java index 102269c3112..b205bf9aaf4 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/HealthIndicatorAutoConfiguration.java @@ -231,7 +231,7 @@ public class HealthIndicatorAutoConfiguration { private String getValidationQuery(DataSource source) { DataSourcePoolMetadata poolMetadata = this.poolMetadataProvider .getDataSourcePoolMetadata(source); - return (poolMetadata == null ? null : poolMetadata.getValidationQuery()); + return (poolMetadata != null ? poolMetadata.getValidationQuery() : null); } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/LinksEnhancer.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/LinksEnhancer.java index f0429137ee1..78c4125ab14 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/LinksEnhancer.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/LinksEnhancer.java @@ -74,7 +74,7 @@ class LinksEnhancer { private void addEndpointLink(ResourceSupport resource, MvcEndpoint endpoint, String rel) { Class type = endpoint.getEndpointType(); - type = (type == null ? Object.class : type); + type = (type != null ? type : Object.class); if (StringUtils.hasText(rel)) { String href = this.rootPath + endpoint.getPath(); resource.add(linkTo(type).slash(href).withRel(rel)); diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementContextConfigurationsImportSelector.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementContextConfigurationsImportSelector.java index 5ecb99599b5..6a648767a14 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementContextConfigurationsImportSelector.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/ManagementContextConfigurationsImportSelector.java @@ -111,9 +111,9 @@ class ManagementContextConfigurationsImportSelector private int readOrder(AnnotationMetadata annotationMetadata) { Map attributes = annotationMetadata .getAnnotationAttributes(Order.class.getName()); - Integer order = (attributes == null ? null - : (Integer) attributes.get("value")); - return (order == null ? Ordered.LOWEST_PRECEDENCE : order); + Integer order = (attributes != null ? (Integer) attributes.get("value") + : null); + return (order != null ? order : Ordered.LOWEST_PRECEDENCE); } public String getClassName() { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricExportAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricExportAutoConfiguration.java index 0a11bfca7b6..94b0f089fca 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricExportAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/MetricExportAutoConfiguration.java @@ -95,8 +95,8 @@ public class MetricExportAutoConfiguration { exporters.setReader(reader); exporters.setWriters(writers); } - exporters.setExporters(this.exporters == null - ? Collections.emptyMap() : this.exporters); + exporters.setExporters(this.exporters != null ? this.exporters + : Collections.emptyMap()); return exporters; } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java index 48a6fdb1e06..89129886c34 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/PublicMetricsAutoConfiguration.java @@ -89,9 +89,10 @@ public class PublicMetricsAutoConfiguration { @Bean public MetricReaderPublicMetrics metricReaderPublicMetrics() { - return new MetricReaderPublicMetrics(new CompositeMetricReader( - this.metricReaders == null ? new MetricReader[0] : this.metricReaders - .toArray(new MetricReader[this.metricReaders.size()]))); + MetricReader[] readers = (this.metricReaders != null + ? this.metricReaders.toArray(new MetricReader[this.metricReaders.size()]) + : new MetricReader[0]); + return new MetricReaderPublicMetrics(new CompositeMetricReader(readers)); } @Bean diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/AbstractJmxCacheStatisticsProvider.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/AbstractJmxCacheStatisticsProvider.java index e62b66e128e..be6b9b3bcaf 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/AbstractJmxCacheStatisticsProvider.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/AbstractJmxCacheStatisticsProvider.java @@ -56,7 +56,7 @@ public abstract class AbstractJmxCacheStatisticsProvider public CacheStatistics getCacheStatistics(CacheManager cacheManager, C cache) { try { ObjectName objectName = internalGetObjectName(cache); - return (objectName == null ? null : getCacheStatistics(objectName)); + return (objectName != null ? getCacheStatistics(objectName) : null); } catch (MalformedObjectNameException ex) { throw new IllegalStateException(ex); diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryActuatorAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryActuatorAutoConfiguration.java index 5ca3e309b2c..e4e9142c368 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryActuatorAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cloudfoundry/CloudFoundryActuatorAutoConfiguration.java @@ -89,8 +89,8 @@ public class CloudFoundryActuatorAutoConfiguration { String cloudControllerUrl = environment.getProperty("vcap.application.cf_api"); boolean skipSslValidation = cloudFoundryProperties .getProperty("skip-ssl-validation", Boolean.class, false); - return cloudControllerUrl == null ? null : new CloudFoundrySecurityService( - restTemplateBuilder, cloudControllerUrl, skipSslValidation); + return (cloudControllerUrl != null ? new CloudFoundrySecurityService( + restTemplateBuilder, cloudControllerUrl, skipSslValidation) : null); } private CorsConfiguration getCorsConfiguration() { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java index 02af56b5bb8..5407cc74599 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AutoConfigurationReportEndpoint.java @@ -137,8 +137,8 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint { public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) { for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) { - List target = conditionAndOutcome.getOutcome() - .isMatch() ? this.matched : this.notMatched; + List target = (conditionAndOutcome.getOutcome() + .isMatch() ? this.matched : this.notMatched); target.add(new MessageAndCondition(conditionAndOutcome)); } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/FlywayEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/FlywayEndpoint.java index 8113081560e..a213b9ba886 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/FlywayEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/FlywayEndpoint.java @@ -123,7 +123,7 @@ public class FlywayEndpoint extends AbstractEndpoint> { } private String nullSafeToString(Object obj) { - return (obj == null ? null : obj.toString()); + return (obj != null ? obj.toString() : null); } public MigrationType getType() { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LoggersEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LoggersEndpoint.java index db730d11a7e..54a20a747d6 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LoggersEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/LoggersEndpoint.java @@ -84,7 +84,7 @@ public class LoggersEndpoint extends AbstractEndpoint> { Assert.notNull(name, "Name must not be null"); LoggerConfiguration configuration = this.loggingSystem .getLoggerConfiguration(name); - return (configuration == null ? null : new LoggerLevels(configuration)); + return (configuration != null ? new LoggerLevels(configuration) : null); } public void setLogLevel(String name, LogLevel level) { @@ -107,7 +107,7 @@ public class LoggersEndpoint extends AbstractEndpoint> { } private String getName(LogLevel level) { - return (level == null ? null : level.name()); + return (level != null ? level.name() : null); } public String getConfiguredLevel() { diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataConverter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataConverter.java index 0c519cc5b2c..456194a8750 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataConverter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/DataConverter.java @@ -38,7 +38,7 @@ class DataConverter { private final JavaType mapStringObject; DataConverter(ObjectMapper objectMapper) { - this.objectMapper = (objectMapper == null ? new ObjectMapper() : objectMapper); + this.objectMapper = (objectMapper != null ? objectMapper : new ObjectMapper()); this.listObject = this.objectMapper.getTypeFactory() .constructParametricType(List.class, Object.class); this.mapStringObject = this.objectMapper.getTypeFactory() diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java index fc0551a0190..4e1f237b884 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/EndpointMBeanExporter.java @@ -115,7 +115,7 @@ public class EndpointMBeanExporter extends MBeanExporter * @param objectMapper the object mapper */ public EndpointMBeanExporter(ObjectMapper objectMapper) { - this.objectMapper = (objectMapper == null ? new ObjectMapper() : objectMapper); + this.objectMapper = (objectMapper != null ? objectMapper : new ObjectMapper()); setAutodetect(false); setNamingStrategy(this.defaultNamingStrategy); setAssembler(this.assembler); diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointHandlerMapping.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointHandlerMapping.java index cadbf6c48db..d10ae16f8f5 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointHandlerMapping.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointHandlerMapping.java @@ -150,7 +150,7 @@ public abstract class AbstractEndpointHandlerMapping } Assert.state(handler instanceof MvcEndpoint, "Only MvcEndpoints are supported"); String path = getPath((MvcEndpoint) handler); - return (path == null ? null : getEndpointPatterns(path, mapping)); + return (path != null ? getEndpointPatterns(path, mapping) : null); } /** @@ -163,8 +163,8 @@ public abstract class AbstractEndpointHandlerMapping } private String[] getEndpointPatterns(String path, RequestMappingInfo mapping) { - String patternPrefix = StringUtils.hasText(this.prefix) ? this.prefix + path - : path; + String patternPrefix = (StringUtils.hasText(this.prefix) ? this.prefix + path + : path); Set defaultPatterns = mapping.getPatternsCondition().getPatterns(); if (defaultPatterns.isEmpty()) { return new String[] { patternPrefix, patternPrefix + ".json" }; diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java index cf639a643a6..c3954928d20 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/LoggersMvcEndpoint.java @@ -58,7 +58,7 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter { return getDisabledResponse(); } LoggerLevels levels = this.delegate.invoke(name); - return (levels == null ? ResponseEntity.notFound().build() : levels); + return (levels != null ? levels : ResponseEntity.notFound().build()); } @ActuatorPostMapping("/{name:.*}") @@ -79,8 +79,8 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter { private LogLevel getLogLevel(Map configuration) { String level = configuration.get("configuredLevel"); try { - return (level == null ? null - : LogLevel.valueOf(level.toUpperCase(Locale.ENGLISH))); + return (level != null ? LogLevel.valueOf(level.toUpperCase(Locale.ENGLISH)) + : null); } catch (IllegalArgumentException ex) { throw new InvalidLogLevelException(level); diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java index ad2e7c81704..d3bf05f0a98 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java @@ -99,7 +99,7 @@ public class OrderedHealthAggregator extends AbstractHealthAggregator { public int compare(Status s1, Status s2) { int i1 = this.statusOrder.indexOf(s1.getCode()); int i2 = this.statusOrder.indexOf(s2.getCode()); - return (i1 < i2 ? -1 : (i1 == i2 ? s1.getCode().compareTo(s2.getCode()) : 1)); + return (i1 < i2 ? -1 : (i1 != i2 ? 1 : s1.getCode().compareTo(s2.getCode()))); } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SolrHealthIndicator.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SolrHealthIndicator.java index 25d89c27434..838d13b213e 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SolrHealthIndicator.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/SolrHealthIndicator.java @@ -42,9 +42,9 @@ public class SolrHealthIndicator extends AbstractHealthIndicator { request.setAction(CoreAdminParams.CoreAdminAction.STATUS); CoreAdminResponse response = request.process(this.solrClient); int statusCode = response.getStatus(); - Status status = (statusCode == 0 ? Status.UP : Status.DOWN); + Status status = (statusCode != 0 ? Status.DOWN : Status.UP); builder.status(status).withDetail("solrStatus", - (statusCode == 0 ? "OK" : statusCode)); + (statusCode != 0 ? statusCode : "OK")); } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/BufferMetricReader.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/BufferMetricReader.java index 0a6ad4aacfa..3d776b8638b 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/BufferMetricReader.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/BufferMetricReader.java @@ -55,7 +55,7 @@ public class BufferMetricReader implements MetricReader, PrefixMetricReader { if (buffer == null) { buffer = this.gaugeBuffers.find(name); } - return (buffer == null ? null : asMetric(name, buffer)); + return (buffer != null ? asMetric(name, buffer) : null); } @Override diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/dropwizard/DropwizardMetricServices.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/dropwizard/DropwizardMetricServices.java index e693dd1d874..2dd621f415f 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/dropwizard/DropwizardMetricServices.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/dropwizard/DropwizardMetricServices.java @@ -80,8 +80,8 @@ public class DropwizardMetricServices implements CounterService, GaugeService { public DropwizardMetricServices(MetricRegistry registry, ReservoirFactory reservoirFactory) { this.registry = registry; - this.reservoirFactory = (reservoirFactory == null ? ReservoirFactory.NONE - : reservoirFactory); + this.reservoirFactory = (reservoirFactory != null ? reservoirFactory + : ReservoirFactory.NONE); } @Override diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/statsd/StatsdMetricWriter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/statsd/StatsdMetricWriter.java index ee8bfaec9e1..c9dc8cf5f65 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/statsd/StatsdMetricWriter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/statsd/StatsdMetricWriter.java @@ -78,7 +78,7 @@ public class StatsdMetricWriter implements MetricWriter, Closeable { } private static String trimPrefix(String prefix) { - String trimmedPrefix = StringUtils.hasText(prefix) ? prefix : null; + String trimmedPrefix = (StringUtils.hasText(prefix) ? prefix : null); while (trimmedPrefix != null && trimmedPrefix.endsWith(".")) { trimmedPrefix = trimmedPrefix.substring(0, trimmedPrefix.length() - 1); } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MetricWriterMessageHandler.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MetricWriterMessageHandler.java index 212c6abf002..08b854207ea 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MetricWriterMessageHandler.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/writer/MetricWriterMessageHandler.java @@ -62,7 +62,7 @@ public final class MetricWriterMessageHandler implements MessageHandler { else { if (logger.isWarnEnabled()) { logger.warn("Unsupported metric payload " - + (payload == null ? "null" : payload.getClass().getName())); + + (payload != null ? payload.getClass().getName() : "null")); } } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java index 49764577d57..46be3e8f67a 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/WebRequestTraceFilter.java @@ -114,8 +114,8 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order finally { addTimeTaken(trace, startTime); addSessionIdIfNecessary(request, trace); - enhanceTrace(trace, status == response.getStatus() ? response - : new CustomStatusResponseWrapper(response, status)); + enhanceTrace(trace, status != response.getStatus() + ? new CustomStatusResponseWrapper(response, status) : response); this.repository.add(trace); } } @@ -124,7 +124,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order Map trace) { HttpSession session = request.getSession(false); add(trace, Include.SESSION_ID, "sessionId", - (session == null ? null : session.getId())); + (session != null ? session.getId() : null)); } protected Map getTrace(HttpServletRequest request) { @@ -144,7 +144,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order request.getPathTranslated()); add(trace, Include.CONTEXT_PATH, "contextPath", request.getContextPath()); add(trace, Include.USER_PRINCIPAL, "userPrincipal", - (userPrincipal == null ? null : userPrincipal.getName())); + (userPrincipal != null ? userPrincipal.getName() : null)); if (isIncluded(Include.PARAMETERS)) { trace.put("parameters", getParameterMapCopy(request)); } diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java index d6312f7dc34..2cfb0134804 100755 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointMvcIntegrationTests.java @@ -128,8 +128,8 @@ public class EndpointMvcIntegrationTests { @Bean @ConditionalOnMissingBean public HttpMessageConverters messageConverters() { - return new HttpMessageConverters(this.converters == null - ? Collections.>emptyList() : this.converters); + return new HttpMessageConverters(this.converters != null ? this.converters + : Collections.>emptyList()); } @Bean diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpointTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpointTests.java index a866e79fa6e..e41507e7401 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpointTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/ConfigurationPropertiesReportEndpointTests.java @@ -298,7 +298,7 @@ public class ConfigurationPropertiesReportEndpointTests } public boolean isMixedBoolean() { - return (this.mixedBoolean == null ? false : this.mixedBoolean); + return (this.mixedBoolean != null ? this.mixedBoolean : false); } public void setMixedBoolean(Boolean mixedBoolean) { diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointDisabledIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointDisabledIntegrationTests.java index 5da5a34c789..1cdeee686d2 100755 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointDisabledIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointDisabledIntegrationTests.java @@ -86,7 +86,7 @@ public class HalBrowserMvcEndpointDisabledIntegrationTests { if ("/actuator".equals(path) || endpoint instanceof HeapdumpMvcEndpoint) { continue; } - path = path.length() > 0 ? path : "/"; + path = (path.length() > 0 ? path : "/"); MockHttpServletRequestBuilder requestBuilder = get(path); if (endpoint instanceof AuditEventsMvcEndpoint) { requestBuilder.param("after", "2016-01-01T12:00:00+00:00"); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointManagementContextPathIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointManagementContextPathIntegrationTests.java index e36e685da10..be8e6235577 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointManagementContextPathIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointManagementContextPathIntegrationTests.java @@ -111,8 +111,8 @@ public class HalBrowserMvcEndpointManagementContextPathIntegrationTests { if ("/actuator".equals(path)) { continue; } - path = path.startsWith("/") ? path.substring(1) : path; - path = path.length() > 0 ? path : "self"; + path = (path.startsWith("/") ? path.substring(1) : path); + path = (path.length() > 0 ? path : "self"); this.mockMvc.perform(get("/admin").accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(jsonPath("$._links.%s.href", path) diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/BufferGaugeServiceSpeedTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/BufferGaugeServiceSpeedTests.java index 123c001f2ec..f9c9c9b4fe7 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/BufferGaugeServiceSpeedTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/BufferGaugeServiceSpeedTests.java @@ -69,8 +69,8 @@ public class BufferGaugeServiceSpeedTests { private static int threadCount = 2; - private static final int number = Boolean.getBoolean("performance.test") ? 10000000 - : 1000000; + private static final int number = (Boolean.getBoolean("performance.test") ? 10000000 + : 1000000); private static StopWatch watch = new StopWatch("count"); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/CounterServiceSpeedTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/CounterServiceSpeedTests.java index 9852f32079f..918959fef6c 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/CounterServiceSpeedTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/CounterServiceSpeedTests.java @@ -68,8 +68,8 @@ public class CounterServiceSpeedTests { private static int threadCount = 2; - private static final int number = Boolean.getBoolean("performance.test") ? 10000000 - : 1000000; + private static final int number = (Boolean.getBoolean("performance.test") ? 10000000 + : 1000000); private static StopWatch watch = new StopWatch("count"); diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DefaultCounterServiceSpeedTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DefaultCounterServiceSpeedTests.java index f5802bcbbf3..46204c637fe 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DefaultCounterServiceSpeedTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DefaultCounterServiceSpeedTests.java @@ -67,8 +67,8 @@ public class DefaultCounterServiceSpeedTests { private static int threadCount = 2; - private static final int number = Boolean.getBoolean("performance.test") ? 2000000 - : 1000000; + private static final int number = (Boolean.getBoolean("performance.test") ? 2000000 + : 1000000); private static int count; diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DefaultGaugeServiceSpeedTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DefaultGaugeServiceSpeedTests.java index 84fcd561265..9fe63df9cd5 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DefaultGaugeServiceSpeedTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DefaultGaugeServiceSpeedTests.java @@ -67,8 +67,8 @@ public class DefaultGaugeServiceSpeedTests { private static int threadCount = 2; - private static final int number = Boolean.getBoolean("performance.test") ? 5000000 - : 1000000; + private static final int number = (Boolean.getBoolean("performance.test") ? 5000000 + : 1000000); private static int count; diff --git a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DropwizardCounterServiceSpeedTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DropwizardCounterServiceSpeedTests.java index 8413965411c..20172979f6c 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DropwizardCounterServiceSpeedTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/metrics/buffer/DropwizardCounterServiceSpeedTests.java @@ -69,8 +69,8 @@ public class DropwizardCounterServiceSpeedTests { private static int threadCount = 2; - private static final int number = Boolean.getBoolean("performance.test") ? 10000000 - : 1000000; + private static final int number = (Boolean.getBoolean("performance.test") ? 10000000 + : 1000000); private static int count; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java index 1e2b9b1ed93..3df9af96961 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationImportSelector.java @@ -232,7 +232,7 @@ public class AutoConfigurationImportSelector RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(getEnvironment(), "spring.autoconfigure."); String[] exclude = resolver.getProperty("exclude", String[].class); - return (Arrays.asList(exclude == null ? new String[0] : exclude)); + return (Arrays.asList(exclude != null ? exclude : new String[0])); } private List sort(List configurations, @@ -298,7 +298,7 @@ public class AutoConfigurationImportSelector protected final List asList(AnnotationAttributes attributes, String name) { String[] value = attributes.getStringArray(name); - return Arrays.asList(value == null ? new String[0] : value); + return Arrays.asList(value != null ? value : new String[0]); } private void fireAutoConfigurationImportEvents(List configurations, diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java index 762f32c1741..c74706ce4c6 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java @@ -66,7 +66,7 @@ class AutoConfigurationSorter { public int compare(String o1, String o2) { int i1 = classes.get(o1).getOrder(); int i2 = classes.get(o2).getOrder(); - return (i1 < i2) ? -1 : (i1 > i2) ? 1 : 0; + return (i1 < i2 ? -1 : (i1 > i2 ? 1 : 0)); } }); @@ -174,8 +174,8 @@ class AutoConfigurationSorter { } Map attributes = getAnnotationMetadata() .getAnnotationAttributes(AutoConfigureOrder.class.getName()); - return (attributes == null ? Ordered.LOWEST_PRECEDENCE - : (Integer) attributes.get("value")); + return (attributes != null ? (Integer) attributes.get("value") + : Ordered.LOWEST_PRECEDENCE); } private Set readBefore() { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java index 5b9fcac212a..1607326e178 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java @@ -111,8 +111,8 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec for (String annotationName : ANNOTATION_NAMES) { AnnotationAttributes merged = AnnotatedElementUtils .getMergedAnnotationAttributes(source, annotationName); - Class[] exclude = (merged == null ? null - : merged.getClassArray("exclude")); + Class[] exclude = (merged != null ? merged.getClassArray("exclude") + : null); if (exclude != null) { for (Class excludeClass : exclude) { exclusions.add(excludeClass.getName()); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 553a80fd30f..613514c2182 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -203,7 +203,7 @@ public class RabbitProperties { return this.username; } Address address = this.parsedAddresses.get(0); - return address.username == null ? this.username : address.username; + return (address.username != null ? address.username : this.username); } public void setUsername(String username) { @@ -226,7 +226,7 @@ public class RabbitProperties { return getPassword(); } Address address = this.parsedAddresses.get(0); - return address.password == null ? getPassword() : address.password; + return (address.password != null ? address.password : getPassword()); } public void setPassword(String password) { @@ -253,7 +253,7 @@ public class RabbitProperties { return getVirtualHost(); } Address address = this.parsedAddresses.get(0); - return address.virtualHost == null ? getVirtualHost() : address.virtualHost; + return (address.virtualHost != null ? address.virtualHost : getVirtualHost()); } public void setVirtualHost(String virtualHost) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java index 71900d6fb99..2395a0a4b30 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheAutoConfiguration.java @@ -124,7 +124,7 @@ public class CacheAutoConfiguration { } private String[] append(String[] array, String value) { - String[] result = new String[array == null ? 1 : array.length + 1]; + String[] result = new String[array != null ? array.length + 1 : 1]; if (array != null) { System.arraycopy(array, 0, result, 0, array.length); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java index 0c067d94eba..957eb948c34 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/BeanTypeRegistry.java @@ -289,9 +289,9 @@ final class BeanTypeRegistry implements SmartInitializingSingleton { private Method[] getCandidateFactoryMethods(BeanDefinition definition, Class factoryClass) { - return shouldConsiderNonPublicMethods(definition) + return (shouldConsiderNonPublicMethods(definition) ? ReflectionUtils.getAllDeclaredMethods(factoryClass) - : factoryClass.getMethods(); + : factoryClass.getMethods()); } private boolean shouldConsiderNonPublicMethods(BeanDefinition definition) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java index 53e03ed1341..99995e92de4 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java @@ -61,7 +61,7 @@ public final class ConditionMessage { @Override public String toString() { - return (this.message == null ? "" : this.message); + return (this.message != null ? this.message : ""); } @Override @@ -359,7 +359,7 @@ public final class ConditionMessage { */ public ConditionMessage items(Style style, Object... items) { return items(style, - items == null ? (Collection) null : Arrays.asList(items)); + items != null ? Arrays.asList(items) : (Collection) null); } /** @@ -416,7 +416,7 @@ public final class ConditionMessage { QUOTE { @Override protected String applyToItem(Object item) { - return (item == null ? null : "'" + item + "'"); + return (item != null ? "'" + item + "'" : null); } }; diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java index 386c228de9d..f8e221d5051 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java @@ -146,7 +146,7 @@ public class ConditionOutcome { @Override public String toString() { - return (this.message == null ? "" : this.message.toString()); + return (this.message != null ? this.message.toString() : ""); } /** diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java index 8027b2cdeb8..e35e48849cc 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnExpressionCondition.java @@ -44,10 +44,10 @@ class OnExpressionCondition extends SpringBootCondition { String rawExpression = expression; expression = context.getEnvironment().resolvePlaceholders(expression); ConfigurableListableBeanFactory beanFactory = context.getBeanFactory(); - BeanExpressionResolver resolver = (beanFactory != null) - ? beanFactory.getBeanExpressionResolver() : null; - BeanExpressionContext expressionContext = (beanFactory != null) - ? new BeanExpressionContext(beanFactory, null) : null; + BeanExpressionResolver resolver = (beanFactory != null + ? beanFactory.getBeanExpressionResolver() : null); + BeanExpressionContext expressionContext = (beanFactory != null + ? new BeanExpressionContext(beanFactory, null) : null); if (resolver == null) { resolver = new StandardBeanExpressionResolver(); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java index a37b05461a4..d41356c7737 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java @@ -53,7 +53,7 @@ class OnJavaCondition extends SpringBootCondition { JavaVersion version) { boolean match = runningVersion.isWithin(range, version); String expected = String.format( - range == Range.EQUAL_OR_NEWER ? "(%s or newer)" : "(older than %s)", + range != Range.EQUAL_OR_NEWER ? "(older than %s)" : "(%s or newer)", version); ConditionMessage message = ConditionMessage .forCondition(ConditionalOnJava.class, expected) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java index b36627dd1be..3d266515300 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java @@ -46,8 +46,8 @@ class OnResourceCondition extends SpringBootCondition { AnnotatedTypeMetadata metadata) { MultiValueMap attributes = metadata .getAllAnnotationAttributes(ConditionalOnResource.class.getName(), true); - ResourceLoader loader = context.getResourceLoader() == null - ? this.defaultResourceLoader : context.getResourceLoader(); + ResourceLoader loader = (context.getResourceLoader() != null + ? context.getResourceLoader() : this.defaultResourceLoader); List locations = new ArrayList(); collectValues(locations, attributes.get("resources")); Assert.isTrue(!locations.isEmpty(), diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java index daefc1b6412..58474d84a83 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration.java @@ -195,8 +195,8 @@ public class RedisAutoConfiguration { } private JedisConnectionFactory createJedisConnectionFactory() { - JedisPoolConfig poolConfig = this.properties.getPool() != null - ? jedisPoolConfig() : new JedisPoolConfig(); + JedisPoolConfig poolConfig = (this.properties.getPool() != null + ? jedisPoolConfig() : new JedisPoolConfig()); if (getSentinelConfig() != null) { return new JedisConnectionFactory(getSentinelConfig(), poolConfig); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java index 68f8444b5e9..6cca5caa21c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java @@ -80,7 +80,7 @@ class NoSuchBeanDefinitionFailureAnalyzer cause); StringBuilder message = new StringBuilder(); message.append(String.format("%s required %s that could not be found.%n", - description == null ? "A component" : description, + (description != null ? description : "A component"), getBeanDescription(cause))); if (!autoConfigurationResults.isEmpty()) { for (AutoConfigurationResult provider : autoConfigurationResults) { @@ -165,7 +165,7 @@ class NoSuchBeanDefinitionFailureAnalyzer Source(String source) { String[] tokens = source.split("#"); this.className = (tokens.length > 1 ? tokens[0] : source); - this.methodName = (tokens.length == 2 ? tokens[1] : null); + this.methodName = (tokens.length != 2 ? null : tokens[1]); } public String getClassName() { @@ -225,8 +225,8 @@ class NoSuchBeanDefinitionFailureAnalyzer private boolean hasName(MethodMetadata methodMetadata, String name) { Map attributes = methodMetadata .getAnnotationAttributes(Bean.class.getName()); - String[] candidates = (attributes == null ? null - : (String[]) attributes.get("name")); + String[] candidates = (attributes != null ? (String[]) attributes.get("name") + : null); if (candidates != null) { for (String candidate : candidates) { if (candidate.equals(name)) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index dcc33e18f45..7e6f3be1980 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -108,7 +108,7 @@ public class FlywayProperties { } public String getPassword() { - return (this.password == null ? "" : this.password); + return (this.password != null ? this.password : ""); } public void setPassword(String password) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java index 26690bb4923..a41e060eb2b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java +++ b/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-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java index e9c8ab39be9..bc98ccd3782 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java @@ -184,7 +184,7 @@ public class DataSourceAutoConfiguration { private ClassLoader getDataSourceClassLoader(ConditionContext context) { Class dataSourceClass = new DataSourceBuilder(context.getClassLoader()) .findType(); - return (dataSourceClass == null ? null : dataSourceClass.getClassLoader()); + return (dataSourceClass != null ? dataSourceClass.getClassLoader() : null); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/DataSourcePoolMetadataProviders.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/DataSourcePoolMetadataProviders.java index 73164134bfe..d9f062c304a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/DataSourcePoolMetadataProviders.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/DataSourcePoolMetadataProviders.java @@ -41,9 +41,9 @@ public class DataSourcePoolMetadataProviders implements DataSourcePoolMetadataPr */ public DataSourcePoolMetadataProviders( Collection providers) { - this.providers = (providers == null - ? Collections.emptyList() - : new ArrayList(providers)); + this.providers = (providers != null + ? new ArrayList(providers) + : Collections.emptyList()); } @Override diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/TomcatDataSourcePoolMetadata.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/TomcatDataSourcePoolMetadata.java index e0e0e031d1f..cb109a4f6f1 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/TomcatDataSourcePoolMetadata.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/metadata/TomcatDataSourcePoolMetadata.java @@ -34,7 +34,7 @@ public class TomcatDataSourcePoolMetadata @Override public Integer getActive() { ConnectionPool pool = getDataSource().getPool(); - return (pool == null ? 0 : pool.getActive()); + return (pool != null ? pool.getActive() : 0); } @Override diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java index 2d76b3dfe07..f2e0bfbd2e1 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jersey/JerseyAutoConfiguration.java @@ -198,7 +198,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-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java index 1d57a632c52..61e10edde2a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java @@ -226,7 +226,7 @@ public class MongoProperties { if (options == null) { options = MongoClientOptions.builder().build(); } - String host = this.host == null ? "localhost" : this.host; + String host = (this.host != null ? this.host : "localhost"); return new MongoClient(Collections.singletonList(new ServerAddress(host, port)), Collections.emptyList(), options); } @@ -242,13 +242,13 @@ public class MongoProperties { } List credentials = new ArrayList(); if (hasCustomCredentials()) { - String database = this.authenticationDatabase == null - ? getMongoClientDatabase() : this.authenticationDatabase; + String database = (this.authenticationDatabase != null + ? this.authenticationDatabase : getMongoClientDatabase()); credentials.add(MongoCredential.createCredential(this.username, database, this.password)); } - String host = this.host == null ? "localhost" : this.host; - int port = this.port != null ? this.port : DEFAULT_PORT; + String host = (this.host != null ? this.host : "localhost"); + int port = (this.port != null ? this.port : DEFAULT_PORT); return new MongoClient( Collections.singletonList(new ServerAddress(host, port)), credentials, options); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java index ec63ff7a0a9..0018bdb89a4 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java @@ -239,8 +239,8 @@ public class EmbeddedMongoAutoConfiguration { Set features) { Assert.notNull(version, "version must not be null"); this.version = version; - this.features = (features == null ? Collections.emptySet() - : features); + this.features = (features != null ? features + : Collections.emptySet()); } @Override diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SpringBootWebSecurityConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SpringBootWebSecurityConfiguration.java index 698fae5f8b5..4b1b2a49bbc 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SpringBootWebSecurityConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/SpringBootWebSecurityConfiguration.java @@ -283,7 +283,7 @@ public class SpringBootWebSecurityConfiguration { private String[] getSecureApplicationPaths() { List list = new ArrayList(); for (String path : this.security.getBasic().getPath()) { - path = (path == null ? "" : path.trim()); + path = (path != null ? path.trim() : ""); if (path.equals("/**")) { return new String[] { path }; } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/DefaultUserInfoRestTemplateFactory.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/DefaultUserInfoRestTemplateFactory.java index ac30aeec067..4186b9a4a4f 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/DefaultUserInfoRestTemplateFactory.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/DefaultUserInfoRestTemplateFactory.java @@ -70,7 +70,7 @@ public class DefaultUserInfoRestTemplateFactory implements UserInfoRestTemplateF public OAuth2RestTemplate getUserInfoRestTemplate() { if (this.oauth2RestTemplate == null) { this.oauth2RestTemplate = createOAuth2RestTemplate( - this.details == null ? DEFAULT_RESOURCE_DETAILS : this.details); + this.details != null ? this.details : DEFAULT_RESOURCE_DETAILS); this.oauth2RestTemplate.getInterceptors() .add(new AcceptJsonRequestInterceptor()); AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider(); diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServices.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServices.java index a3c3445353e..7cb4251b357 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServices.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/resource/UserInfoTokenServices.java @@ -115,7 +115,7 @@ public class UserInfoTokenServices implements ResourceServerTokenServices { */ protected Object getPrincipal(Map map) { Object principal = this.principalExtractor.extractPrincipal(map); - return (principal == null ? "unknown" : principal); + return (principal != null ? principal : "unknown"); } @Override diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java index f3c363e97ee..ad1199c2053 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/FacebookAutoConfiguration.java @@ -70,7 +70,7 @@ public class FacebookAutoConfiguration { public Facebook facebook(ConnectionRepository repository) { Connection connection = repository .findPrimaryConnection(Facebook.class); - return connection != null ? connection.getApi() : null; + return (connection != null ? connection.getApi() : null); } @Bean(name = { "connect/facebookConnect", "connect/facebookConnected" }) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java index 48866c2a84e..03e3a26f629 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/social/LinkedInAutoConfiguration.java @@ -70,7 +70,7 @@ public class LinkedInAutoConfiguration { public LinkedIn linkedin(ConnectionRepository repository) { Connection connection = repository .findPrimaryConnection(LinkedIn.class); - return connection != null ? connection.getApi() : null; + return (connection != null ? connection.getApi() : null); } @Bean(name = { "connect/linkedinConnect", "connect/linkedinConnected" }) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java index 39ecd7ee348..7f9211cebee 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java @@ -76,7 +76,7 @@ public class TemplateAvailabilityProviders { * @param applicationContext the source application context */ public TemplateAvailabilityProviders(ApplicationContext applicationContext) { - this(applicationContext == null ? null : applicationContext.getClassLoader()); + this(applicationContext != null ? applicationContext.getClassLoader() : null); } /** @@ -144,12 +144,12 @@ public class TemplateAvailabilityProviders { if (provider == null) { synchronized (this.cache) { provider = findProvider(view, environment, classLoader, resourceLoader); - provider = (provider == null ? NONE : provider); + provider = (provider != null ? provider : NONE); this.resolved.put(view, provider); this.cache.put(view, provider); } } - return (provider == NONE ? null : provider); + return (provider != NONE ? provider : null); } private TemplateAvailabilityProvider findProvider(String view, diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java index 6c5ab3a0a61..0cf48c2dd0a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java @@ -41,8 +41,9 @@ public class TransactionManagerCustomizers { public TransactionManagerCustomizers( Collection> customizers) { - this.customizers = (customizers == null ? null - : new ArrayList>(customizers)); + this.customizers = (customizers != null + ? new ArrayList>(customizers) + : null); } public void customize(PlatformTransactionManager transactionManager) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java index 755dfa7a73e..0615e2cdf8f 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/BasicErrorController.java @@ -90,7 +90,7 @@ public class BasicErrorController extends AbstractErrorController { request, isIncludeStackTrace(request, MediaType.TEXT_HTML))); response.setStatus(status.value()); ModelAndView modelAndView = resolveErrorView(request, response, status, model); - return (modelAndView == null ? new ModelAndView("error", model) : modelAndView); + return (modelAndView != null ? modelAndView : new ModelAndView("error", model)); } @RequestMapping diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java index ced74749665..4d49186b1be 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java @@ -283,11 +283,11 @@ public class ErrorMvcAutoConfiguration { @Override public String resolvePlaceholder(String placeholderName) { Expression expression = this.expressions.get(placeholderName); - return escape(expression == null ? null : expression.getValue(this.context)); + return escape(expression != null ? expression.getValue(this.context) : null); } private String escape(Object value) { - return HtmlUtils.htmlEscape(value == null ? null : value.toString()); + return HtmlUtils.htmlEscape(value != null ? value.toString() : null); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpEncodingProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpEncodingProperties.java index d547d02e77c..a4c8e2fb518 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpEncodingProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpEncodingProperties.java @@ -102,7 +102,7 @@ public class HttpEncodingProperties { } boolean shouldForce(Type type) { - Boolean force = (type == Type.REQUEST ? this.forceRequest : this.forceResponse); + Boolean force = (type != Type.REQUEST ? this.forceResponse : this.forceRequest); if (force == null) { force = this.force; } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.java index 77ccf6a2b13..e5e48011357 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/HttpMessageConvertersAutoConfiguration.java @@ -64,8 +64,8 @@ public class HttpMessageConvertersAutoConfiguration { @Bean @ConditionalOnMissingBean public HttpMessageConverters messageConverters() { - return new HttpMessageConverters(this.converters == null - ? Collections.>emptyList() : this.converters); + return new HttpMessageConverters(this.converters != null ? this.converters + : Collections.>emptyList()); } @Configuration diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index e32ec9a1b9b..1ad128448ca 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -382,7 +382,7 @@ public class ServerProperties return this.useForwardHeaders; } CloudPlatform platform = CloudPlatform.getActive(this.environment); - return (platform == null ? false : platform.isUsingForwardHeaders()); + return (platform != null ? platform.isUsingForwardHeaders() : false); } public Integer getConnectionTimeout() { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java index ac690940243..0ab16ef128a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration.java @@ -381,8 +381,8 @@ public class WebMvcAutoConfiguration { @Override public RequestMappingHandlerAdapter requestMappingHandlerAdapter() { RequestMappingHandlerAdapter adapter = super.requestMappingHandlerAdapter(); - adapter.setIgnoreDefaultModelOnRedirect(this.mvcProperties == null ? true - : this.mvcProperties.isIgnoreDefaultModelOnRedirect()); + adapter.setIgnoreDefaultModelOnRedirect(this.mvcProperties != null + ? this.mvcProperties.isIgnoreDefaultModelOnRedirect() : true); return adapter; } diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java index 609dbe9b68c..b0952f83999 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java @@ -96,8 +96,8 @@ public class HazelcastJpaDependencyAutoConfigurationTests { private List getEntityManagerFactoryDependencies() { String[] dependsOn = this.context.getBeanDefinition("entityManagerFactory") .getDependsOn(); - return dependsOn != null ? Arrays.asList(dependsOn) - : Collections.emptyList(); + return (dependsOn != null ? Arrays.asList(dependsOn) + : Collections.emptyList()); } public void load(Class config) { diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java index dd70c6d2d36..6099fe7ef58 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java @@ -64,7 +64,7 @@ public class SpringApplicationWebApplicationInitializer private Manifest getManifest(ServletContext servletContext) throws IOException { InputStream stream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF"); - Manifest manifest = (stream == null ? null : new Manifest(stream)); + Manifest manifest = (stream != null ? new Manifest(stream) : null); return manifest; } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java index 0a52a20dd81..0bdca86549f 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java @@ -260,7 +260,7 @@ public class CommandRunner implements Iterable { } protected boolean errorMessage(String message) { - Log.error(message == null ? "Unexpected error" : message); + Log.error(message != null ? message : "Unexpected error"); return message != null; } @@ -280,8 +280,8 @@ public class CommandRunner implements Iterable { String usageHelp = command.getUsageHelp(); String description = command.getDescription(); Log.info(String.format("%n %1$s %2$-15s%n %3$s", command.getName(), - (usageHelp == null ? "" : usageHelp), - (description == null ? "" : description))); + (usageHelp != null ? usageHelp : ""), + (description != null ? description : ""))); } } Log.info(""); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java index 5ec07abf4ed..9d2c7367958 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java @@ -238,7 +238,7 @@ abstract class ArchiveCommand extends OptionParsingCommand { private String commaDelimitedClassNames(Class[] classes) { StringBuilder builder = new StringBuilder(); for (int i = 0; i < classes.length; i++) { - builder.append(i == 0 ? "" : ","); + builder.append(i != 0 ? "," : ""); builder.append(classes[i].getName()); } return builder.toString(); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java index 0d41157aae8..326074f14f1 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java @@ -107,7 +107,7 @@ public class HelpCommand extends AbstractCommand { } Collection examples = command.getExamples(); if (examples != null) { - Log.info(examples.size() == 1 ? "example:" : "examples:"); + Log.info(examples.size() != 1 ? "examples:" : "example:"); Log.info(""); for (HelpExample example : examples) { Log.info(" " + example.getDescription() + ":"); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java index 2803e329406..b114d06f484 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java @@ -45,7 +45,7 @@ public class HintCommand extends AbstractCommand { @Override public ExitStatus run(String... args) throws Exception { try { - int index = (args.length == 0 ? 0 : Integer.valueOf(args[0]) - 1); + int index = (args.length != 0 ? Integer.valueOf(args[0]) - 1 : 0); List arguments = new ArrayList(args.length); for (int i = 2; i < args.length; i++) { arguments.add(args[i]); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java index b8f125ce9bd..d37c9a4c6d7 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrServiceMetadata.java @@ -149,8 +149,8 @@ class InitializrServiceMetadata { } JSONObject type = root.getJSONObject(TYPE_EL); JSONArray array = type.getJSONArray(VALUES_EL); - String defaultType = type.has(DEFAULT_ATTRIBUTE) - ? type.getString(DEFAULT_ATTRIBUTE) : null; + String defaultType = (type.has(DEFAULT_ATTRIBUTE) + ? type.getString(DEFAULT_ATTRIBUTE) : null); for (int i = 0; i < array.length(); i++) { JSONObject typeJson = array.getJSONObject(i); ProjectType projectType = parseType(typeJson, defaultType); @@ -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-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java index 4cf44fd5ed1..c65490c6733 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java @@ -417,7 +417,7 @@ class ProjectGenerationRequest { } if (this.output != null) { int i = this.output.lastIndexOf('.'); - return (i == -1 ? this.output : this.output.substring(0, i)); + return (i != -1 ? this.output.substring(0, i) : this.output); } return null; } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java index 305938d0f82..597e4a09541 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java @@ -164,7 +164,7 @@ public class OptionHandler { OptionHelpAdapter(OptionDescriptor descriptor) { this.options = new LinkedHashSet(); for (String option : descriptor.options()) { - this.options.add((option.length() == 1 ? "-" : "--") + option); + this.options.add((option.length() != 1 ? "--" : "-") + option); } if (this.options.contains("--cp")) { this.options.remove("--cp"); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java index 5bfa79a5423..0d2558a4a0c 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java @@ -73,7 +73,7 @@ public class CommandCompleter extends StringsCompleter { public int complete(String buffer, int cursor, List candidates) { int completionIndex = super.complete(buffer, cursor, candidates); int spaceIndex = buffer.indexOf(' '); - String commandName = (spaceIndex == -1) ? "" : buffer.substring(0, spaceIndex); + String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : ""); if (!"".equals(commandName.trim())) { for (Command command : this.commands) { if (command.getName().equals(commandName)) { @@ -129,7 +129,7 @@ public class CommandCompleter extends StringsCompleter { OptionHelpLine(OptionHelp optionHelp) { StringBuilder options = new StringBuilder(); for (String option : optionHelp.getOptions()) { - options.append(options.length() == 0 ? "" : ", "); + options.append(options.length() != 0 ? ", " : ""); options.append(option); } this.options = options.toString(); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java index c9f84dbf57e..fec86c078af 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java @@ -145,7 +145,7 @@ public class Shell { private void printBanner() { String version = getClass().getPackage().getImplementationVersion(); - version = (version == null ? "" : " (v" + version + ")"); + version = (version != null ? " (v" + version + ")" : ""); System.out.println(ansi("Spring Boot", Code.BOLD).append(version, Code.FAINT)); System.out.println(ansi("Hit TAB to complete. Type 'help' and hit " + "RETURN for help, and 'exit' to quit.")); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java index 1b8ec1f67a5..cadc049ad57 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/ShellPrompts.java @@ -53,7 +53,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-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java index 9992ba9c6d1..a2bd79ffcd0 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java @@ -119,7 +119,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader { InputStream resourceStream = super.getResourceAsStream(name); if (resourceStream == null) { byte[] bytes = this.classResources.get(name); - resourceStream = bytes == null ? null : new ByteArrayInputStream(bytes); + resourceStream = (bytes != null ? new ByteArrayInputStream(bytes) : null); } return resourceStream; } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java index fbacab3433a..2222e9412e2 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java @@ -42,13 +42,13 @@ public class DependencyManagementArtifactCoordinatesResolver @Override public String getGroupId(String artifactId) { Dependency dependency = find(artifactId); - return (dependency == null ? null : dependency.getGroupId()); + return (dependency != null ? dependency.getGroupId() : null); } @Override public String getArtifactId(String id) { Dependency dependency = find(id); - return dependency == null ? null : dependency.getArtifactId(); + return (dependency != null ? dependency.getArtifactId() : null); } private Dependency find(String id) { @@ -69,7 +69,7 @@ public class DependencyManagementArtifactCoordinatesResolver @Override public String getVersion(String module) { Dependency dependency = find(module); - return dependency == null ? null : dependency.getVersion(); + return (dependency != null ? dependency.getVersion() : null); } } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java index e5f56c3cf70..d3624ba0849 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java @@ -209,7 +209,7 @@ public class AetherGrapeEngine implements GrapeEngine { private boolean isTransitive(Map dependencyMap) { Boolean transitive = (Boolean) dependencyMap.get("transitive"); - return (transitive == null ? true : transitive); + return (transitive != null ? transitive : true); } private List getDependencies(DependencyResult dependencyResult) { @@ -231,7 +231,7 @@ public class AetherGrapeEngine implements GrapeEngine { private GroovyClassLoader getClassLoader(Map args) { GroovyClassLoader classLoader = (GroovyClassLoader) args.get("classLoader"); - return (classLoader == null ? this.classLoader : classLoader); + return (classLoader != null ? classLoader : this.classLoader); } @Override diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java index 5e9454dc32e..5d4e09f8ead 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java @@ -51,8 +51,9 @@ public class DefaultRepositorySystemSessionAutoConfiguration ProxySelector existing = session.getProxySelector(); if (existing == null || !(existing instanceof CompositeProxySelector)) { JreProxySelector fallback = new JreProxySelector(); - ProxySelector selector = existing == null ? fallback - : new CompositeProxySelector(Arrays.asList(existing, fallback)); + ProxySelector selector = (existing != null + ? new CompositeProxySelector(Arrays.asList(existing, fallback)) + : fallback); session.setProxySelector(selector); } } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java index f6f3ec07c86..e6d6eebd559 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java @@ -67,7 +67,7 @@ public class DependencyResolutionContext { dependency = this.managedDependencyByGroupAndArtifact .get(getIdentifier(groupId, artifactId)); } - return dependency != null ? dependency.getArtifact().getVersion() : null; + return (dependency != null ? dependency.getArtifact().getVersion() : null); } public List getManagedDependencies() { @@ -104,9 +104,10 @@ public class DependencyResolutionContext { this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency), aetherDependency); } - this.dependencyManagement = this.dependencyManagement == null - ? dependencyManagement : new CompositeDependencyManagement( - dependencyManagement, this.dependencyManagement); + this.dependencyManagement = (this.dependencyManagement != null + ? new CompositeDependencyManagement(dependencyManagement, + this.dependencyManagement) + : dependencyManagement); this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver( this.dependencyManagement); } diff --git a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java index 44ee494af48..c1f4f65c90f 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java @@ -120,8 +120,8 @@ public abstract class AbstractHttpClientMockTests { try { HttpEntity entity = mock(HttpEntity.class); given(entity.getContent()).willReturn(new ByteArrayInputStream(content)); - Header contentTypeHeader = contentType != null - ? new BasicHeader("Content-Type", contentType) : null; + Header contentTypeHeader = (contentType != null + ? new BasicHeader("Content-Type", contentType) : null); given(entity.getContentType()).willReturn(contentTypeHeader); given(response.getEntity()).willReturn(entity); return entity; @@ -139,7 +139,7 @@ public abstract class AbstractHttpClientMockTests { protected void mockHttpHeader(CloseableHttpResponse response, String headerName, String value) { - Header header = value != null ? new BasicHeader(headerName, value) : null; + Header header = (value != null ? new BasicHeader(headerName, value) : null); given(response.getFirstHeader(headerName)).willReturn(header); } diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java index c6e17e5a911..4825fb5d3f0 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java @@ -95,8 +95,8 @@ public class RemoteDevToolsAutoConfiguration { @Bean public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() { Handler handler = new HttpStatusHandler(); - return new UrlHandlerMapper((this.serverProperties.getContextPath() == null ? "" - : this.serverProperties.getContextPath()) + return new UrlHandlerMapper((this.serverProperties.getContextPath() != null + ? this.serverProperties.getContextPath() : "") + this.properties.getRemote().getContextPath(), handler); } @@ -136,8 +136,8 @@ public class RemoteDevToolsAutoConfiguration { @Bean @ConditionalOnMissingBean(name = "remoteRestartHandlerMapper") public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) { - String url = (this.serverProperties.getContextPath() == null ? "" - : this.serverProperties.getContextPath()) + String url = (this.serverProperties.getContextPath() != null + ? this.serverProperties.getContextPath() : "") + this.properties.getRemote().getContextPath() + "/restart"; logger.warn("Listening for remote restart updates on " + url); Handler handler = new HttpRestartServerHandler(server); @@ -162,8 +162,8 @@ public class RemoteDevToolsAutoConfiguration { @ConditionalOnMissingBean(name = "remoteDebugHandlerMapper") public UrlHandlerMapper remoteDebugHandlerMapper( @Qualifier("remoteDebugHttpTunnelServer") HttpTunnelServer server) { - String url = (this.serverProperties.getContextPath() == null ? "" - : this.serverProperties.getContextPath()) + String url = (this.serverProperties.getContextPath() != null + ? this.serverProperties.getContextPath() : "") + this.properties.getRemote().getContextPath() + "/debug"; logger.warn("Listening for remote debug traffic on " + url); Handler handler = new HttpTunnelServerHandler(server); diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java index 5b5d26764dc..0a193a86c63 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java @@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce public void postProcessEnvironment(ConfigurableEnvironment environment, SpringApplication application) { File home = getHomeFolder(); - File propertyFile = (home == null ? null : new File(home, FILE_NAME)); + File propertyFile = (home != null ? new File(home, FILE_NAME) : null); if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) { FileSystemResource resource = new FileSystemResource(propertyFile); Properties properties; diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java index cbd5c674991..d23f20095ac 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java @@ -135,7 +135,7 @@ public class ClassPathChangeUploader private void logUpload(ClassLoaderFiles classLoaderFiles) { int size = classLoaderFiles.size(); logger.info( - "Uploaded " + size + " class " + (size == 1 ? "resource" : "resources")); + "Uploaded " + size + " class " + (size != 1 ? "resources" : "resource")); } private byte[] serialize(ClassLoaderFiles classLoaderFiles) throws IOException { @@ -162,10 +162,10 @@ public class ClassPathChangeUploader private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile) throws IOException { ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType()); - byte[] bytes = (kind == Kind.DELETED ? null - : FileCopyUtils.copyToByteArray(changedFile.getFile())); - long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis() - : changedFile.getFile().lastModified()); + byte[] bytes = (kind != Kind.DELETED + ? FileCopyUtils.copyToByteArray(changedFile.getFile()) : null); + long lastModified = (kind != Kind.DELETED ? changedFile.getFile().lastModified() + : System.currentTimeMillis()); return new ClassLoaderFile(kind, lastModified, bytes); } diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java index 920b7d1ff27..f814a651c5a 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java @@ -55,8 +55,8 @@ public class ClassLoaderFile implements Serializable { */ public ClassLoaderFile(Kind kind, long lastModified, byte[] contents) { Assert.notNull(kind, "Kind must not be null"); - Assert.isTrue(kind == Kind.DELETED ? contents == null : contents != null, - "Contents must " + (kind == Kind.DELETED ? "" : "not ") + "be null"); + Assert.isTrue(kind != Kind.DELETED ? contents != null : contents == null, + "Contents must " + (kind != Kind.DELETED ? "not " : "") + "be null"); this.kind = kind; this.lastModified = lastModified; this.contents = contents; diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java index 9014fb757ce..978e4dd5fe7 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java @@ -91,8 +91,8 @@ public class HttpTunnelConnection implements TunnelConnection { throw new IllegalArgumentException("Malformed URL '" + url + "'"); } this.requestFactory = requestFactory; - this.executor = (executor == null - ? Executors.newCachedThreadPool(new TunnelThreadFactory()) : executor); + this.executor = (executor != null ? executor + : Executors.newCachedThreadPool(new TunnelThreadFactory())); } @Override diff --git a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java index f1158bf5c3f..0071180d949 100644 --- a/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java +++ b/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java @@ -139,7 +139,7 @@ public class ClassPathChangeUploaderTests { private void assertClassFile(ClassLoaderFile file, String content, Kind kind) { assertThat(file.getContents()) - .isEqualTo(content == null ? null : content.getBytes()); + .isEqualTo(content != null ? content.getBytes() : null); assertThat(file.getKind()).isEqualTo(kind); } diff --git a/spring-boot-docs/src/main/java/org/springframework/boot/test/spock/SpockTestRestTemplateExample.java b/spring-boot-docs/src/main/java/org/springframework/boot/test/spock/SpockTestRestTemplateExample.java index cc87370ee48..b954daedd85 100644 --- a/spring-boot-docs/src/main/java/org/springframework/boot/test/spock/SpockTestRestTemplateExample.java +++ b/spring-boot-docs/src/main/java/org/springframework/boot/test/spock/SpockTestRestTemplateExample.java @@ -45,8 +45,8 @@ public class SpockTestRestTemplateExample { ObjectProvider builderProvider, Environment environment) { RestTemplateBuilder builder = builderProvider.getIfAvailable(); - TestRestTemplate template = builder == null ? new TestRestTemplate() - : new TestRestTemplate(builder.build()); + TestRestTemplate template = (builder != null + ? new TestRestTemplate(builder.build()) : new TestRestTemplate()); template.setUriTemplateHandler(new LocalHostUriTemplateHandler(environment)); return template; } diff --git a/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java b/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java index a7a16aaedf7..45dd4744d57 100644 --- a/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java +++ b/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java @@ -66,8 +66,9 @@ abstract class AbstractApplicationLauncher extends ExternalResource { private Process startApplication() throws Exception { File workingDirectory = getWorkingDirectory(); - File serverPortFile = workingDirectory == null ? new File("target/server.port") - : new File(workingDirectory, "target/server.port"); + File serverPortFile = (workingDirectory != null + ? new File(workingDirectory, "target/server.port") + : new File("target/server.port")); serverPortFile.delete(); File archive = this.applicationBuilder.buildApplication(); List arguments = new ArrayList(); diff --git a/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/BootRunApplicationLauncher.java b/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/BootRunApplicationLauncher.java index f5a87f5b42e..d707e00c311 100644 --- a/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/BootRunApplicationLauncher.java +++ b/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/BootRunApplicationLauncher.java @@ -107,14 +107,14 @@ class BootRunApplicationLauncher extends AbstractApplicationLauncher { } private String getClassesPath(File archive) { - return archive.getName().endsWith(".jar") ? "BOOT-INF/classes" - : "WEB-INF/classes"; + return (archive.getName().endsWith(".jar") ? "BOOT-INF/classes" + : "WEB-INF/classes"); } private List getLibPaths(File archive) { - return archive.getName().endsWith(".jar") + return (archive.getName().endsWith(".jar") ? Collections.singletonList("BOOT-INF/lib") - : Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided"); + : Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided")); } private void explodeArchive(File archive) throws IOException { diff --git a/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/ExplodedApplicationLauncher.java b/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/ExplodedApplicationLauncher.java index 52bb10c6649..bb71be94876 100644 --- a/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/ExplodedApplicationLauncher.java +++ b/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/ExplodedApplicationLauncher.java @@ -54,9 +54,9 @@ class ExplodedApplicationLauncher extends AbstractApplicationLauncher { @Override protected List getArguments(File archive) { - String mainClass = archive.getName().endsWith(".war") + String mainClass = (archive.getName().endsWith(".war") ? "org.springframework.boot.loader.WarLauncher" - : "org.springframework.boot.loader.JarLauncher"; + : "org.springframework.boot.loader.JarLauncher"); try { explodeArchive(archive); return Arrays.asList("-cp", this.exploded.getAbsolutePath(), mainClass); diff --git a/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/IdeApplicationLauncher.java b/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/IdeApplicationLauncher.java index 681c684b6f0..e3648b097cc 100644 --- a/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/IdeApplicationLauncher.java +++ b/spring-boot-integration-tests/spring-boot-integration-tests-embedded-servlet-container/src/test/java/org/springframework/boot/context/embedded/IdeApplicationLauncher.java @@ -128,14 +128,14 @@ class IdeApplicationLauncher extends AbstractApplicationLauncher { } private String getClassesPath(File archive) { - return archive.getName().endsWith(".jar") ? "BOOT-INF/classes" - : "WEB-INF/classes"; + return (archive.getName().endsWith(".jar") ? "BOOT-INF/classes" + : "WEB-INF/classes"); } private List getLibPaths(File archive) { - return archive.getName().endsWith(".jar") + return (archive.getName().endsWith(".jar") ? Collections.singletonList("BOOT-INF/lib") - : Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided"); + : Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided")); } private void explodeArchive(File archive, File destination) throws IOException { diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java index 496839fb796..903b85ec79c 100644 --- a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java +++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/domain/HotelSummary.java @@ -25,7 +25,7 @@ public interface HotelSummary { Double getAverageRating(); default Integer getAverageRatingRounded() { - return getAverageRating() == null ? null : (int) Math.round(getAverageRating()); + return (getAverageRating() != null ? (int) Math.round(getAverageRating()) : null); } } diff --git a/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/domain/HotelSummary.java b/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/domain/HotelSummary.java index 49f4392997a..d4970c2b538 100644 --- a/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/domain/HotelSummary.java +++ b/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/domain/HotelSummary.java @@ -25,7 +25,7 @@ public interface HotelSummary { Double getAverageRating(); default Integer getAverageRatingRounded() { - return getAverageRating() == null ? null : (int) Math.round(getAverageRating()); + return (getAverageRating() != null ? (int) Math.round(getAverageRating()) : null); } } diff --git a/spring-boot-samples/spring-boot-sample-hibernate52/src/main/java/sample/hibernate52/domain/HotelSummary.java b/spring-boot-samples/spring-boot-sample-hibernate52/src/main/java/sample/hibernate52/domain/HotelSummary.java index 1bd36810fb8..afb28548e64 100644 --- a/spring-boot-samples/spring-boot-sample-hibernate52/src/main/java/sample/hibernate52/domain/HotelSummary.java +++ b/spring-boot-samples/spring-boot-sample-hibernate52/src/main/java/sample/hibernate52/domain/HotelSummary.java @@ -25,7 +25,7 @@ public interface HotelSummary { Double getAverageRating(); default Integer getAverageRatingRounded() { - return getAverageRating() == null ? null : (int) Math.round(getAverageRating()); + return (getAverageRating() != null ? (int) Math.round(getAverageRating()) : null); } } diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java index 5df6ca9c49e..ed2e6bae3ed 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java @@ -105,8 +105,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource } Annotation mergedAnnotation = AnnotatedElementUtils.getMergedAnnotation(source, annotationType); - return mergedAnnotation != null ? mergedAnnotation - : findMergedAnnotation(source.getSuperclass(), annotationType); + return (mergedAnnotation != null ? mergedAnnotation + : findMergedAnnotation(source.getSuperclass(), annotationType)); } private void collectProperties(Annotation annotation, Method attribute, @@ -143,8 +143,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource private String getName(PropertyMapping typeMapping, PropertyMapping attributeMapping, Method attribute) { - String prefix = (typeMapping == null ? "" : typeMapping.value()); - String name = (attributeMapping == null ? "" : attributeMapping.value()); + String prefix = (typeMapping != null ? typeMapping.value() : ""); + String name = (attributeMapping != null ? attributeMapping.value() : ""); if (!StringUtils.hasText(name)) { name = toKebabCase(attribute.getName()); } diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java index 1c811cb0c7f..07f1171d4d2 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java @@ -115,10 +115,10 @@ class PropertyMappingContextCustomizer implements ContextCustomizer { private String getAnnotationsDescription(Set> annotations) { StringBuilder result = new StringBuilder(); for (Class annotation : annotations) { - result.append(result.length() == 0 ? "" : ", "); + result.append(result.length() != 0 ? ", " : ""); result.append("@" + ClassUtils.getShortName(annotation)); } - result.insert(0, annotations.size() == 1 ? "annotation " : "annotations "); + result.insert(0, annotations.size() != 1 ? "annotations " : "annotation "); return result.toString(); } diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java b/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java index b77a7dffb9b..dd3a9323a64 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java @@ -169,10 +169,10 @@ class ImportsContextCustomizer implements ContextCustomizer { public String[] selectImports(AnnotationMetadata importingClassMetadata) { BeanDefinition definition = this.beanFactory .getBeanDefinition(ImportsConfiguration.BEAN_NAME); - Object testClass = (definition == null ? null - : definition.getAttribute(TEST_CLASS_ATTRIBUTE)); - return (testClass == null ? NO_IMPORTS - : new String[] { ((Class) testClass).getName() }); + Object testClass = (definition != null + ? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null); + return (testClass != null ? new String[] { ((Class) testClass).getName() } + : NO_IMPORTS); } } diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java index 61329056a48..6cbbfbd403a 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java @@ -79,7 +79,7 @@ final class SpringBootConfigurationFinder { private String getParentPackage(String sourcePackage) { int lastDot = sourcePackage.lastIndexOf("."); - return (lastDot == -1 ? "" : sourcePackage.substring(0, lastDot)); + return (lastDot != -1 ? sourcePackage.substring(0, lastDot) : ""); } /** diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java index 8adf675b211..836e64a3953 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java @@ -44,6 +44,7 @@ import org.springframework.core.env.PropertySources; import org.springframework.core.env.PropertySourcesPropertyResolver; import org.springframework.core.env.StandardEnvironment; import org.springframework.core.io.DefaultResourceLoader; +import org.springframework.core.io.ResourceLoader; import org.springframework.test.context.ContextConfigurationAttributes; import org.springframework.test.context.ContextCustomizer; import org.springframework.test.context.ContextLoader; @@ -97,11 +98,11 @@ public class SpringBootContextLoader extends AbstractContextLoader { if (!ObjectUtils.isEmpty(config.getActiveProfiles())) { setActiveProfiles(environment, config.getActiveProfiles()); } + ResourceLoader resourceLoader = (application.getResourceLoader() != null + ? application.getResourceLoader() + : new DefaultResourceLoader(getClass().getClassLoader())); TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment, - application.getResourceLoader() == null - ? new DefaultResourceLoader(getClass().getClassLoader()) - : application.getResourceLoader(), - config.getPropertySourceLocations()); + resourceLoader, config.getPropertySourceLocations()); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(environment, getInlinedProperties(config)); application.setEnvironment(environment); diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java index 361bde0f7ef..df3f8a18192 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java @@ -147,8 +147,8 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr WebAppConfiguration webAppConfiguration = AnnotatedElementUtils .findMergedAnnotation(mergedConfig.getTestClass(), WebAppConfiguration.class); - String resourceBasePath = (webAppConfiguration == null ? "src/main/webapp" - : webAppConfiguration.value()); + String resourceBasePath = (webAppConfiguration != null + ? webAppConfiguration.value() : "src/main/webapp"); mergedConfig = new WebMergedContextConfiguration(mergedConfig, resourceBasePath); } @@ -275,17 +275,17 @@ public class SpringBootTestContextBootstrapper extends DefaultTestContextBootstr */ protected WebEnvironment getWebEnvironment(Class testClass) { SpringBootTest annotation = getAnnotation(testClass); - return (annotation == null ? null : annotation.webEnvironment()); + return (annotation != null ? annotation.webEnvironment() : null); } protected Class[] getClasses(Class testClass) { SpringBootTest annotation = getAnnotation(testClass); - return (annotation == null ? null : annotation.classes()); + return (annotation != null ? annotation.classes() : null); } protected String[] getProperties(Class testClass) { SpringBootTest annotation = getAnnotation(testClass); - return (annotation == null ? null : annotation.properties()); + return (annotation != null ? annotation.properties() : null); } protected SpringBootTest getAnnotation(Class testClass) { diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java b/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java index c7fc0c1a3f4..50095cb059b 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java @@ -75,7 +75,7 @@ public final class JsonContent implements AssertProvider { @Override public String toString() { return "JsonContent " + this.json - + (this.type == null ? "" : " created from " + this.type); + + (this.type != null ? " created from " + this.type : ""); } } diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java b/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java index e26d875011d..8e25f6ffca2 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java @@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert resourceLoadClass, Charset charset) { this.resourceLoadClass = resourceLoadClass; - this.charset = charset == null ? Charset.forName("UTF-8") : charset; + this.charset = (charset != null ? charset : Charset.forName("UTF-8")); } Class getResourceLoadClass() { diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java b/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java index 553030553e6..db9c5fb5b21 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java @@ -63,7 +63,7 @@ public final class ObjectContent implements AssertProvider 0 ? index : pair.length()); - String value = index > 0 ? pair.substring(index + 1) : ""; + String value = (index > 0 ? pair.substring(index + 1) : ""); map.put(key.trim(), value.trim()); } } diff --git a/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/AbstractConfigurationMetadataTests.java b/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/AbstractConfigurationMetadataTests.java index 6401178eda0..3ab31bf3f04 100644 --- a/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/AbstractConfigurationMetadataTests.java +++ b/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/AbstractConfigurationMetadataTests.java @@ -50,7 +50,7 @@ public abstract class AbstractConfigurationMetadataTests { assertThat(actual).isNotNull(); assertThat(actual.getId()).isEqualTo(id); assertThat(actual.getName()).isEqualTo(name); - String typeName = type != null ? type.getName() : null; + String typeName = (type != null ? type.getName() : null); assertThat(actual.getType()).isEqualTo(typeName); assertThat(actual.getDefaultValue()).isEqualTo(defaultValue); } diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java index 69afda4abb3..9c0176396dc 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java @@ -327,7 +327,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix, this.typeUtils.getQualifiedName(returnElement), this.typeUtils.getQualifiedName(element), - (getter == null ? null : getter.toString()))); + (getter != null ? getter.toString() : null))); processTypeElement(nestedPrefix, (TypeElement) returnElement, source); } } diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java index 4e6171a7c72..84b1f4a4434 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java @@ -150,8 +150,8 @@ class TypeElementMembers { } private String getAccessorName(String methodName) { - String name = methodName.startsWith("is") ? methodName.substring(2) - : methodName.substring(3); + String name = (methodName.startsWith("is") ? methodName.substring(2) + : methodName.substring(3)); name = Character.toLowerCase(name.charAt(0)) + name.substring(1); return name; } diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java index 54222725e5e..01254f949d3 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java @@ -139,8 +139,8 @@ class TypeUtils { } public String getJavaDoc(Element element) { - String javadoc = (element == null ? null - : this.env.getElementUtils().getDocComment(element)); + String javadoc = (element != null + ? this.env.getElementUtils().getDocComment(element) : null); if (javadoc != null) { javadoc = javadoc.trim(); } diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/Trees.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/Trees.java index 8a525241042..a6122742045 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/Trees.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/Trees.java @@ -35,7 +35,7 @@ final class Trees extends ReflectionWrapper { public Tree getTree(Element element) throws Exception { Object tree = findMethod("getTree", Element.class).invoke(getInstance(), element); - return (tree == null ? null : new Tree(tree)); + return (tree != null ? new Tree(tree) : null); } public static Trees instance(ProcessingEnvironment env) throws Exception { diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.java index c543fc06c82..51b4d655718 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.java @@ -43,7 +43,7 @@ class VariableTree extends ReflectionWrapper { public ExpressionTree getInitializer() throws Exception { Object instance = findMethod("getInitializer").invoke(getInstance()); - return (instance == null ? null : new ExpressionTree(instance)); + return (instance != null ? new ExpressionTree(instance) : null); } @SuppressWarnings("unchecked") diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java index d54cb8ff0cd..bb7f974da29 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java @@ -181,7 +181,7 @@ public class ConfigurationMetadata { } public static String nestedPrefix(String prefix, String name) { - String nestedPrefix = (prefix == null ? "" : prefix); + String nestedPrefix = (prefix != null ? prefix : ""); String dashedName = toDashedCase(name); nestedPrefix += ("".equals(nestedPrefix) ? dashedName : "." + dashedName); return nestedPrefix; diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java index 7b1636c2214..b3a24d613a8 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java @@ -108,7 +108,7 @@ public class ItemDeprecation { } private int nullSafeHashCode(Object o) { - return (o == null ? 0 : o.hashCode()); + return (o != null ? o.hashCode() : 0); } } diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java index d7aa5296454..aec328b41ca 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java @@ -60,11 +60,11 @@ public final class ItemMetadata implements Comparable { while (prefix != null && prefix.endsWith(".")) { prefix = prefix.substring(0, prefix.length() - 1); } - StringBuilder fullName = new StringBuilder(prefix == null ? "" : prefix); + StringBuilder fullName = new StringBuilder(prefix != null ? prefix : ""); if (fullName.length() > 0 && name != null) { fullName.append("."); } - fullName.append(name == null ? "" : ConfigurationMetadata.toDashedCase(name)); + fullName.append(name != null ? ConfigurationMetadata.toDashedCase(name) : ""); return fullName.toString(); } @@ -193,7 +193,7 @@ public final class ItemMetadata implements Comparable { } private int nullSafeHashCode(Object o) { - return (o == null ? 0 : o.hashCode()); + return (o != null ? o.hashCode() : 0); } @Override diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootPluginExtension.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootPluginExtension.java index 0dcc148e9fa..23bd23efabb 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootPluginExtension.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/SpringBootPluginExtension.java @@ -152,7 +152,7 @@ public class SpringBootPluginExtension { * @return the Layout to use or null if not explicitly set */ public Layout convertLayout() { - return (this.layout == null ? null : this.layout.layout); + return (this.layout != null ? this.layout.layout : null); } public String getMainClass() { diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/ProjectLibraries.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/ProjectLibraries.java index a808ab4039e..eea9dc36fee 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/ProjectLibraries.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/ProjectLibraries.java @@ -114,8 +114,8 @@ class ProjectLibraries implements Libraries { private Set getLibraries(String configurationName, LibraryScope scope) { - Configuration configuration = (configurationName == null ? null - : this.project.getConfigurations().findByName(configurationName)); + Configuration configuration = (configurationName != null + ? this.project.getConfigurations().findByName(configurationName) : null); if (configuration == null) { return null; } @@ -321,8 +321,8 @@ class ProjectLibraries implements Libraries { String configurationName = (String) this.getTargetConfiguration .invoke(projectDependency); return projectDependency.getDependencyProject().getConfigurations() - .getByName(configurationName == null - ? Dependency.DEFAULT_CONFIGURATION : configurationName); + .getByName(configurationName != null ? configurationName + : Dependency.DEFAULT_CONFIGURATION); } catch (Exception ex) { throw new RuntimeException("Failed to get target configuration", ex); diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/RepackageTask.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/RepackageTask.java index 09f54ed7416..7eaaf85aabc 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/RepackageTask.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/repackage/RepackageTask.java @@ -145,8 +145,8 @@ public class RepackageTask extends DefaultTask { SpringBootPluginExtension extension = project.getExtensions() .getByType(SpringBootPluginExtension.class); ProjectLibraries libraries = new ProjectLibraries(project, extension, - this.excludeDevtools == null ? extension.isExcludeDevtools() - : this.excludeDevtools); + this.excludeDevtools != null ? this.excludeDevtools + : extension.isExcludeDevtools()); if (extension.getProvidedConfiguration() != null) { libraries.setProvidedConfigurationName(extension.getProvidedConfiguration()); } @@ -293,20 +293,20 @@ public class RepackageTask extends DefaultTask { } private boolean isExecutable() { - return RepackageTask.this.executable != null ? RepackageTask.this.executable - : this.extension.isExecutable(); + return (RepackageTask.this.executable != null ? RepackageTask.this.executable + : this.extension.isExecutable()); } private File getEmbeddedLaunchScript() { - return RepackageTask.this.embeddedLaunchScript != null + return (RepackageTask.this.embeddedLaunchScript != null ? RepackageTask.this.embeddedLaunchScript - : this.extension.getEmbeddedLaunchScript(); + : this.extension.getEmbeddedLaunchScript()); } private Map getEmbeddedLaunchScriptProperties() { - return RepackageTask.this.embeddedLaunchScriptProperties != null + return (RepackageTask.this.embeddedLaunchScriptProperties != null ? RepackageTask.this.embeddedLaunchScriptProperties - : this.extension.getEmbeddedLaunchScriptProperties(); + : this.extension.getEmbeddedLaunchScriptProperties()); } } diff --git a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/run/BootRunTask.java b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/run/BootRunTask.java index 76cc4fd3456..6e5ec413b26 100644 --- a/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/run/BootRunTask.java +++ b/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/run/BootRunTask.java @@ -65,8 +65,8 @@ public class BootRunTask extends JavaExec { private void addResourcesIfNecessary() { if (this.addResources) { SourceSet mainSourceSet = SourceSets.findMainSourceSet(getProject()); - final File outputDir = (mainSourceSet == null ? null - : mainSourceSet.getOutput().getResourcesDir()); + final File outputDir = (mainSourceSet != null + ? mainSourceSet.getOutput().getResourcesDir() : null); final Set resources = new LinkedHashSet(); if (mainSourceSet != null) { resources.addAll(mainSourceSet.getResources().getSrcDirs()); diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java index 552a85b01b9..ad3ddb57c79 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java @@ -95,7 +95,7 @@ public class DefaultLaunchScript implements LaunchScript { value = (String) properties.get(name); } else { - value = (value == null ? matcher.group(0) : value.substring(1)); + value = (value != null ? value.substring(1) : matcher.group(0)); } matcher.appendReplacement(expanded, value.replace("$", "\\$")); } diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java index a0e28c2ebf0..040dc1e141a 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java @@ -332,7 +332,7 @@ public class JarWriter implements LoaderClassesWriter { @Override public int read() throws IOException { - int read = (this.headerStream == null ? -1 : this.headerStream.read()); + int read = (this.headerStream != null ? this.headerStream.read() : -1); if (read != -1) { this.headerStream = null; return read; @@ -347,8 +347,8 @@ public class JarWriter implements LoaderClassesWriter { @Override public int read(byte[] b, int off, int len) throws IOException { - int read = (this.headerStream == null ? -1 - : this.headerStream.read(b, off, len)); + int read = (this.headerStream != null ? this.headerStream.read(b, off, len) + : -1); if (read != -1) { this.headerStream = null; return read; diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java index 0c18dab0829..b8022df6493 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java @@ -63,7 +63,7 @@ public class Library { * @param unpackRequired if the library needs to be unpacked before it can be used */ public Library(String name, File file, LibraryScope scope, boolean unpackRequired) { - this.name = (name == null ? file.getName() : name); + this.name = (name != null ? name : file.getName()); this.file = file; this.scope = scope; this.unpackRequired = unpackRequired; diff --git a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java index 429caa3df8d..820934e9d83 100644 --- a/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java +++ b/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java @@ -516,8 +516,8 @@ public abstract class MainClassFinder { "Unable to find a single main class from the following candidates " + matchingMainClasses); } - return matchingMainClasses.isEmpty() ? null - : matchingMainClasses.iterator().next().getName(); + return (matchingMainClasses.isEmpty() ? null + : matchingMainClasses.iterator().next().getName()); } } diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java index 2b0f106e66d..5d681131a24 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java @@ -116,8 +116,8 @@ public abstract class Launcher { protected final Archive createArchive() throws Exception { ProtectionDomain protectionDomain = getClass().getProtectionDomain(); CodeSource codeSource = protectionDomain.getCodeSource(); - URI location = (codeSource == null ? null : codeSource.getLocation().toURI()); - String path = (location == null ? null : location.getSchemeSpecificPart()); + URI location = (codeSource != null ? codeSource.getLocation().toURI() : null); + String path = (location != null ? location.getSchemeSpecificPart() : null); if (path == null) { throw new IllegalStateException("Unable to determine code source archive"); } diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java index bd6ea870f15..b2672b93fd9 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java @@ -38,7 +38,7 @@ public class MainMethodRunner { */ public MainMethodRunner(String mainClass, String[] args) { this.mainClassName = mainClass; - this.args = (args == null ? null : args.clone()); + this.args = (args != null ? args.clone() : null); } public void run() throws Exception { diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 7962237c2fd..e4b6bdd7144 100755 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -438,8 +438,9 @@ public class PropertiesLauncher extends Launcher { return SystemPropertyUtils.resolvePlaceholders(this.properties, value); } } - return defaultValue == null ? defaultValue - : SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue); + return (defaultValue != null + ? SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue) + : defaultValue); } @Override diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/ByteArrayRandomAccessData.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/ByteArrayRandomAccessData.java index 059fb7a4221..00edb49cc56 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/ByteArrayRandomAccessData.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/ByteArrayRandomAccessData.java @@ -33,11 +33,11 @@ public class ByteArrayRandomAccessData implements RandomAccessData { private final long length; public ByteArrayRandomAccessData(byte[] bytes) { - this(bytes, 0, (bytes == null ? 0 : bytes.length)); + this(bytes, 0, (bytes != null ? bytes.length : 0)); } public ByteArrayRandomAccessData(byte[] bytes, long offset, long length) { - this.bytes = (bytes == null ? new byte[0] : bytes); + this.bytes = (bytes != null ? bytes : new byte[0]); this.offset = offset; this.length = length; } diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java index 687eb1b9b39..8ee6d257139 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java @@ -142,7 +142,7 @@ public class RandomAccessDataFile implements RandomAccessData { @Override public int read(byte[] b) throws IOException { - return read(b, 0, b == null ? 0 : b.length); + return read(b, 0, b != null ? b.length : 0); } @Override @@ -178,7 +178,7 @@ public class RandomAccessDataFile implements RandomAccessData { } if (b == null) { int rtn = file.read(); - moveOn(rtn == -1 ? 0 : 1); + moveOn(rtn != -1 ? 1 : 0); return rtn; } else { diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryFileHeader.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryFileHeader.java index ad63d39a94d..0f7a3020464 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryFileHeader.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryFileHeader.java @@ -103,7 +103,7 @@ final class CentralDirectoryFileHeader implements FileHeader { @Override public boolean hasName(String name, String suffix) { - return this.name.equals(new AsciiBytes(suffix == null ? name : name + suffix)); + return this.name.equals(new AsciiBytes(suffix != null ? name + suffix : name)); } public boolean isDirectory() { diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java index d0a9236ad7e..2137b371fc9 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java @@ -250,7 +250,7 @@ public class Handler extends URLStreamHandler { } private int hashCode(String protocol, String file) { - int result = (protocol == null ? 0 : protocol.hashCode()); + int result = (protocol != null ? protocol.hashCode() : 0); int separatorIndex = file.indexOf(SEPARATOR); if (separatorIndex == -1) { return result + file.hashCode(); @@ -319,7 +319,7 @@ public class Handler extends URLStreamHandler { String path = name.substring(FILE_PROTOCOL.length()); File file = new File(URLDecoder.decode(path, "UTF-8")); Map cache = rootFileCache.get(); - JarFile result = (cache == null ? null : cache.get(file)); + JarFile result = (cache != null ? cache.get(file) : null); if (result == null) { result = new JarFile(file); addToRootFileCache(file, result); diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java index 1fbda8de083..3b5a6b08c01 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java @@ -71,7 +71,7 @@ class JarEntry extends java.util.jar.JarEntry implements FileHeader { @Override public Attributes getAttributes() throws IOException { Manifest manifest = this.jarFile.getManifest(); - return (manifest == null ? null : manifest.getAttributes(getName())); + return (manifest != null ? manifest.getAttributes(getName()) : null); } @Override diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java index 11c1e16fb29..afb9d9bea6b 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java @@ -154,7 +154,7 @@ public class JarFile extends java.util.jar.JarFile { @Override public Manifest getManifest() throws IOException { - Manifest manifest = (this.manifest == null ? null : this.manifest.get()); + Manifest manifest = (this.manifest != null ? this.manifest.get() : null); if (manifest == null) { if (this.type == JarFileType.NESTED_DIRECTORY) { manifest = new JarFile(this.getRootJarFile()).getManifest(); @@ -219,7 +219,7 @@ public class JarFile extends java.util.jar.JarFile { if (ze instanceof JarEntry) { return this.entries.getInputStream((JarEntry) ze, access); } - return getInputStream(ze == null ? null : ze.getName(), access); + return getInputStream((ze != null ? ze.getName() : null), access); } InputStream getInputStream(String name, ResourceAccess access) throws IOException { diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java index 2107c86391a..af2ca23b030 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java @@ -280,7 +280,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable { } private AsciiBytes applyFilter(AsciiBytes name) { - return (this.filter == null ? name : this.filter.apply(name)); + return (this.filter != null ? this.filter.apply(name) : name); } /** diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index b45eb154f72..9c763747a44 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -205,7 +205,7 @@ final class JarURLConnection extends java.net.JarURLConnection { return this.jarFile.size(); } JarEntry entry = getJarEntry(); - return (entry == null ? -1 : (int) entry.getSize()); + return (entry != null ? (int) entry.getSize() : -1); } catch (IOException ex) { return -1; @@ -220,7 +220,7 @@ final class JarURLConnection extends java.net.JarURLConnection { @Override public String getContentType() { - return (this.jarEntryName == null ? null : this.jarEntryName.getContentType()); + return (this.jarEntryName != null ? this.jarEntryName.getContentType() : null); } @Override @@ -242,7 +242,7 @@ final class JarURLConnection extends java.net.JarURLConnection { } try { JarEntry entry = getJarEntry(); - return (entry == null ? 0 : entry.getTime()); + return (entry != null ? entry.getTime() : 0); } catch (IOException ex) { return 0; diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java index b9b949b9076..bc151316940 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java @@ -155,7 +155,7 @@ public abstract class SystemPropertyUtils { if (propVal != null) { return propVal; } - return properties == null ? null : properties.getProperty(placeholderName); + return (properties != null ? properties.getProperty(placeholderName) : null); } public static String getProperty(String key) { @@ -189,8 +189,8 @@ public abstract class SystemPropertyUtils { } if (propVal == null) { // Try uppercase with underscores as well. - propVal = System.getenv(key.toUpperCase(Locale.ENGLISH) - .replace('.', '_')); + propVal = System + .getenv(key.toUpperCase(Locale.ENGLISH).replace('.', '_')); } if (propVal != null) { return propVal; diff --git a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java index 0676e7c2d34..ca6d078ce38 100755 --- a/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java +++ b/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/archive/ExplodedArchiveTests.java @@ -69,9 +69,9 @@ public class ExplodedArchiveTests { File file = this.temporaryFolder.newFile(); TestJarCreator.createTestJar(file); - this.rootFolder = StringUtils.hasText(folderName) + this.rootFolder = (StringUtils.hasText(folderName) ? this.temporaryFolder.newFolder(folderName) - : this.temporaryFolder.newFolder(); + : this.temporaryFolder.newFolder()); JarFile jarFile = new JarFile(file); Enumeration entries = jarFile.entries(); while (entries.hasMoreElements()) { diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index 87a460905d5..680b0c4de41 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -432,8 +432,8 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { private void addDependencies(List urls) throws MalformedURLException, MojoExecutionException { - FilterArtifacts filters = this.useTestClasspath ? getFilters() - : getFilters(new TestArtifactFilter()); + FilterArtifacts filters = (this.useTestClasspath ? getFilters() + : getFilters(new TestArtifactFilter())); Set artifacts = filterDependencies(this.project.getArtifacts(), filters); for (Artifact artifact : artifacts) { @@ -481,7 +481,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { public void uncaughtException(Thread thread, Throwable ex) { if (!(ex instanceof ThreadDeath)) { synchronized (this.monitor) { - this.exception = (this.exception == null ? ex : this.exception); + this.exception = (this.exception != null ? this.exception : ex); } getLog().warn(ex); } diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java index 6215a1deff8..c62230ee222 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java @@ -69,7 +69,7 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer String value = (String) entry.getValue(); String existing = this.data.getProperty(name); this.data.setProperty(name, - existing == null ? value : existing + "," + value); + existing != null ? existing + "," + value : value); } } diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java index ba202760349..00631d9f4e8 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java @@ -223,7 +223,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { } private File getTargetFile() { - String classifier = (this.classifier == null ? "" : this.classifier.trim()); + String classifier = (this.classifier != null ? this.classifier.trim() : ""); if (classifier.length() > 0 && !classifier.startsWith("-")) { classifier = "-" + classifier; } @@ -288,7 +288,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo { } private String removeLineBreaks(String description) { - return (description == null ? null : description.replaceAll("\\s+", " ")); + return (description != null ? description.replaceAll("\\s+", " ") : null); } private void putIfMissing(Properties properties, String key, diff --git a/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/Verify.java b/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/Verify.java index e169faed591..f86781034e8 100644 --- a/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/Verify.java +++ b/spring-boot-tools/spring-boot-maven-plugin/src/test/java/org/springframework/boot/maven/Verify.java @@ -167,7 +167,7 @@ public final class Verify { } - private static abstract class AbstractArchiveVerification { + private abstract static class AbstractArchiveVerification { private final File file; diff --git a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ModifiedClassPathRunner.java b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ModifiedClassPathRunner.java index 7dc2af97cde..db3328ad79b 100644 --- a/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ModifiedClassPathRunner.java +++ b/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/junit/runner/classpath/ModifiedClassPathRunner.java @@ -65,8 +65,8 @@ import org.springframework.util.StringUtils; */ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner { - private static final Pattern INTELLIJ_CLASSPATH_JAR_PATTERN = Pattern.compile( - ".*classpath(\\d+)?.jar"); + private static final Pattern INTELLIJ_CLASSPATH_JAR_PATTERN = Pattern + .compile(".*classpath(\\d+)?.jar"); public ModifiedClassPathRunner(Class testClass) throws InitializationError { super(testClass); @@ -150,8 +150,8 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner { private String[] getClassPath(URL booterJar) throws Exception { Attributes attributes = getManifestMainAttributesFromUrl(booterJar); - return StringUtils.delimitedListToStringArray(attributes - .getValue(Attributes.Name.CLASS_PATH), " "); + return StringUtils.delimitedListToStringArray( + attributes.getValue(Attributes.Name.CLASS_PATH), " "); } private Attributes getManifestMainAttributesFromUrl(URL url) throws Exception { @@ -233,8 +233,8 @@ public class ModifiedClassPathRunner extends BlockJUnit4ClassRunner { private ClassPathEntryFilter(Class testClass) throws Exception { ClassPathExclusions exclusions = AnnotationUtils.findAnnotation(testClass, ClassPathExclusions.class); - this.exclusions = exclusions == null ? Collections.emptyList() - : Arrays.asList(exclusions.value()); + this.exclusions = (exclusions != null ? Arrays.asList(exclusions.value()) + : Collections.emptyList()); } private boolean isExcluded(URL url) throws Exception { diff --git a/spring-boot/src/main/java/org/springframework/boot/ApplicationHome.java b/spring-boot/src/main/java/org/springframework/boot/ApplicationHome.java index 81ea61bcac0..d25d0ca489f 100644 --- a/spring-boot/src/main/java/org/springframework/boot/ApplicationHome.java +++ b/spring-boot/src/main/java/org/springframework/boot/ApplicationHome.java @@ -56,7 +56,7 @@ public class ApplicationHome { * @param sourceClass the source class or {@code null} */ public ApplicationHome(Class sourceClass) { - this.source = findSource(sourceClass == null ? getStartClass() : sourceClass); + this.source = findSource(sourceClass != null ? sourceClass : getStartClass()); this.dir = findHomeDir(this.source); } @@ -95,11 +95,11 @@ public class ApplicationHome { private File findSource(Class sourceClass) { try { - ProtectionDomain domain = (sourceClass == null ? null - : sourceClass.getProtectionDomain()); - CodeSource codeSource = (domain == null ? null : domain.getCodeSource()); - URL location = (codeSource == null ? null : codeSource.getLocation()); - File source = (location == null ? null : findSource(location)); + ProtectionDomain domain = (sourceClass != null + ? sourceClass.getProtectionDomain() : null); + CodeSource codeSource = (domain != null ? domain.getCodeSource() : null); + URL location = (codeSource != null ? codeSource.getLocation() : null); + File source = (location != null ? findSource(location) : null); if (source != null && source.exists() && !isUnitTest()) { return source.getAbsoluteFile(); } @@ -142,7 +142,7 @@ public class ApplicationHome { private File findHomeDir(File source) { File homeDir = source; - homeDir = (homeDir == null ? findDefaultHomeDir() : homeDir); + homeDir = (homeDir != null ? homeDir : findDefaultHomeDir()); if (homeDir.isFile()) { homeDir = homeDir.getParentFile(); } diff --git a/spring-boot/src/main/java/org/springframework/boot/ApplicationPid.java b/spring-boot/src/main/java/org/springframework/boot/ApplicationPid.java index f35d5f0541c..23ba504d7e9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/ApplicationPid.java +++ b/spring-boot/src/main/java/org/springframework/boot/ApplicationPid.java @@ -53,7 +53,7 @@ public class ApplicationPid { @Override public String toString() { - return (this.pid == null ? "???" : this.pid); + return (this.pid != null ? this.pid : "???"); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java b/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java index 5b5817724db..66f17181593 100644 --- a/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java +++ b/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java @@ -62,7 +62,7 @@ public class DefaultApplicationArguments implements ApplicationArguments { @Override public List getOptionValues(String name) { List values = this.source.getOptionValues(name); - return (values == null ? null : Collections.unmodifiableList(values)); + return (values != null ? Collections.unmodifiableList(values) : null); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java b/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java index 866595febf1..c13744a6aab 100644 --- a/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java +++ b/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java @@ -93,7 +93,7 @@ class ExitCodeGenerators implements Iterable { } } catch (Exception ex) { - exitCode = (exitCode == 0 ? 1 : exitCode); + exitCode = (exitCode != 0 ? exitCode : 1); ex.printStackTrace(); } } diff --git a/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java b/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java index c2d1d797b20..0795c2fe54b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java +++ b/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java @@ -106,8 +106,8 @@ public class ResourceBanner implements Banner { } protected String getApplicationVersion(Class sourceClass) { - Package sourcePackage = (sourceClass == null ? null : sourceClass.getPackage()); - return (sourcePackage == null ? null : sourcePackage.getImplementationVersion()); + Package sourcePackage = (sourceClass != null ? sourceClass.getPackage() : null); + return (sourcePackage != null ? sourcePackage.getImplementationVersion() : null); } protected String getBootVersion() { @@ -131,14 +131,14 @@ public class ResourceBanner implements Banner { MutablePropertySources sources = new MutablePropertySources(); String applicationTitle = getApplicationTitle(sourceClass); Map titleMap = Collections.singletonMap( - "application.title", (applicationTitle == null ? "" : applicationTitle)); + "application.title", (applicationTitle != null ? applicationTitle : "")); sources.addFirst(new MapPropertySource("title", titleMap)); return new PropertySourcesPropertyResolver(sources); } protected String getApplicationTitle(Class sourceClass) { - Package sourcePackage = (sourceClass == null ? null : sourceClass.getPackage()); - return (sourcePackage == null ? null : sourcePackage.getImplementationTitle()); + Package sourcePackage = (sourceClass != null ? sourceClass.getPackage() : null); + return (sourcePackage != null ? sourcePackage.getImplementationTitle() : null); } } diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index eb33939e4f2..9a438be7fc7 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -495,8 +495,8 @@ public class SpringApplication { if (this.bannerMode == Banner.Mode.OFF) { return null; } - ResourceLoader resourceLoader = this.resourceLoader != null ? this.resourceLoader - : new DefaultResourceLoader(getClassLoader()); + ResourceLoader resourceLoader = (this.resourceLoader != null ? this.resourceLoader + : new DefaultResourceLoader(getClassLoader())); SpringApplicationBannerPrinter bannerPrinter = new SpringApplicationBannerPrinter( resourceLoader, this.banner); if (this.bannerMode == Mode.LOG) { @@ -1167,7 +1167,7 @@ public class SpringApplication { } catch (Exception ex) { ex.printStackTrace(); - exitCode = (exitCode == 0 ? 1 : exitCode); + exitCode = (exitCode != 0 ? exitCode : 1); } return exitCode; } diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java index cea4d5f3147..7c2c71568a8 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java @@ -163,7 +163,7 @@ class SpringApplicationBannerPrinter { @Override public void printBanner(Environment environment, Class sourceClass, PrintStream out) { - sourceClass = (sourceClass == null ? this.sourceClass : sourceClass); + sourceClass = (sourceClass != null ? sourceClass : this.sourceClass); this.banner.printBanner(environment, sourceClass, out); } diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java b/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java index f6fc9e7179a..ded43d409da 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java @@ -87,7 +87,7 @@ class SpringApplicationRunListeners { } else { String message = ex.getMessage(); - message = (message == null ? "no error message" : message); + message = (message != null ? message : "no error message"); this.log.warn("Error handling failed (" + message + ")"); } } diff --git a/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java b/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java index 2cf91591f13..08aa293914b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java @@ -49,7 +49,7 @@ class SpringBootBanner implements Banner { printStream.println(line); } String version = SpringBootVersion.getVersion(); - version = (version == null ? "" : " (v" + version + ")"); + version = (version != null ? " (v" + version + ")" : ""); String padding = ""; while (padding.length() < STRAP_LINE_SIZE - (version.length() + SPRING_BOOT.length())) { diff --git a/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java b/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java index ddc995a3925..7ad308578d8 100644 --- a/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java +++ b/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java @@ -140,8 +140,8 @@ class StartupInfoLogger { } }); ApplicationHome home = new ApplicationHome(this.sourceClass); - String path = (home.getSource() == null ? "" - : home.getSource().getAbsolutePath()); + String path = (home.getSource() != null ? home.getSource().getAbsolutePath() + : ""); if (startedBy == null && path == null) { return ""; } diff --git a/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java b/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java index 7a562a5503d..bc71c3da0f9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java +++ b/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java @@ -94,7 +94,7 @@ public final class AnsiColors { private final double b; LabColor(Integer rgb) { - this(rgb == null ? (Color) null : new Color(rgb)); + this(rgb != null ? new Color(rgb) : (Color) null); } LabColor(Color color) { diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/OriginCapablePropertyValue.java b/spring-boot/src/main/java/org/springframework/boot/bind/OriginCapablePropertyValue.java index cb1d96599da..da405c02f1f 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/OriginCapablePropertyValue.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/OriginCapablePropertyValue.java @@ -52,9 +52,9 @@ class OriginCapablePropertyValue extends PropertyValue { @Override public String toString() { - String name = this.origin != null ? this.origin.getName() : this.getName(); - String source = this.origin.getSource() != null - ? this.origin.getSource().getName() : "unknown"; + String name = (this.origin != null ? this.origin.getName() : this.getName()); + String source = (this.origin.getSource() != null + ? this.origin.getSource().getName() : "unknown"); return "'" + name + "' from '" + source + "'"; } diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/PatternPropertyNamePatternsMatcher.java b/spring-boot/src/main/java/org/springframework/boot/bind/PatternPropertyNamePatternsMatcher.java index 390947fc64b..cd7a348ce6b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PatternPropertyNamePatternsMatcher.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PatternPropertyNamePatternsMatcher.java @@ -32,8 +32,8 @@ class PatternPropertyNamePatternsMatcher implements PropertyNamePatternsMatcher private final String[] patterns; PatternPropertyNamePatternsMatcher(Collection patterns) { - this.patterns = (patterns == null ? new String[] {} - : patterns.toArray(new String[patterns.size()])); + this.patterns = (patterns != null ? patterns.toArray(new String[patterns.size()]) + : new String[] {}); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourceUtils.java b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourceUtils.java index e7449add665..d359cd633e0 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourceUtils.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PropertySourceUtils.java @@ -77,7 +77,7 @@ public abstract class PropertySourceUtils { private static String getSubKey(String name, String rootPrefixes, RelaxedNames keyPrefix) { - rootPrefixes = (rootPrefixes == null ? "" : rootPrefixes); + rootPrefixes = (rootPrefixes != null ? rootPrefixes : ""); for (String rootPrefix : new RelaxedNames(rootPrefixes)) { for (String candidateKeyPrefix : keyPrefix) { if (name.startsWith(rootPrefix + candidateKeyPrefix)) { diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedDataBinder.java b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedDataBinder.java index fc1ca4133a4..7c642d6dbe3 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedDataBinder.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedDataBinder.java @@ -385,7 +385,7 @@ public class RelaxedDataBinder extends DataBinder { if (propertyName == null) { propertyName = resolveNestedPropertyName(target, prefix, name); } - return (propertyName == null ? name : propertyName); + return (propertyName != null ? propertyName : name); } private String resolveNestedPropertyName(BeanWrapper target, String prefix, @@ -712,7 +712,7 @@ public class RelaxedDataBinder extends DataBinder { } private boolean isBenign(PropertyOrigin origin) { - String name = (origin == null ? null : origin.getSource().getName()); + String name = (origin != null ? origin.getSource().getName() : null); return BENIGN_PROPERTY_SOURCE_NAMES.contains(name); } diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java index afc4245c53e..282eee70b85 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedNames.java @@ -50,7 +50,7 @@ public final class RelaxedNames implements Iterable { * using dashed notation (e.g. {@literal my-property-name} */ public RelaxedNames(String name) { - this.name = (name == null ? "" : name); + this.name = (name != null ? name : ""); initialize(RelaxedNames.this.name, this.values); } @@ -92,7 +92,7 @@ public final class RelaxedNames implements Iterable { @Override public String apply(String value) { - return value.isEmpty() ? value : value.toLowerCase(Locale.ENGLISH); + return (value.isEmpty() ? value : value.toLowerCase(Locale.ENGLISH)); } }, @@ -101,7 +101,7 @@ public final class RelaxedNames implements Iterable { @Override public String apply(String value) { - return value.isEmpty() ? value : value.toUpperCase(Locale.ENGLISH); + return (value.isEmpty() ? value : value.toUpperCase(Locale.ENGLISH)); } }; @@ -128,7 +128,7 @@ public final class RelaxedNames implements Iterable { @Override public String apply(String value) { - return value.indexOf('-') != -1 ? value.replace('-', '_') : value; + return (value.indexOf('-') != -1 ? value.replace('-', '_') : value); } }, @@ -137,7 +137,7 @@ public final class RelaxedNames implements Iterable { @Override public String apply(String value) { - return value.indexOf('_') != -1 ? value.replace('_', '.') : value; + return (value.indexOf('_') != -1 ? value.replace('_', '.') : value); } }, @@ -146,7 +146,7 @@ public final class RelaxedNames implements Iterable { @Override public String apply(String value) { - return value.indexOf('.') != -1 ? value.replace('.', '_') : value; + return (value.indexOf('.') != -1 ? value.replace('.', '_') : value); } }, @@ -228,7 +228,7 @@ public final class RelaxedNames implements Iterable { for (String field : SEPARATED_TO_CAMEL_CASE_PATTERN.split(value)) { field = (caseInsensitive ? field.toLowerCase(Locale.ENGLISH) : field); builder.append( - builder.length() == 0 ? field : StringUtils.capitalize(field)); + builder.length() != 0 ? StringUtils.capitalize(field) : field); } char lastChar = value.charAt(value.length() - 1); for (char suffix : SUFFIXES) { diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedPropertyResolver.java b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedPropertyResolver.java index 37bd3412c10..c86f2079a4a 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedPropertyResolver.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/RelaxedPropertyResolver.java @@ -43,7 +43,7 @@ public class RelaxedPropertyResolver implements PropertyResolver { public RelaxedPropertyResolver(PropertyResolver resolver, String prefix) { Assert.notNull(resolver, "PropertyResolver must not be null"); this.resolver = resolver; - this.prefix = (prefix == null ? "" : prefix); + this.prefix = (prefix != null ? prefix : ""); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/bind/YamlJavaBeanPropertyConstructor.java b/spring-boot/src/main/java/org/springframework/boot/bind/YamlJavaBeanPropertyConstructor.java index dabd103dd76..c0eea246b30 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/YamlJavaBeanPropertyConstructor.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/YamlJavaBeanPropertyConstructor.java @@ -87,8 +87,8 @@ public class YamlJavaBeanPropertyConstructor extends Constructor { throws IntrospectionException { Map forType = YamlJavaBeanPropertyConstructor.this.properties .get(type); - Property property = (forType == null ? null : forType.get(name)); - return (property == null ? super.getProperty(type, name) : property); + Property property = (forType != null ? forType.get(name) : null); + return (property != null ? property : super.getProperty(type, name)); } } diff --git a/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java b/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index 909ad0fff84..f90d55aaf06 100644 --- a/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java +++ b/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java @@ -390,7 +390,7 @@ public class SpringApplicationBuilder { for (String property : properties) { int index = lowestIndexOf(property, ":", "="); String key = property.substring(0, index > 0 ? index : property.length()); - String value = index > 0 ? property.substring(index + 1) : ""; + String value = (index > 0 ? property.substring(index + 1) : ""); map.put(key, value); } return map; @@ -401,7 +401,7 @@ public class SpringApplicationBuilder { for (String candidate : candidates) { int candidateIndex = property.indexOf(candidate); if (candidateIndex > 0) { - index = (index == -1 ? candidateIndex : Math.min(index, candidateIndex)); + index = (index != -1 ? Math.min(index, candidateIndex) : candidateIndex); } } return index; diff --git a/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java index d01953d0162..d0cb06b130a 100644 --- a/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java @@ -225,7 +225,7 @@ public class CloudFoundryVcapEnvironmentPostProcessor properties.put(key, value.toString()); } else { - properties.put(key, value == null ? "" : value); + properties.put(key, value != null ? value : ""); } } } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index ee50c48d6be..bf0e8cfe071 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -344,8 +344,8 @@ public class ConfigFileApplicationListener Loader(ConfigurableEnvironment environment, ResourceLoader resourceLoader) { this.environment = environment; - this.resourceLoader = resourceLoader == null ? new DefaultResourceLoader() - : resourceLoader; + this.resourceLoader = (resourceLoader != null ? resourceLoader + : new DefaultResourceLoader()); } public void load() { @@ -437,7 +437,7 @@ public class ConfigFileApplicationListener } private void load(String location, String name, Profile profile) { - String group = "profile=" + (profile == null ? "" : profile); + String group = "profile=" + (profile != null ? profile : ""); if (!StringUtils.hasText(name)) { // Try to load directly from the location loadIntoGroup(group, location, profile); @@ -488,7 +488,7 @@ public class ConfigFileApplicationListener String name = "applicationConfig: [" + location + "]"; String group = "applicationConfig: [" + identifier + "]"; propertySource = this.propertiesLoader.load(resource, group, name, - (profile == null ? null : profile.getName())); + (profile != null ? profile.getName() : null)); if (propertySource != null) { msg.append("Loaded "); handleProfileProperties(propertySource); diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactory.java index 64611d12235..83f58080193 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactory.java @@ -73,11 +73,11 @@ public abstract class AbstractEmbeddedServletContainerFactory protected final File getValidDocumentRoot() { File file = getDocumentRoot(); // If document root not explicitly set see if we are running from a war archive - file = file != null ? file : getWarFileDocumentRoot(); + file = (file != null ? file : getWarFileDocumentRoot()); // If not a war archive maybe it is an exploded war - file = file != null ? file : getExplodedWarFileDocumentRoot(); + file = (file != null ? file : getExplodedWarFileDocumentRoot()); // Or maybe there is a document root in a well-known location - file = file != null ? file : getCommonDocumentRoot(); + file = (file != null ? file : getCommonDocumentRoot()); if (file == null && this.logger.isDebugEnabled()) { this.logger .debug("None of the document roots " + Arrays.asList(COMMON_DOC_ROOTS) @@ -225,7 +225,7 @@ public abstract class AbstractEmbeddedServletContainerFactory File getCodeSourceArchive(CodeSource codeSource) { try { - URL location = (codeSource == null ? null : codeSource.getLocation()); + URL location = (codeSource != null ? codeSource.getLocation() : null); if (location == null) { return null; } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/MimeMappings.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/MimeMappings.java index f390ca3970f..6a86d447af6 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/MimeMappings.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/MimeMappings.java @@ -282,7 +282,7 @@ public final class MimeMappings implements Iterable { */ public String add(String extension, String mimeType) { Mapping previous = this.map.put(extension, new Mapping(extension, mimeType)); - return (previous == null ? null : previous.getMimeType()); + return (previous != null ? previous.getMimeType() : null); } /** @@ -292,7 +292,7 @@ public final class MimeMappings implements Iterable { */ public String get(String extension) { Mapping mapping = this.map.get(extension); - return (mapping == null ? null : mapping.getMimeType()); + return (mapping != null ? mapping.getMimeType() : null); } /** @@ -302,7 +302,7 @@ public final class MimeMappings implements Iterable { */ public String remove(String extension) { Mapping previous = this.map.remove(extension); - return (previous == null ? null : previous.getMimeType()); + return (previous != null ? previous.getMimeType() : null); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java index fa2d97b2994..e3dc03c76c2 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainer.java @@ -169,7 +169,7 @@ public class JettyEmbeddedServletContainer implements EmbeddedServletContainer { private String getActualPortsDescription() { StringBuilder ports = new StringBuilder(); for (Connector connector : this.server.getConnectors()) { - ports.append(ports.length() == 0 ? "" : ", "); + ports.append(ports.length() != 0 ? ", " : ""); ports.append(getLocalPort(connector) + getProtocols(connector)); } return ports.toString(); diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java index fe1a0f2e0a1..8f83eb8fd9d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java @@ -404,7 +404,7 @@ public class JettyEmbeddedServletContainerFactory private File getTempDirectory() { String temp = System.getProperty("java.io.tmpdir"); - return (temp == null ? null : new File(temp)); + return (temp != null ? new File(temp) : null); } private void configureDocumentRoot(WebAppContext handler) { diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/SkipPatternJarScanner.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/SkipPatternJarScanner.java index b3edc4bd520..0643e4df31b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/SkipPatternJarScanner.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/SkipPatternJarScanner.java @@ -71,7 +71,7 @@ class SkipPatternJarScanner extends StandardJarScanner { Assert.notNull(scanMethod, "Unable to find scan method"); try { scanMethod.invoke(this.jarScanner, context, classloader, callback, - (jarsToSkip == null ? this.patterns : jarsToSkip)); + (jarsToSkip != null ? jarsToSkip : this.patterns)); } catch (Exception ex) { throw new IllegalStateException("Tomcat 7 reflection failed", ex); diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java index 829c7c40032..bc70b39a92d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainer.java @@ -329,7 +329,7 @@ public class TomcatEmbeddedServletContainer implements EmbeddedServletContainer private String getPortsDescription(boolean localPort) { StringBuilder ports = new StringBuilder(); for (Connector connector : this.tomcat.getService().findConnectors()) { - ports.append(ports.length() == 0 ? "" : " "); + ports.append(ports.length() != 0 ? " " : ""); int port = (localPort ? connector.getLocalPort() : connector.getPort()); ports.append(port + " (" + connector.getScheme() + ")"); } diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java index a2b156001c0..9e79f3fee7d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java @@ -47,7 +47,7 @@ public class TomcatEmbeddedWebappClassLoader extends WebappClassLoader { public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { Class result = findExistingLoadedClass(name); - result = (result == null ? doLoadClass(name) : result); + result = (result != null ? result : doLoadClass(name)); if (result == null) { throw new ClassNotFoundException(name); } @@ -56,7 +56,7 @@ public class TomcatEmbeddedWebappClassLoader extends WebappClassLoader { private Class findExistingLoadedClass(String name) { Class resultClass = findLoadedClass0(name); - resultClass = (resultClass == null ? findLoadedClass(name) : resultClass); + resultClass = (resultClass != null ? resultClass : findLoadedClass(name)); return resultClass; } @@ -64,10 +64,10 @@ public class TomcatEmbeddedWebappClassLoader extends WebappClassLoader { checkPackageAccess(name); if ((this.delegate || filter(name, true))) { Class result = loadFromParent(name); - return (result == null ? findClassIgnoringNotFound(name) : result); + return (result != null ? result : findClassIgnoringNotFound(name)); } Class result = findClassIgnoringNotFound(name); - return (result == null ? loadFromParent(name) : result); + return (result != null ? result : loadFromParent(name)); } private Class resolveIfNecessary(Class resultClass, boolean resolve) { diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainer.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainer.java index 093a692ff59..ebd424eed93 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainer.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainer.java @@ -287,8 +287,8 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine private Port getPortFromChannel(BoundChannel channel) { SocketAddress socketAddress = channel.getLocalAddress(); if (socketAddress instanceof InetSocketAddress) { - String protocol = ReflectionUtils.findField(channel.getClass(), "ssl") != null - ? "https" : "http"; + String protocol = (ReflectionUtils.findField(channel.getClass(), + "ssl") != null ? "https" : "http"); return new Port(((InetSocketAddress) socketAddress).getPort(), protocol); } return null; diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java index 7d3fa84a3f6..7bb9d1d7b75 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactory.java @@ -371,13 +371,13 @@ public class UndertowEmbeddedServletContainerFactory private KeyStore loadKeyStore(String type, String resource, String password) throws Exception { - type = (type == null ? "JKS" : type); + type = (type != null ? type : "JKS"); if (resource == null) { return null; } KeyStore store = KeyStore.getInstance(type); URL url = ResourceUtils.getURL(resource); - store.load(url.openStream(), password == null ? null : password.toCharArray()); + store.load(url.openStream(), password != null ? password.toCharArray() : null); return store; } @@ -435,8 +435,8 @@ public class UndertowEmbeddedServletContainerFactory AccessLogReceiver accessLogReceiver = new DefaultAccessLogReceiver( createWorker(), this.accessLogDirectory, prefix, this.accessLogSuffix, this.accessLogRotate); - String formatString = (this.accessLogPattern != null) ? this.accessLogPattern - : "common"; + String formatString = (this.accessLogPattern != null ? this.accessLogPattern + : "common"); return new AccessLogHandler(handler, accessLogReceiver, formatString, Undertow.class.getClassLoader()); } @@ -489,8 +489,8 @@ public class UndertowEmbeddedServletContainerFactory List metaInfResourceUrls = getUrlsOfJarsWithMetaInfResources(); List resourceJarUrls = new ArrayList(); List resourceManagers = new ArrayList(); - ResourceManager rootResourceManager = root.isDirectory() - ? new FileResourceManager(root, 0) : new JarResourceManager(root); + ResourceManager rootResourceManager = (root.isDirectory() + ? new FileResourceManager(root, 0) : new JarResourceManager(root)); resourceManagers.add(rootResourceManager); for (URL url : metaInfResourceUrls) { if ("file".equals(url.getProtocol())) { diff --git a/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetaData.java b/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetaData.java index 67aa3b0e5a8..584cedbbbfb 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetaData.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetaData.java @@ -71,7 +71,7 @@ public class ConfigurationBeanFactoryMetaData implements BeanFactoryPostProcesso public A findFactoryAnnotation(String beanName, Class type) { Method method = findFactoryMethod(beanName); - return (method == null ? null : AnnotationUtils.findAnnotation(method, type)); + return (method != null ? AnnotationUtils.findAnnotation(method, type) : null); } private Method findFactoryMethod(String beanName) { diff --git a/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java index be56d2db7fc..391ba7f0e4c 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java @@ -316,8 +316,8 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc factory.setValidator(determineValidator(bean)); // If no explicit conversion service is provided we add one so that (at least) // comma-separated arrays of convertibles can be bound automatically - factory.setConversionService(this.conversionService == null - ? getDefaultConversionService() : this.conversionService); + factory.setConversionService(this.conversionService != null + ? this.conversionService : getDefaultConversionService()); if (annotation != null) { factory.setIgnoreInvalidFields(annotation.ignoreInvalidFields()); factory.setIgnoreUnknownFields(annotation.ignoreUnknownFields()); diff --git a/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java b/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java index 35a25b209ff..2cb0787f6ed 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java @@ -50,8 +50,8 @@ class EnableConfigurationPropertiesImportSelector implements ImportSelector { public String[] selectImports(AnnotationMetadata metadata) { MultiValueMap attributes = metadata.getAllAnnotationAttributes( EnableConfigurationProperties.class.getName(), false); - Object[] type = attributes == null ? null - : (Object[]) attributes.getFirst("value"); + Object[] type = (attributes != null ? (Object[]) attributes.getFirst("value") + : null); if (type == null || type.length == 0) { return new String[] { ConfigurationPropertiesBindingPostProcessorRegistrar.class diff --git a/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java b/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java index cc22ee27daa..8a760af6c3f 100644 --- a/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java +++ b/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java @@ -65,7 +65,7 @@ public final class FailureAnalyzers { FailureAnalyzers(ConfigurableApplicationContext context, ClassLoader classLoader) { Assert.notNull(context, "Context must not be null"); - this.classLoader = (classLoader == null ? context.getClassLoader() : classLoader); + this.classLoader = (classLoader != null ? classLoader : context.getClassLoader()); this.analyzers = loadFailureAnalyzers(this.classLoader); prepareFailureAnalyzers(this.analyzers, context); } diff --git a/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java b/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java index 39cc45163c8..1929213f4db 100644 --- a/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java +++ b/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java @@ -57,7 +57,7 @@ class BeanCurrentlyInCreationFailureAnalyzer if (index == -1) { beansInCycle.add(beanInCycle); } - cycleStart = (cycleStart == -1 ? index : cycleStart); + cycleStart = (cycleStart != -1 ? cycleStart : index); } candidate = candidate.getCause(); } @@ -82,7 +82,7 @@ class BeanCurrentlyInCreationFailureAnalyzer String leftSide = (i < cycleStart ? " " : "↑"); message.append(String.format("%s ↓%n", leftSide)); } - String leftSide = i < cycleStart ? " " : "|"; + String leftSide = (i < cycleStart ? " " : "|"); message.append(String.format("%s %s%n", leftSide, beanInCycle)); } message.append(String.format("└─────┘%n")); diff --git a/spring-boot/src/main/java/org/springframework/boot/env/PropertySourcesLoader.java b/spring-boot/src/main/java/org/springframework/boot/env/PropertySourcesLoader.java index 9de866c0d97..529a6069636 100644 --- a/spring-boot/src/main/java/org/springframework/boot/env/PropertySourcesLoader.java +++ b/spring-boot/src/main/java/org/springframework/boot/env/PropertySourcesLoader.java @@ -141,7 +141,7 @@ public class PropertySourcesLoader { } private String generatePropertySourceName(String name, String profile) { - return (profile == null ? name : name + "#" + profile); + return (profile != null ? name + "#" + profile : name); } private boolean canLoadFileExtension(PropertySourceLoader loader, Resource resource) { diff --git a/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java index cea6ffb64cf..3a327efbe1d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java @@ -109,7 +109,7 @@ public class SpringApplicationJsonEnvironmentPostProcessor private void flatten(String prefix, Map result, Map map) { - prefix = (prefix == null ? "" : prefix + "."); + prefix = (prefix != null ? prefix + "." : ""); for (Map.Entry entry : map.entrySet()) { extract(prefix + entry.getKey(), result, entry.getValue()); } diff --git a/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java index dc2ba8587a2..32c8a41c533 100644 --- a/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java @@ -102,7 +102,7 @@ public class AtomikosDependsOnBeanFactoryPostProcessor } private List asList(String[] array) { - return (array == null ? Collections.emptyList() : Arrays.asList(array)); + return (array != null ? Arrays.asList(array) : Collections.emptyList()); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java b/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java index f1f59de15b9..bb90f69be1e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java @@ -63,7 +63,7 @@ public class SimpleFormatter extends Formatter { private String getThreadName() { String name = Thread.currentThread().getName(); - return (name == null ? "" : name); + return (name != null ? name : ""); } private static String getOrUseDefault(String key, String defaultValue) { diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java b/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java index e3fc67029c6..aaa9648cb14 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java @@ -101,7 +101,7 @@ public final class ColorConverter extends LogEventPatternConverter { } PatternParser parser = PatternLayout.createPatternParser(config); List formatters = parser.parse(options[0]); - AnsiElement element = (options.length == 1 ? null : ELEMENTS.get(options[1])); + AnsiElement element = (options.length != 1 ? ELEMENTS.get(options[1]) : null); return new ColorConverter(formatters, element); } @@ -126,7 +126,7 @@ public final class ColorConverter extends LogEventPatternConverter { if (element == null) { // Assume highlighting element = LEVELS.get(event.getLevel().intLevel()); - element = (element == null ? AnsiColor.GREEN : element); + element = (element != null ? element : AnsiColor.GREEN); } appendAnsiString(toAppendTo, buf.toString(), element); } diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java index 3d5421e01bc..ed5af1338ae 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java @@ -67,7 +67,7 @@ public class ColorConverter extends CompositeConverter { if (element == null) { // Assume highlighting element = LEVELS.get(event.getLevel().toInteger()); - element = (element == null ? AnsiColor.GREEN : element); + element = (element != null ? element : AnsiColor.GREEN); } return toAnsiString(in, element); } diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java index a08ef6efff3..2da892d4b79 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LevelRemappingAppender.java @@ -68,7 +68,7 @@ public class LevelRemappingAppender extends AppenderBase { protected void append(ILoggingEvent event) { AppendableLogger logger = getLogger(this.destinationLogger); Level remapped = this.remapLevels.get(event.getLevel()); - logger.callAppenders(remapped == null ? event : new RemappedLoggingEvent(event)); + logger.callAppenders(remapped != null ? new RemappedLoggingEvent(event) : event); } protected AppendableLogger getLogger(String name) { @@ -140,7 +140,7 @@ public class LevelRemappingAppender extends AppenderBase { public Level getLevel() { Level remappedLevel = LevelRemappingAppender.this.remapLevels .get(this.event.getLevel()); - return (remappedLevel == null ? this.event.getLevel() : remappedLevel); + return (remappedLevel != null ? remappedLevel : this.event.getLevel()); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPidFileWriter.java b/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPidFileWriter.java index 68484c02945..58097b83b77 100644 --- a/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPidFileWriter.java +++ b/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPidFileWriter.java @@ -164,7 +164,7 @@ public class ApplicationPidFileWriter private boolean failOnWriteError(SpringApplicationEvent event) { String value = getProperty(event, FAIL_ON_WRITE_ERROR_PROPERTIES); - return (value == null ? false : Boolean.parseBoolean(value)); + return (value != null ? Boolean.parseBoolean(value) : false); } private String getProperty(SpringApplicationEvent event, List candidates) { diff --git a/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java b/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java index f27c972a1da..8799e46b29f 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java @@ -618,14 +618,14 @@ public class RestTemplateBuilder { private Set append(Set set, T addition) { Set result = new LinkedHashSet( - set == null ? Collections.emptySet() : set); + set != null ? set : Collections.emptySet()); result.add(addition); return Collections.unmodifiableSet(result); } private Set append(Set set, Collection additions) { Set result = new LinkedHashSet( - set == null ? Collections.emptySet() : set); + set != null ? set : Collections.emptySet()); result.addAll(additions); return Collections.unmodifiableSet(result); } diff --git a/spring-boot/src/main/java/org/springframework/boot/web/servlet/ErrorPage.java b/spring-boot/src/main/java/org/springframework/boot/web/servlet/ErrorPage.java index 7a21ca77fc3..c4bf8ddf091 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/servlet/ErrorPage.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/servlet/ErrorPage.java @@ -84,7 +84,7 @@ public class ErrorPage { * @return the status value (or 0 for a page that matches any status) */ public int getStatusCode() { - return (this.status == null ? 0 : this.status.value()); + return (this.status != null ? this.status.value() : 0); } /** @@ -92,7 +92,7 @@ public class ErrorPage { * @return the exception type name (or {@code null} if there is none) */ public String getExceptionName() { - return (this.exception == null ? null : this.exception.getName()); + return (this.exception != null ? this.exception.getName() : null); } /** diff --git a/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java b/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java index 3ee21b054d2..5b7ab77758f 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java @@ -278,7 +278,7 @@ public class ServletContextInitializerBeans @Override public RegistrationBean createRegistrationBean(String name, Servlet source, int totalNumberOfSourceBeans) { - String url = (totalNumberOfSourceBeans == 1 ? "/" : "/" + name + "/"); + String url = (totalNumberOfSourceBeans != 1 ? "/" + name + "/" : "/"); if (name.equals(DISPATCHER_SERVLET_NAME)) { url = "/"; // always map the main dispatcherServlet to "/" } diff --git a/spring-boot/src/main/java/org/springframework/boot/web/support/ErrorPageFilter.java b/spring-boot/src/main/java/org/springframework/boot/web/support/ErrorPageFilter.java index b1f58789c3e..d4c9102fd15 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/support/ErrorPageFilter.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/support/ErrorPageFilter.java @@ -196,7 +196,7 @@ public class ErrorPageFilter implements Filter, ErrorPageRegistry { */ protected String getDescription(HttpServletRequest request) { return "[" + request.getServletPath() - + (request.getPathInfo() == null ? "" : request.getPathInfo()) + "]"; + + (request.getPathInfo() != null ? request.getPathInfo() : "") + "]"; } private void handleCommittedResponse(HttpServletRequest request, Throwable ex) { diff --git a/spring-boot/src/main/java/org/springframework/boot/yaml/SpringProfileDocumentMatcher.java b/spring-boot/src/main/java/org/springframework/boot/yaml/SpringProfileDocumentMatcher.java index 5fe82aa0e3e..05ca45b3647 100644 --- a/spring-boot/src/main/java/org/springframework/boot/yaml/SpringProfileDocumentMatcher.java +++ b/spring-boot/src/main/java/org/springframework/boot/yaml/SpringProfileDocumentMatcher.java @@ -95,9 +95,10 @@ public class SpringProfileDocumentMatcher implements DocumentMatcher { } private ProfilesMatcher getProfilesMatcher() { - return this.activeProfiles.length == 0 ? new EmptyProfilesMatcher() - : new ActiveProfilesMatcher( - new HashSet(Arrays.asList(this.activeProfiles))); + return (this.activeProfiles.length != 0 + ? new ActiveProfilesMatcher( + new HashSet(Arrays.asList(this.activeProfiles))) + : new EmptyProfilesMatcher()); } private Set extractProfiles(List profiles, ProfileType type) { @@ -111,8 +112,8 @@ public class SpringProfileDocumentMatcher implements DocumentMatcher { candidateType = ProfileType.NEGATIVE; } if (candidateType == type) { - extractedProfiles.add(type == ProfileType.POSITIVE ? candidate - : candidate.substring(1)); + extractedProfiles.add(type != ProfileType.POSITIVE + ? candidate.substring(1) : candidate); } } return extractedProfiles; diff --git a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index b358a836ed2..8b778871378 100644 --- a/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -1283,7 +1283,7 @@ public class SpringApplicationTests { @Override public Resource getResource(String path) { Resource resource = this.resources.get(path); - return (resource == null ? new ClassPathResource("doesnotexist") : resource); + return (resource != null ? resource : new ClassPathResource("doesnotexist")); } @Override diff --git a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java index 27a439cb5b7..52ea6ecf655 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java @@ -469,7 +469,7 @@ public class ConfigFileApplicationListenerTests { } private String createLogForProfile(String profile) { - String suffix = profile != null ? "-" + profile : ""; + String suffix = (profile != null ? "-" + profile : ""); String string = ".properties)"; return "Loaded config file '" + new File("target/test-classes/application" + suffix + ".properties") diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/MockEmbeddedServletContainerFactory.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/MockEmbeddedServletContainerFactory.java index d14251a7bbb..fb2e3a3ab94 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/MockEmbeddedServletContainerFactory.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/MockEmbeddedServletContainerFactory.java @@ -67,17 +67,17 @@ public class MockEmbeddedServletContainerFactory } public ServletContext getServletContext() { - return getContainer() == null ? null : getContainer().servletContext; + return (getContainer() != null ? getContainer().servletContext : null); } public RegisteredServlet getRegisteredServlet(int index) { - return getContainer() == null ? null - : getContainer().getRegisteredServlets().get(index); + return (getContainer() != null ? getContainer().getRegisteredServlets().get(index) + : null); } public RegisteredFilter getRegisteredFilter(int index) { - return getContainer() == null ? null - : getContainer().getRegisteredFilters().get(index); + return (getContainer() != null ? getContainer().getRegisteredFilters().get(index) + : null); } public static class MockEmbeddedServletContainer implements EmbeddedServletContainer { diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java index f78c965ac34..0d4ac07ab4f 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactoryTests.java @@ -443,7 +443,7 @@ public class JettyEmbeddedServletContainerFactoryTests WebAppContext context = (WebAppContext) ((JettyEmbeddedServletContainer) this.container) .getServer().getHandler(); String charsetName = context.getLocaleEncoding(locale); - return (charsetName != null) ? Charset.forName(charsetName) : null; + return (charsetName != null ? Charset.forName(charsetName) : null); } @Override diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java index 5a0edda05f0..f652a4e1012 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactoryTests.java @@ -566,7 +566,7 @@ public class TomcatEmbeddedServletContainerFactoryTests .getTomcat().getHost().findChildren()[0]; CharsetMapper mapper = ((TomcatEmbeddedContext) context).getCharsetMapper(); String charsetName = mapper.getCharset(locale); - return (charsetName != null) ? Charset.forName(charsetName) : null; + return (charsetName != null ? Charset.forName(charsetName) : null); } private void assertTimeout(TomcatEmbeddedServletContainerFactory factory, diff --git a/spring-boot/src/test/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactoryTests.java b/spring-boot/src/test/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactoryTests.java index 7b026ade9b5..aabe8337151 100644 --- a/spring-boot/src/test/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactoryTests.java +++ b/spring-boot/src/test/java/org/springframework/boot/context/embedded/undertow/UndertowEmbeddedServletContainerFactoryTests.java @@ -319,7 +319,7 @@ public class UndertowEmbeddedServletContainerFactoryTests DeploymentInfo info = ((DeploymentManager) ReflectionTestUtils .getField(this.container, "manager")).getDeployment().getDeploymentInfo(); String charsetName = info.getLocaleCharsetMapping().get(locale.toString()); - return (charsetName != null) ? Charset.forName(charsetName) : null; + return (charsetName != null ? Charset.forName(charsetName) : null); } @Override