From 9543fcf44d2cbaf9b7fc8962955c515b2cc3d876 Mon Sep 17 00:00:00 2001 From: Phillip Webb Date: Tue, 28 Aug 2018 15:22:36 -0700 Subject: [PATCH] Upgrade to spring-javaformat 0.0.6 --- .../boot/actuate/audit/AuditEvent.java | 18 +++---- .../EndpointAutoConfiguration.java | 13 +++-- .../EndpointWebMvcAutoConfiguration.java | 6 +-- ...ermediaManagementContextConfiguration.java | 7 +-- ...tWebMvcManagementContextConfiguration.java | 4 +- .../HealthIndicatorAutoConfiguration.java | 2 +- .../actuate/autoconfigure/LinksEnhancer.java | 2 +- ...ntContextConfigurationsImportSelector.java | 6 +-- .../MetricExportAutoConfiguration.java | 4 +- .../PublicMetricsAutoConfiguration.java | 4 +- .../AbstractJmxCacheStatisticsProvider.java | 4 +- .../cache/CacheStatisticsProvider.java | 4 +- .../cache/EhCacheStatisticsProvider.java | 4 +- ...CloudFoundryActuatorAutoConfiguration.java | 4 +- .../boot/actuate/endpoint/FlywayEndpoint.java | 2 +- .../actuate/endpoint/LoggersEndpoint.java | 4 +- .../actuate/endpoint/jmx/DataConverter.java | 2 +- .../endpoint/jmx/EndpointMBeanExporter.java | 6 +-- .../mvc/AbstractEndpointHandlerMapping.java | 4 +- .../mvc/AbstractEndpointMvcAdapter.java | 8 +-- .../endpoint/mvc/LoggersMvcEndpoint.java | 6 +-- .../health/OrderedHealthAggregator.java | 2 +- .../actuate/health/SolrHealthIndicator.java | 4 +- .../boot/actuate/health/Status.java | 22 ++++---- .../boot/actuate/metrics/Metric.java | 34 ++++++------ .../aggregate/AggregateMetricReader.java | 6 +-- .../metrics/buffer/BufferMetricReader.java | 2 +- .../boot/actuate/metrics/buffer/Buffers.java | 4 +- .../dropwizard/DropwizardMetricServices.java | 4 +- .../jmx/DefaultMetricNamingStrategy.java | 4 +- .../boot/actuate/metrics/rich/RichGauge.java | 4 +- .../metrics/statsd/StatsdMetricWriter.java | 6 +-- .../writer/MetricWriterMessageHandler.java | 2 +- .../actuate/trace/WebRequestTraceFilter.java | 6 +-- .../EndpointMvcIntegrationTests.java | 2 +- ...gurationPropertiesReportEndpointTests.java | 2 +- ...erMvcEndpointDisabledIntegrationTests.java | 2 +- ...ManagementContextPathIntegrationTests.java | 2 +- ...serMvcEndpointVanillaIntegrationTests.java | 2 +- .../AutoConfigurationImportSelector.java | 4 +- .../AutoConfigurationMetadataLoader.java | 14 ++--- .../AutoConfigurationPackages.java | 10 ++-- .../AutoConfigurationSorter.java | 6 +-- ...ImportAutoConfigurationImportSelector.java | 4 +- .../amqp/RabbitAutoConfiguration.java | 4 +- .../autoconfigure/amqp/RabbitProperties.java | 6 +-- ...bitListenerContainerFactoryConfigurer.java | 6 +-- .../cache/CacheManagerCustomizers.java | 6 +-- .../condition/AbstractNestedCondition.java | 6 +-- ...ReportAutoConfigurationImportListener.java | 6 +-- .../condition/ConditionMessage.java | 24 ++++----- .../condition/ConditionOutcome.java | 14 ++--- .../condition/OnBeanCondition.java | 2 +- .../condition/OnJavaCondition.java | 2 +- .../condition/OnPropertyCondition.java | 2 +- .../condition/OnResourceCondition.java | 4 +- .../couchbase/CouchbaseProperties.java | 6 +-- ...ExceptionTranslationAutoConfiguration.java | 4 +- .../data/redis/RedisAutoConfiguration.java | 5 +- .../NoSuchBeanDefinitionFailureAnalyzer.java | 10 ++-- .../flyway/FlywayProperties.java | 2 +- .../jdbc/DataSourceAutoConfiguration.java | 2 +- .../jdbc/EmbeddedDatabaseConnection.java | 2 +- .../DataSourcePoolMetadataProviders.java | 4 +- .../TomcatDataSourcePoolMetadata.java | 2 +- .../boot/autoconfigure/jms/JmsProperties.java | 8 +-- .../ActiveMQConnectionFactoryFactory.java | 4 +- .../autoconfigure/mongo/MongoProperties.java | 12 ++--- .../EmbeddedMongoAutoConfiguration.java | 46 ++++++++-------- .../jpa/DataSourceInitializedPublisher.java | 6 +-- .../autoconfigure/orm/jpa/JpaProperties.java | 6 +-- .../SpringBootWebSecurityConfiguration.java | 2 +- .../DefaultUserInfoRestTemplateFactory.java | 2 +- .../resource/UserInfoTokenServices.java | 2 +- .../session/SessionProperties.java | 4 +- .../social/FacebookAutoConfiguration.java | 2 +- .../social/LinkedInAutoConfiguration.java | 2 +- .../AbstractViewResolverProperties.java | 4 +- .../TemplateAvailabilityProviders.java | 6 +-- .../PlatformTransactionManagerCustomizer.java | 4 +- .../TransactionManagerCustomizers.java | 4 +- .../ValidationAutoConfiguration.java | 4 +- .../web/BasicErrorController.java | 2 +- .../web/ErrorMvcAutoConfiguration.java | 5 +- .../web/HttpEncodingProperties.java | 2 +- ...ttpMessageConvertersAutoConfiguration.java | 2 +- .../autoconfigure/web/ResourceProperties.java | 2 +- .../autoconfigure/web/ServerProperties.java | 6 +-- .../web/WebMvcAutoConfiguration.java | 2 +- ...stJpaDependencyAutoConfigurationTests.java | 4 +- .../cli/app/SpringApplicationLauncher.java | 8 +-- ...gApplicationWebApplicationInitializer.java | 2 +- .../boot/cli/command/CommandFactory.java | 4 +- .../boot/cli/command/CommandRunner.java | 8 +-- .../boot/cli/command/HelpExample.java | 4 +- .../cli/command/archive/ArchiveCommand.java | 2 +- .../boot/cli/command/core/HelpCommand.java | 2 +- .../boot/cli/command/core/HintCommand.java | 2 +- .../cli/command/init/InitializrService.java | 4 +- .../init/ProjectGenerationRequest.java | 2 +- .../cli/command/init/ProjectGenerator.java | 10 ++-- .../command/install/DependencyResolver.java | 6 +-- .../cli/command/install/InstallCommand.java | 4 +- .../cli/command/install/UninstallCommand.java | 4 +- .../cli/command/options/OptionHandler.java | 3 +- .../cli/command/shell/CommandCompleter.java | 2 +- .../boot/cli/command/shell/Shell.java | 2 +- .../cli/compiler/DependencyCustomizer.java | 12 ++--- .../compiler/ExtendedGroovyClassLoader.java | 2 +- ...veDependencyCoordinatesTransformation.java | 4 +- .../ArtifactCoordinatesResolver.java | 14 ++--- .../cli/compiler/dependencies/Dependency.java | 54 +++++++++---------- .../dependencies/DependencyManagement.java | 4 +- ...ManagementArtifactCoordinatesResolver.java | 6 +-- .../cli/compiler/grape/AetherGrapeEngine.java | 4 +- ...ositorySystemSessionAutoConfiguration.java | 4 +- .../grape/DependencyResolutionContext.java | 6 +-- .../DependencyResolutionFailedException.java | 4 +- .../grape/RepositoryConfiguration.java | 28 +++++----- .../cli/compiler/maven/MavenSettings.java | 7 +-- .../init/AbstractHttpClientMockTests.java | 10 ++-- .../init/ProjectGenerationRequestTests.java | 6 +-- .../RemoteDevToolsAutoConfiguration.java | 21 ++++---- .../DevToolsHomePropertiesPostProcessor.java | 2 +- .../boot/devtools/filewatch/ChangedFile.java | 12 ++--- .../boot/devtools/filewatch/ChangedFiles.java | 12 ++--- .../client/ClassPathChangeUploader.java | 12 ++--- .../restart/classloader/ClassLoaderFile.java | 4 +- .../classloader/RestartClassLoader.java | 4 +- .../tunnel/client/HttpTunnelConnection.java | 4 +- .../tunnel/client/TunnelConnection.java | 6 +-- .../client/ClassPathChangeUploaderTests.java | 2 +- .../spock/SpockTestRestTemplateExample.java | 4 +- .../embedded/AbstractApplicationLauncher.java | 4 +- spring-boot-parent/pom.xml | 2 +- spring-boot-samples/pom.xml | 2 +- .../sample/data/jpa/domain/HotelSummary.java | 2 +- .../data/jpa/service/HotelServiceImpl.java | 2 +- .../hibernate4/domain/HotelSummary.java | 2 +- .../hibernate4/service/HotelServiceImpl.java | 2 +- .../hibernate52/domain/HotelSummary.java | 2 +- .../hibernate52/service/HotelServiceImpl.java | 2 +- .../domain/VehicleIdentificationNumber.java | 12 ++--- .../sample/test/service/VehicleDetails.java | 12 ++--- .../jetty/echo/DefaultEchoService.java | 2 +- .../jetty93/echo/DefaultEchoService.java | 2 +- .../tomcat/echo/DefaultEchoService.java | 2 +- .../undertow/echo/DefaultEchoService.java | 2 +- ...ConfigurationContextCustomizerFactory.java | 10 ++-- ...notationCustomizableTypeExcludeFilter.java | 30 +++++------ .../TypeExcludeFiltersContextCustomizer.java | 12 ++--- .../properties/AnnotationsPropertySource.java | 18 +++---- .../PropertyMappingContextCustomizer.java | 14 ++--- .../WebDriverContextCustomizerFactory.java | 12 ++--- .../web/servlet/WebDriverScope.java | 4 +- ...eFiltersContextCustomizerFactoryTests.java | 10 ++-- .../json/app/ExampleBasicObject.java | 12 ++--- .../json/app/ExampleCustomObject.java | 12 ++--- .../json/app/ExampleJsonObjectWithView.java | 12 ++--- .../context/ImportsContextCustomizer.java | 30 +++++------ .../SpringBootConfigurationFinder.java | 2 +- .../test/context/SpringBootContextLoader.java | 4 +- .../SpringBootTestContextBootstrapper.java | 10 ++-- .../SpringBootTestContextCustomizer.java | 12 ++--- .../ExcludeFilterContextCustomizer.java | 12 ++--- .../test/json/AbstractJsonMarshalTester.java | 2 +- .../boot/test/json/BasicJsonTester.java | 4 +- ...ateJsonObjectContextCustomizerFactory.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/json/ObjectContentAssert.java | 4 +- .../boot/test/mock/mockito/Definition.java | 26 ++++----- .../test/mock/mockito/MockDefinition.java | 24 ++++----- .../mockito/MockitoContextCustomizer.java | 12 ++--- .../mock/mockito/QualifierDefinition.java | 12 ++--- .../boot/test/mock/mockito/SpyDefinition.java | 16 +++--- .../boot/test/util/EnvironmentTestUtils.java | 4 +- .../boot/test/json/ExampleObject.java | 12 ++--- .../boot/test/json/ExampleObjectWithView.java | 12 ++--- .../AutoConfigureAnnotationProcessor.java | 4 +- .../AbstractConfigurationMetadataTests.java | 2 +- ...figurationMetadataAnnotationProcessor.java | 2 +- .../MetadataCollector.java | 6 +-- .../configurationprocessor/TypeUtils.java | 4 +- .../fieldvalues/javac/Trees.java | 2 +- .../fieldvalues/javac/VariableTree.java | 2 +- .../metadata/ConfigurationMetadata.java | 6 +-- .../metadata/ItemDeprecation.java | 16 +++--- .../metadata/ItemHint.java | 10 ++-- .../metadata/ItemMetadata.java | 28 +++++----- .../gradle/SpringBootPluginExtension.java | 2 +- .../gradle/repackage/ProjectLibraries.java | 16 +++--- .../boot/gradle/repackage/RepackageTask.java | 14 ++--- .../boot/gradle/run/BootRunTask.java | 4 +- .../loader/tools/DefaultLaunchScript.java | 2 +- .../boot/loader/tools/JarWriter.java | 10 ++-- .../boot/loader/tools/Library.java | 2 +- .../boot/loader/tools/MainClassFinder.java | 22 ++++---- .../springframework/boot/loader/Launcher.java | 4 +- .../boot/loader/MainMethodRunner.java | 2 +- .../boot/loader/PropertiesLauncher.java | 4 +- .../data/ByteArrayRandomAccessData.java | 4 +- .../loader/data/RandomAccessDataFile.java | 6 +-- .../boot/loader/jar/AsciiBytes.java | 46 ++++++++-------- .../jar/CentralDirectoryFileHeader.java | 2 +- .../loader/jar/CentralDirectoryParser.java | 4 +- .../boot/loader/jar/Handler.java | 4 +- .../boot/loader/jar/JarEntry.java | 2 +- .../boot/loader/jar/JarFile.java | 4 +- .../boot/loader/jar/JarFileEntries.java | 6 +-- .../boot/loader/jar/JarURLConnection.java | 10 ++-- .../loader/jar/ZipInflaterInputStream.java | 4 +- .../boot/loader/util/SystemPropertyUtils.java | 2 +- .../boot/maven/AbstractRunMojo.java | 13 ++--- .../PropertiesMergingResourceTransformer.java | 2 +- .../boot/maven/RepackageMojo.java | 4 +- .../classpath/ModifiedClassPathRunner.java | 4 +- .../springframework/boot/ApplicationHome.java | 14 ++--- .../springframework/boot/ApplicationPid.java | 20 +++---- .../boot/BeanDefinitionLoader.java | 6 +-- .../boot/DefaultApplicationArguments.java | 2 +- .../boot/EnvironmentConverter.java | 6 +-- .../boot/ExitCodeGenerators.java | 2 +- .../springframework/boot/ResourceBanner.java | 10 ++-- .../boot/SpringApplication.java | 8 +-- .../boot/SpringApplicationBannerPrinter.java | 2 +- .../boot/SpringApplicationRunListeners.java | 2 +- .../boot/SpringBootBanner.java | 2 +- .../boot/SpringBootVersion.java | 4 +- .../boot/StartupInfoLogger.java | 8 +-- .../springframework/boot/ansi/AnsiColors.java | 4 +- .../boot/bind/OriginCapablePropertyValue.java | 6 +-- .../PatternPropertyNamePatternsMatcher.java | 4 +- .../bind/PropertiesConfigurationFactory.java | 10 ++-- .../boot/bind/PropertySourceUtils.java | 2 +- .../boot/bind/RelaxedDataBinder.java | 8 +-- .../boot/bind/RelaxedNames.java | 14 ++--- .../boot/bind/RelaxedPropertyResolver.java | 2 +- .../bind/YamlJavaBeanPropertyConstructor.java | 4 +- ...arentContextCloserApplicationListener.java | 12 ++--- .../builder/SpringApplicationBuilder.java | 12 ++--- ...udFoundryVcapEnvironmentPostProcessor.java | 2 +- .../config/ConfigFileApplicationListener.java | 30 +++++------ ...stractEmbeddedServletContainerFactory.java | 10 ++-- .../boot/context/embedded/MimeMappings.java | 26 ++++----- ...onContextServletContextAwareProcessor.java | 6 +-- .../jetty/JettyEmbeddedServletContainer.java | 2 +- .../JettyEmbeddedServletContainerFactory.java | 10 ++-- .../tomcat/SkipPatternJarScanner.java | 2 +- .../TomcatEmbeddedServletContainer.java | 2 +- ...TomcatEmbeddedServletContainerFactory.java | 10 ++-- .../TomcatEmbeddedWebappClassLoader.java | 8 +-- .../UndertowEmbeddedServletContainer.java | 24 ++++----- ...dertowEmbeddedServletContainerFactory.java | 16 +++--- .../ConfigurationBeanFactoryMetaData.java | 2 +- ...urationPropertiesBindingPostProcessor.java | 2 +- ...ConfigurationPropertiesImportSelector.java | 4 +- .../boot/diagnostics/FailureAnalyzers.java | 2 +- ...eanCurrentlyInCreationFailureAnalyzer.java | 16 +++--- .../boot/env/PropertySourcesLoader.java | 2 +- ...plicationJsonEnvironmentPostProcessor.java | 4 +- .../boot/info/GitProperties.java | 4 +- .../boot/jackson/JsonComponentModule.java | 6 +-- .../boot/jdbc/DatabaseDriver.java | 2 +- ...ikosDependsOnBeanFactoryPostProcessor.java | 2 +- .../boot/logging/AbstractLoggingSystem.java | 4 +- .../boot/logging/LoggerConfiguration.java | 34 ++++++------ .../boot/logging/LoggingSystem.java | 4 +- .../boot/logging/java/SimpleFormatter.java | 2 +- .../boot/logging/log4j2/ColorConverter.java | 4 +- .../boot/logging/logback/ColorConverter.java | 2 +- .../logback/LevelRemappingAppender.java | 7 +-- .../logging/logback/LogbackLoggingSystem.java | 2 +- .../orm/jpa/EntityManagerFactoryBuilder.java | 6 +-- .../boot/system/ApplicationPidFileWriter.java | 2 +- .../boot/system/SystemProperties.java | 4 +- .../boot/web/client/RestTemplateBuilder.java | 4 +- .../boot/web/servlet/ErrorPage.java | 24 ++++----- .../boot/web/servlet/RegistrationBean.java | 4 +- .../ServletContextInitializerBeans.java | 2 +- .../boot/web/support/ErrorPageFilter.java | 4 +- .../yaml/SpringProfileDocumentMatcher.java | 6 +-- .../boot/SpringApplicationTests.java | 2 +- .../ConfigFileApplicationListenerTests.java | 2 +- .../MockEmbeddedServletContainerFactory.java | 10 ++-- ...yEmbeddedServletContainerFactoryTests.java | 2 +- ...tEmbeddedServletContainerFactoryTests.java | 2 +- ...wEmbeddedServletContainerFactoryTests.java | 2 +- 290 files changed, 1021 insertions(+), 1014 deletions(-) diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java index 98712d8788b..89885ba988d 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,9 +56,9 @@ public class AuditEvent implements Serializable { /** * Create a new audit event for the current time. - * @param principal The user principal responsible + * @param principal the user principal responsible * @param type the event type - * @param data The event data + * @param data the event data */ public AuditEvent(String principal, String type, Map data) { this(new Date(), principal, type, data); @@ -67,9 +67,9 @@ public class AuditEvent implements Serializable { /** * Create a new audit event for the current time from data provided as name-value * pairs. - * @param principal The user principal responsible + * @param principal the user principal responsible * @param type the event type - * @param data The event data in the form 'key=value' or simply 'key' + * @param data the event data in the form 'key=value' or simply 'key' */ public AuditEvent(String principal, String type, String... data) { this(new Date(), principal, type, convert(data)); @@ -77,17 +77,17 @@ public class AuditEvent implements Serializable { /** * Create a new audit event. - * @param timestamp The date/time of the event - * @param principal The user principal responsible + * @param timestamp the date/time of the event + * @param principal the user principal responsible * @param type the event type - * @param data The event data + * @param data the event data */ public AuditEvent(Date timestamp, String principal, String type, Map data) { Assert.notNull(timestamp, "Timestamp must not be null"); Assert.notNull(type, "Type must not be null"); this.timestamp = timestamp; - this.principal = (principal != null ? principal : ""); + this.principal = (principal != null) ? principal : ""; this.type = type; this.data = Collections.unmodifiableMap(data); } 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 e010a48a736..bcf28488d99 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,11 +114,10 @@ public class EndpointAutoConfiguration { @Bean @ConditionalOnMissingBean public HealthEndpoint healthEndpoint() { - HealthAggregator healthAggregator = (this.healthAggregator != null - ? this.healthAggregator : new OrderedHealthAggregator()); - Map healthIndicators = (this.healthIndicators != null - ? this.healthIndicators - : Collections.emptyMap()); + HealthAggregator healthAggregator = (this.healthAggregator != null) + ? this.healthAggregator : new OrderedHealthAggregator(); + Map healthIndicators = (this.healthIndicators != null) + ? this.healthIndicators : Collections.emptyMap(); return new HealthEndpoint(healthAggregator, healthIndicators); } @@ -131,7 +130,7 @@ public class EndpointAutoConfiguration { @Bean @ConditionalOnMissingBean public InfoEndpoint infoEndpoint() throws Exception { - return new InfoEndpoint(this.infoContributors != null ? this.infoContributors + return new InfoEndpoint((this.infoContributors != null) ? this.infoContributors : Collections.emptyList()); } @@ -156,7 +155,7 @@ public class EndpointAutoConfiguration { @Bean @ConditionalOnMissingBean public TraceEndpoint traceEndpoint() { - return new TraceEndpoint(this.traceRepository != null ? this.traceRepository + return new TraceEndpoint((this.traceRepository != null) ? this.traceRepository : new InMemoryTraceRepository()); } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java index 90e63335b6a..7d323d8ef1c 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -376,8 +376,8 @@ public class EndpointWebMvcAutoConfiguration } return ((managementPort == null) || (serverPort == null && managementPort.equals(8080)) - || (managementPort != 0 && managementPort.equals(serverPort)) ? SAME - : DIFFERENT); + || (managementPort != 0) && managementPort.equals(serverPort)) ? SAME + : DIFFERENT; } private static T getTemporaryBean(BeanFactory beanFactory, Class type) { 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 caea9bd6875..b052970d14b 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,9 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration { @SuppressWarnings("unchecked") EndpointResource(Object content, String path) { - this.content = (content instanceof Map ? null : content); - this.embedded = (Map) (this.content != null ? null : content); + 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 d20ec510268..b4bbe7f06dd 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,8 +89,8 @@ public class EndpointWebMvcManagementContextConfiguration { this.corsProperties = corsProperties; List providedCustomizers = mappingCustomizers .getIfAvailable(); - this.mappingCustomizers = (providedCustomizers != null ? providedCustomizers - : Collections.emptyList()); + 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 f88594ead61..3c1e5be709a 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 ? poolMetadata.getValidationQuery() : null); + 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 b87fb9acc64..8b396558c02 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 ? type : Object.class); + 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 501fc68178a..1ae02f2b964 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 ? (Integer) attributes.get("value") - : null); - return (order != null ? order : Ordered.LOWEST_PRECEDENCE); + 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 4ea8a1990cb..01edd731db1 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,7 +95,7 @@ public class MetricExportAutoConfiguration { exporters.setReader(reader); exporters.setWriters(writers); } - exporters.setExporters(this.exporters != null ? this.exporters + exporters.setExporters((this.exporters != null) ? this.exporters : Collections.emptyMap()); return exporters; } @@ -128,7 +128,7 @@ public class MetricExportAutoConfiguration { public MetricExportProperties metricExportProperties() { MetricExportProperties export = new MetricExportProperties(); export.getRedis().setPrefix("spring.metrics" - + (this.prefix.length() > 0 ? "." : "") + this.prefix); + + ((this.prefix.length() > 0) ? "." : "") + this.prefix); export.getAggregate().setPrefix(this.prefix); export.getAggregate().setKeyPattern(this.aggregateKeyPattern); return export; 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 89129886c34..f7030cb01f2 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,9 @@ public class PublicMetricsAutoConfiguration { @Bean public MetricReaderPublicMetrics metricReaderPublicMetrics() { - MetricReader[] readers = (this.metricReaders != null + MetricReader[] readers = (this.metricReaders != null) ? this.metricReaders.toArray(new MetricReader[this.metricReaders.size()]) - : new MetricReader[0]); + : new MetricReader[0]; return new MetricReaderPublicMetrics(new CompositeMetricReader(readers)); } 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 69a1058cc3d..8eb61090982 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 @@ -38,7 +38,7 @@ import org.springframework.cache.CacheManager; * Base {@link CacheStatisticsProvider} implementation that uses JMX to retrieve the cache * statistics. * - * @param The cache type + * @param the cache type * @author Stephane Nicoll * @since 1.3.0 */ @@ -56,7 +56,7 @@ public abstract class AbstractJmxCacheStatisticsProvider public CacheStatistics getCacheStatistics(CacheManager cacheManager, C cache) { try { ObjectName objectName = internalGetObjectName(cache); - return (objectName != null ? getCacheStatistics(objectName) : null); + 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/cache/CacheStatisticsProvider.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CacheStatisticsProvider.java index d27e44dc8ef..8aa51d9c8b6 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CacheStatisticsProvider.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/CacheStatisticsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.springframework.cache.CacheManager; /** * Provide a {@link CacheStatistics} based on a {@link Cache}. * - * @param The {@link Cache} type + * @param the {@link Cache} type * @author Stephane Nicoll * @author Phillip Webb * @since 1.3.0 diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/EhCacheStatisticsProvider.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/EhCacheStatisticsProvider.java index 98eae49faed..8d950cbed20 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/EhCacheStatisticsProvider.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/cache/EhCacheStatisticsProvider.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ public class EhCacheStatisticsProvider implements CacheStatisticsProvider 1 ? 1 : hitRatio); + double sanitizedHitRatio = (hitRatio > 1) ? 1 : hitRatio; statistics.setHitRatio(sanitizedHitRatio); statistics.setMissRatio(1 - sanitizedHitRatio); } 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 e4e9142c368..0e23b070ded 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 ? new CloudFoundrySecurityService( - restTemplateBuilder, cloudControllerUrl, skipSslValidation) : null); + 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/FlywayEndpoint.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/FlywayEndpoint.java index a37c53e56b9..45cd71fee4a 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 @@ -124,7 +124,7 @@ public class FlywayEndpoint extends AbstractEndpoint> { } private String nullSafeToString(Object obj) { - return (obj != null ? obj.toString() : null); + 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 e295c4eb05f..95f060be65f 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 ? new LoggerLevels(configuration) : null); + 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 ? level.name() : null); + 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 458372a290b..9113f4e8c1e 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 ? objectMapper : new 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 3fdc8baf6fc..ef93cb44b35 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 ? objectMapper : new ObjectMapper()); + this.objectMapper = (objectMapper != null) ? objectMapper : new ObjectMapper(); setAutodetect(false); setNamingStrategy(this.defaultNamingStrategy); setAssembler(this.assembler); @@ -167,8 +167,8 @@ public class EndpointMBeanExporter extends MBeanExporter for (Map.Entry entry : endpoints.entrySet()) { String name = entry.getKey(); JmxEndpoint endpoint = entry.getValue(); - Class type = (endpoint.getEndpointType() != null - ? endpoint.getEndpointType() : endpoint.getClass()); + Class type = (endpoint.getEndpointType() != null) + ? endpoint.getEndpointType() : endpoint.getClass(); if (!this.registeredEndpoints.contains(type) && endpoint.isEnabled()) { try { registerBeanNameOrInstance(endpoint, name); 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 840db818a9b..6b1281b6f3f 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 @@ -55,7 +55,7 @@ import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandl * MVC on the classpath). Note that any endpoints having method signatures will break in a * non-servlet environment. * - * @param The endpoint type + * @param the endpoint type * @author Phillip Webb * @author Christian Dupuis * @author Dave Syer @@ -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 ? getEndpointPatterns(path, mapping) : null); + return (path != null) ? getEndpointPatterns(path, mapping) : null; } /** diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointMvcAdapter.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointMvcAdapter.java index 1415a63e282..82c31ea2cf6 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointMvcAdapter.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/mvc/AbstractEndpointMvcAdapter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import org.springframework.util.Assert; /** * Abstract base class for {@link MvcEndpoint} implementations. * - * @param The delegate endpoint + * @param the delegate endpoint * @author Dave Syer * @author Andy Wilkinson * @author Phillip Webb @@ -67,7 +67,7 @@ public abstract class AbstractEndpointMvcAdapter> @Override public String getPath() { - return (this.path != null ? this.path : "/" + this.delegate.getId()); + return (this.path != null) ? this.path : "/" + this.delegate.getId(); } public void setPath(String path) { @@ -93,7 +93,7 @@ public abstract class AbstractEndpointMvcAdapter> /** * Returns the response that should be returned when the endpoint is disabled. - * @return The response to be returned when the endpoint is disabled + * @return the response to be returned when the endpoint is disabled * @since 1.2.4 * @see Endpoint#isEnabled() */ 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 c3954928d20..dda687f4a73 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 ? levels : ResponseEntity.notFound().build()); + 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 ? LogLevel.valueOf(level.toUpperCase(Locale.ENGLISH)) - : null); + 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 6f90043e375..c5d22d9b79c 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 ? 1 : s1.getCode().compareTo(s2.getCode()))); + 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 9891cdea235..739e374c108 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.DOWN : Status.UP); + Status status = (statusCode != 0) ? Status.DOWN : Status.UP; builder.status(status).withDetail("solrStatus", - (statusCode != 0 ? statusCode : "OK")); + (statusCode != 0) ? statusCode : "OK"); } } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java index c3a5d89b700..b62ec82388a 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -102,16 +102,6 @@ public final class Status { return this.description; } - @Override - public String toString() { - return this.code; - } - - @Override - public int hashCode() { - return this.code.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -123,4 +113,14 @@ public final class Status { return false; } + @Override + public int hashCode() { + return this.code.hashCode(); + } + + @Override + public String toString() { + return this.code; + } + } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Metric.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Metric.java index 757e0615861..dd5494dfdd6 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Metric.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/Metric.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -79,12 +79,6 @@ public class Metric { return this.timestamp; } - @Override - public String toString() { - return "Metric [name=" + this.name + ", value=" + this.value + ", timestamp=" - + this.timestamp + "]"; - } - /** * Create a new {@link Metric} with an incremented value. * @param amount the amount that the new metric will differ from this one @@ -105,16 +99,6 @@ public class Metric { return new Metric(this.getName(), value); } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ObjectUtils.nullSafeHashCode(this.name); - result = prime * result + ObjectUtils.nullSafeHashCode(this.timestamp); - result = prime * result + ObjectUtils.nullSafeHashCode(this.value); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -134,4 +118,20 @@ public class Metric { return super.equals(obj); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ObjectUtils.nullSafeHashCode(this.name); + result = prime * result + ObjectUtils.nullSafeHashCode(this.timestamp); + result = prime * result + ObjectUtils.nullSafeHashCode(this.value); + return result; + } + + @Override + public String toString() { + return "Metric [name=" + this.name + ", value=" + this.value + ", timestamp=" + + this.timestamp + "]"; + } + } diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/aggregate/AggregateMetricReader.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/aggregate/AggregateMetricReader.java index f39c9424f86..0cfda635a6d 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/aggregate/AggregateMetricReader.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/aggregate/AggregateMetricReader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -144,12 +144,12 @@ public class AggregateMetricReader implements MetricReader { StringBuilder builder = new StringBuilder(); for (int i = 0; i < patterns.length; i++) { if ("k".equals(patterns[i])) { - builder.append(builder.length() > 0 ? "." : ""); + builder.append((builder.length() > 0) ? "." : ""); builder.append(keys[i]); } } for (int i = patterns.length; i < keys.length; i++) { - builder.append(builder.length() > 0 ? "." : ""); + builder.append((builder.length() > 0) ? "." : ""); builder.append(keys[i]); } return builder.toString(); 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 6f069f14d36..42359d8c8a6 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 ? asMetric(name, buffer) : null); + return (buffer != null) ? asMetric(name, buffer) : null; } @Override diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/Buffers.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/Buffers.java index 920af45fc9f..a41ef85864d 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/Buffers.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/buffer/Buffers.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ import org.springframework.lang.UsesJava8; * * @author Dave Syer * @author Phillip Webb - * @param The buffer type + * @param the buffer type */ @UsesJava8 abstract class Buffers> { 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 3ff8143faec..7e655c1e763 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 - : ReservoirFactory.NONE); + this.reservoirFactory = (reservoirFactory != null) ? reservoirFactory + : ReservoirFactory.NONE; } @Override diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jmx/DefaultMetricNamingStrategy.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jmx/DefaultMetricNamingStrategy.java index 7f454c9bf3a..1f3c1d22fed 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jmx/DefaultMetricNamingStrategy.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/jmx/DefaultMetricNamingStrategy.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -52,7 +52,7 @@ public class DefaultMetricNamingStrategy implements ObjectNamingStrategy { String[] parts = StringUtils.delimitedListToStringArray(name, "."); table.put("type", parts[0]); if (parts.length > 1) { - table.put(parts.length > 2 ? "name" : "value", parts[1]); + table.put((parts.length > 2) ? "name" : "value", parts[1]); } if (parts.length > 2) { table.put("value", diff --git a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/rich/RichGauge.java b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/rich/RichGauge.java index 564f44dea76..a8ecef737fa 100644 --- a/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/rich/RichGauge.java +++ b/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/rich/RichGauge.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,7 +126,7 @@ public final class RichGauge { /** * Return either an exponential weighted moving average or a simple mean, * respectively, depending on whether the weight 'alpha' has been set for this gauge. - * @return The average over all the accumulated values + * @return the average over all the accumulated values */ public double getAverage() { return this.average; 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 b5ff0a80b4e..308243213a2 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 @@ -70,7 +70,7 @@ public class StatsdMetricWriter implements MetricWriter, Closeable { /** * Create a new writer with the given client. - * @param client StatsD client to write metrics with + * @param client the StatsD client to write metrics with */ public StatsdMetricWriter(StatsDClient client) { Assert.notNull(client, "client must not be null"); @@ -121,8 +121,8 @@ public class StatsdMetricWriter implements MetricWriter, Closeable { /** * Sanitize the metric name if necessary. - * @param name The metric name - * @return The sanitized metric name + * @param name the metric name + * @return the sanitized metric name */ private String sanitizeMetricName(String name) { return name.replace(":", "-"); 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 aaee0debf68..077f502c97f 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 ? payload.getClass().getName() : "null")); + + ((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 46be3e8f67a..48655afa392 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,7 +114,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order finally { addTimeTaken(trace, startTime); addSessionIdIfNecessary(request, trace); - enhanceTrace(trace, status != response.getStatus() + 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 ? session.getId() : null)); + (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 ? userPrincipal.getName() : null)); + (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 b875134a653..69a61e84c89 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,7 +128,7 @@ public class EndpointMvcIntegrationTests { @Bean @ConditionalOnMissingBean public HttpMessageConverters messageConverters() { - return new HttpMessageConverters(this.converters != null ? this.converters + return new HttpMessageConverters((this.converters != null) ? this.converters : Collections.>emptyList()); } 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 0db9910e7da..d0a34700d04 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 ? this.mixedBoolean : false); + 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 e22decb3363..b108f6a9c7d 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 1c72669ed0a..8a926cf953d 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 @@ -112,7 +112,7 @@ public class HalBrowserMvcEndpointManagementContextPathIntegrationTests { continue; } path = (path.startsWith("/") ? path.substring(1) : path); - path = (path.length() > 0 ? path : "self"); + 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/endpoint/mvc/HalBrowserMvcEndpointVanillaIntegrationTests.java b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointVanillaIntegrationTests.java index 640baf05f44..7d5a0c659d0 100644 --- a/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointVanillaIntegrationTests.java +++ b/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/mvc/HalBrowserMvcEndpointVanillaIntegrationTests.java @@ -126,7 +126,7 @@ public class HalBrowserMvcEndpointVanillaIntegrationTests { if (collections.contains(path)) { continue; } - path = (path.length() > 0 ? path : "/"); + path = (path.length() > 0) ? path : "/"; this.mockMvc.perform(get(path).accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(jsonPath("$._links.self.href") .value("http://localhost" + endpoint.getPath())); 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 98ed0cacc7d..4f5f16c897d 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 ? exclude : new String[0])); + 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 ? value : new String[0]); + 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/AutoConfigurationMetadataLoader.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoader.java index c99e2172091..a3ffda00940 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoader.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,8 +45,8 @@ final class AutoConfigurationMetadataLoader { static AutoConfigurationMetadata loadMetadata(ClassLoader classLoader, String path) { try { - Enumeration urls = (classLoader != null ? classLoader.getResources(path) - : ClassLoader.getSystemResources(path)); + Enumeration urls = (classLoader != null) ? classLoader.getResources(path) + : ClassLoader.getSystemResources(path); Properties properties = new Properties(); while (urls.hasMoreElements()) { properties.putAll(PropertiesLoaderUtils @@ -89,7 +89,7 @@ final class AutoConfigurationMetadataLoader { @Override public Integer getInteger(String className, String key, Integer defaultValue) { String value = get(className, key); - return (value != null ? Integer.valueOf(value) : defaultValue); + return (value != null) ? Integer.valueOf(value) : defaultValue; } @Override @@ -101,8 +101,8 @@ final class AutoConfigurationMetadataLoader { public Set getSet(String className, String key, Set defaultValue) { String value = get(className, key); - return (value != null ? StringUtils.commaDelimitedListToSet(value) - : defaultValue); + return (value != null) ? StringUtils.commaDelimitedListToSet(value) + : defaultValue; } @Override @@ -113,7 +113,7 @@ final class AutoConfigurationMetadataLoader { @Override public String get(String className, String key, String defaultValue) { String value = this.properties.getProperty(className + "." + key); - return (value != null ? value : defaultValue); + return (value != null) ? value : defaultValue; } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java index 07a1bc687d0..ae0475ab7f8 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java @@ -150,9 +150,8 @@ public abstract class AutoConfigurationPackages { this.packageName = ClassUtils.getPackageName(metadata.getClassName()); } - @Override - public int hashCode() { - return this.packageName.hashCode(); + public String getPackageName() { + return this.packageName; } @Override @@ -163,8 +162,9 @@ public abstract class AutoConfigurationPackages { return this.packageName.equals(((PackageImport) obj).packageName); } - public String getPackageName() { - return this.packageName; + @Override + public int hashCode() { + return this.packageName.hashCode(); } @Override 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 452c69353ce..836aaf3c8b2 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 ? (Integer) attributes.get("value") - : Ordered.LOWEST_PRECEDENCE); + 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 48e29615e55..d7f471a6597 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 ? merged.getClassArray("exclude") - : null); + 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/RabbitAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java index 0ea5a3e4e3f..20823f29c4a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -189,7 +189,7 @@ public class RabbitAutoConfiguration { private boolean determineMandatoryFlag() { Boolean mandatory = this.properties.getTemplate().getMandatory(); - return (mandatory != null ? mandatory : this.properties.isPublisherReturns()); + return (mandatory != null) ? mandatory : this.properties.isPublisherReturns(); } private RetryTemplate createRetryTemplate(RabbitProperties.Retry properties) { 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 0879de7ed9a..e78387f2e52 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 ? address.username : this.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 ? address.password : getPassword()); + 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 ? address.virtualHost : getVirtualHost()); + 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/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java index 52b6509039f..1dcae7faed1 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/SimpleRabbitListenerContainerFactoryConfigurer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -113,8 +113,8 @@ public final class SimpleRabbitListenerContainerFactoryConfigurer { builder.maxAttempts(retryConfig.getMaxAttempts()); builder.backOffOptions(retryConfig.getInitialInterval(), retryConfig.getMultiplier(), retryConfig.getMaxInterval()); - MessageRecoverer recoverer = (this.messageRecoverer != null - ? this.messageRecoverer : new RejectAndDontRequeueRecoverer()); + MessageRecoverer recoverer = (this.messageRecoverer != null) + ? this.messageRecoverer : new RejectAndDontRequeueRecoverer(); builder.recoverer(recoverer); factory.setAdviceChain(builder.build()); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheManagerCustomizers.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheManagerCustomizers.java index 021f9c79e99..34d3d9d5cd4 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheManagerCustomizers.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheManagerCustomizers.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,9 +41,9 @@ public class CacheManagerCustomizers { public CacheManagerCustomizers( List> customizers) { - this.customizers = (customizers != null + this.customizers = (customizers != null) ? new ArrayList>(customizers) - : Collections.>emptyList()); + : Collections.>emptyList(); } /** diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java index 11be4a5ec4c..4355d1f0f54 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -146,8 +146,8 @@ abstract class AbstractNestedCondition extends SpringBootCondition private List getConditionClasses(AnnotatedTypeMetadata metadata) { MultiValueMap attributes = metadata .getAllAnnotationAttributes(Conditional.class.getName(), true); - Object values = (attributes != null ? attributes.get("value") : null); - return (List) (values != null ? values : Collections.emptyList()); + Object values = (attributes != null) ? attributes.get("value") : null; + return (List) ((values != null) ? values : Collections.emptyList()); } private Condition getCondition(String conditionClassName) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportAutoConfigurationImportListener.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportAutoConfigurationImportListener.java index 208c7e25d02..20e29dbf52a 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportAutoConfigurationImportListener.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportAutoConfigurationImportListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,8 +46,8 @@ class ConditionEvaluationReportAutoConfigurationImportListener @Override public void setBeanFactory(BeanFactory beanFactory) throws BeansException { - this.beanFactory = (beanFactory instanceof ConfigurableListableBeanFactory - ? (ConfigurableListableBeanFactory) beanFactory : null); + this.beanFactory = (beanFactory instanceof ConfigurableListableBeanFactory) + ? (ConfigurableListableBeanFactory) beanFactory : null; } } 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 4be2fc61b7f..db883547127 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 @@ -59,16 +59,6 @@ public final class ConditionMessage { return !StringUtils.hasLength(this.message); } - @Override - public String toString() { - return (this.message != null ? this.message : ""); - } - - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.message); - } - @Override public boolean equals(Object obj) { if (obj == null || !ConditionMessage.class.isInstance(obj)) { @@ -80,6 +70,16 @@ public final class ConditionMessage { return ObjectUtils.nullSafeEquals(((ConditionMessage) obj).message, this.message); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.message); + } + + @Override + public String toString() { + return (this.message != null) ? this.message : ""; + } + /** * Return a new {@link ConditionMessage} based on the instance and an appended * message. @@ -359,7 +359,7 @@ public final class ConditionMessage { */ public ConditionMessage items(Style style, Object... items) { return items(style, - items != null ? Arrays.asList(items) : (Collection) null); + (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 ? "'" + item + "'" : null); + 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 bbee3c425c5..65fb9e9012f 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 @@ -122,12 +122,6 @@ public class ConditionOutcome { return this.message; } - @Override - public int hashCode() { - return ObjectUtils.hashCode(this.match) * 31 - + ObjectUtils.nullSafeHashCode(this.message); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -144,9 +138,15 @@ public class ConditionOutcome { return super.equals(obj); } + @Override + public int hashCode() { + return ObjectUtils.hashCode(this.match) * 31 + + ObjectUtils.nullSafeHashCode(this.message); + } + @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/OnBeanCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java index ebf6480c902..fe525929e1c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java @@ -365,7 +365,7 @@ class OnBeanCondition extends SpringBootCondition implements ConfigurationCondit } public SearchStrategy getStrategy() { - return (this.strategy != null ? this.strategy : SearchStrategy.ALL); + return (this.strategy != null) ? this.strategy : SearchStrategy.ALL; } public List getNames() { 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 3380bae62ce..3d41093e546 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 ? "(older than %s)" : "(%s or newer)", + (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/OnPropertyCondition.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java index 34b9c421df8..e85e0fbc48b 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java @@ -145,7 +145,7 @@ class OnPropertyCondition extends SpringBootCondition { "The name or value attribute of @ConditionalOnProperty must be specified"); Assert.state(value.length == 0 || name.length == 0, "The name and value attributes of @ConditionalOnProperty are exclusive"); - return (value.length > 0 ? value : name); + return (value.length > 0) ? value : name; } private void collectProperties(PropertyResolver resolver, List missing, 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 0e28abf25bd..b2549f83bf7 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 - ? context.getResourceLoader() : this.defaultResourceLoader); + 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/couchbase/CouchbaseProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java index da4853e2bde..53fb589ef95 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -174,8 +174,8 @@ public class CouchbaseProperties { private String keyStorePassword; public Boolean getEnabled() { - return (this.enabled != null ? this.enabled - : StringUtils.hasText(this.keyStore)); + return (this.enabled != null) ? this.enabled + : StringUtils.hasText(this.keyStore); } public void setEnabled(Boolean enabled) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java index 32084cb0da8..ad5274f2d76 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/dao/PersistenceExceptionTranslationAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class PersistenceExceptionTranslationAutoConfiguration { RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.aop."); Boolean value = resolver.getProperty("proxyTargetClass", Boolean.class); - return (value != null ? value : true); + return (value != null) ? value : true; } } 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 58474d84a83..9f45d6f7156 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,9 +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 8f0b638754a..38d4aa55496 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 ? description : "A component"), + (description != null) ? description : "A component", getBeanDescription(cause))); if (!autoConfigurationResults.isEmpty()) { for (AutoConfigurationResult provider : autoConfigurationResults) { @@ -164,8 +164,8 @@ class NoSuchBeanDefinitionFailureAnalyzer Source(String source) { String[] tokens = source.split("#"); - this.className = (tokens.length > 1 ? tokens[0] : source); - this.methodName = (tokens.length != 2 ? null : tokens[1]); + this.className = (tokens.length > 1) ? tokens[0] : source; + 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 ? (String[]) attributes.get("name") - : null); + 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 e547c5ceda6..b3458367835 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/jdbc/DataSourceAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java index df969af3fc7..4c2a098ccb7 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 ? dataSourceClass.getClassLoader() : null); + return (dataSourceClass != null) ? dataSourceClass.getClassLoader() : null; } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/EmbeddedDatabaseConnection.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/EmbeddedDatabaseConnection.java index c248cff239c..77998358949 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/EmbeddedDatabaseConnection.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/EmbeddedDatabaseConnection.java @@ -107,7 +107,7 @@ public enum EmbeddedDatabaseConnection { */ public String getUrl(String databaseName) { Assert.hasText(databaseName, "DatabaseName must not be null."); - return (this.url != null ? String.format(this.url, databaseName) : null); + return (this.url != null) ? String.format(this.url, databaseName) : 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 1b17c308133..5cf5f7c3624 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 + this.providers = (providers != null) ? new ArrayList(providers) - : Collections.emptyList()); + : 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 3a975f13932..ff2a9ba918c 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 ? pool.getActive() : 0); + return (pool != null) ? pool.getActive() : 0; } @Override diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java index 40a6d5c85ea..aafcbbb7a5e 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -124,11 +124,11 @@ public class JmsProperties { public String formatConcurrency() { if (this.concurrency == null) { - return (this.maxConcurrency != null ? "1-" + this.maxConcurrency : null); + return (this.maxConcurrency != null) ? "1-" + this.maxConcurrency : null; } - return (this.maxConcurrency != null + return (this.maxConcurrency != null) ? this.concurrency + "-" + this.maxConcurrency - : String.valueOf(this.concurrency)); + : String.valueOf(this.concurrency); } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryFactory.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryFactory.java index da168c33e78..fe88fabab9c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryFactory.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryFactory.java @@ -48,8 +48,8 @@ class ActiveMQConnectionFactoryFactory { List factoryCustomizers) { Assert.notNull(properties, "Properties must not be null"); this.properties = properties; - this.factoryCustomizers = (factoryCustomizers != null ? factoryCustomizers - : Collections.emptyList()); + this.factoryCustomizers = (factoryCustomizers != null) ? factoryCustomizers + : Collections.emptyList(); } public T createConnectionFactory( 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 4b8b05926c2..a63932e48c0 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 @@ -159,7 +159,7 @@ public class MongoProperties { } public String determineUri() { - return (this.uri != null ? this.uri : DEFAULT_URI); + return (this.uri != null) ? this.uri : DEFAULT_URI; } public void setUri(String uri) { @@ -226,7 +226,7 @@ public class MongoProperties { if (options == null) { options = MongoClientOptions.builder().build(); } - String host = (this.host != null ? this.host : "localhost"); + 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 - ? this.authenticationDatabase : getMongoClientDatabase()); + String database = (this.authenticationDatabase != null) + ? this.authenticationDatabase : getMongoClientDatabase(); credentials.add(MongoCredential.createCredential(this.username, database, this.password)); } - String host = (this.host != null ? this.host : "localhost"); - 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 4c308f36d4b..4ef63fa508a 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 @@ -128,13 +128,13 @@ public class EmbeddedMongoAutoConfiguration { this.embeddedProperties.getFeatures()); MongodConfigBuilder builder = new MongodConfigBuilder() .version(featureAwareVersion); - if (this.embeddedProperties.getStorage() != null) { - builder.replication( - new Storage(this.embeddedProperties.getStorage().getDatabaseDir(), - this.embeddedProperties.getStorage().getReplSetName(), - this.embeddedProperties.getStorage().getOplogSize() != null - ? this.embeddedProperties.getStorage().getOplogSize() - : 0)); + org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongoProperties.Storage storage = this.embeddedProperties + .getStorage(); + if (storage != null) { + String databaseDir = storage.getDatabaseDir(); + String replSetName = storage.getReplSetName(); + int oplogSize = (storage.getOplogSize() != null) ? storage.getOplogSize() : 0; + builder.replication(new Storage(databaseDir, replSetName, oplogSize)); } Integer configuredPort = this.properties.getPort(); if (configuredPort != null && configuredPort > 0) { @@ -239,8 +239,8 @@ public class EmbeddedMongoAutoConfiguration { Set features) { Assert.notNull(version, "version must not be null"); this.version = version; - this.features = (features != null ? features - : Collections.emptySet()); + this.features = (features != null) ? features + : Collections.emptySet(); } @Override @@ -253,20 +253,6 @@ public class EmbeddedMongoAutoConfiguration { return this.features.contains(feature); } - @Override - public String toString() { - return this.version; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + this.features.hashCode(); - result = prime * result + this.version.hashCode(); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -285,6 +271,20 @@ public class EmbeddedMongoAutoConfiguration { return super.equals(obj); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + this.features.hashCode(); + result = prime * result + this.version.hashCode(); + return result; + } + + @Override + public String toString() { + return this.version; + } + } } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java index 74810e47a2e..c8b19118b39 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,8 +81,8 @@ class DataSourceInitializedPublisher implements BeanPostProcessor { private DataSource findDataSource(EntityManagerFactory entityManagerFactory) { Object dataSource = entityManagerFactory.getProperties() .get("javax.persistence.nonJtaDataSource"); - return (dataSource != null && dataSource instanceof DataSource - ? (DataSource) dataSource : this.dataSource); + return (dataSource != null && dataSource instanceof DataSource) + ? (DataSource) dataSource : this.dataSource; } private boolean isInitializingDatabase(DataSource dataSource) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java index d5adda332f7..7c5a7321773 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -210,8 +210,8 @@ public class JpaProperties { private String getOrDeduceDdlAuto(Map existing, DataSource dataSource) { - String ddlAuto = (this.ddlAuto != null ? this.ddlAuto - : getDefaultDdlAuto(dataSource)); + String ddlAuto = (this.ddlAuto != null) ? this.ddlAuto + : getDefaultDdlAuto(dataSource); if (!existing.containsKey("hibernate." + "hbm2ddl.auto") && !"none".equals(ddlAuto)) { return ddlAuto; 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 5173c065414..f05400a0d59 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 7376125f5e3..3cbefef5463 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 ? this.details : DEFAULT_RESOURCE_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 61d83d68e90..ee9b35fd4c2 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 ? principal : "unknown"); + return (principal != null) ? principal : "unknown"; } @Override diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionProperties.java index 8eccfa6ea5a..b0bea245a76 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -50,7 +50,7 @@ public class SessionProperties { public SessionProperties(ObjectProvider serverProperties) { ServerProperties properties = serverProperties.getIfUnique(); - this.timeout = (properties != null ? properties.getSession().getTimeout() : null); + this.timeout = (properties != null) ? properties.getSession().getTimeout() : null; } public StoreType getStoreType() { 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 293190e6c47..f97fd10e887 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 4661d266a32..3d3f7aad19d 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/AbstractViewResolverProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractViewResolverProperties.java index acc0cd6c5c8..cc6dd8db347 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractViewResolverProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractViewResolverProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -119,7 +119,7 @@ public abstract class AbstractViewResolverProperties { } public String getCharsetName() { - return (this.charset != null ? this.charset.name() : null); + return (this.charset != null) ? this.charset.name() : null; } public void setCharset(Charset charset) { 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 d0057ea172c..0ac98f81964 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 ? applicationContext.getClassLoader() : null); + 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 ? provider : NONE); + provider = (provider != null) ? provider : NONE; this.resolved.put(view, provider); this.cache.put(view, provider); } } - return (provider != NONE ? provider : null); + return (provider != NONE) ? provider : null; } private TemplateAvailabilityProvider findProvider(String view, diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.java index 5c9d4325fed..0465de3efb6 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,7 +23,7 @@ import org.springframework.transaction.PlatformTransactionManager; * {@link PlatformTransactionManager PlatformTransactionManagers} whilst retaining default * auto-configuration. * - * @param The transaction manager type + * @param the transaction manager type * @author Phillip Webb * @since 1.5.0 */ 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 c79d4a5243e..d72671141eb 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,9 +41,9 @@ public class TransactionManagerCustomizers { public TransactionManagerCustomizers( Collection> customizers) { - this.customizers = (customizers != null + this.customizers = (customizers != null) ? new ArrayList>(customizers) - : null); + : null; } public void customize(PlatformTransactionManager transactionManager) { diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java index f8ad76ed29f..0386451b933 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,7 +72,7 @@ public class ValidationAutoConfiguration { RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(environment, "spring.aop."); Boolean value = resolver.getProperty("proxyTargetClass", Boolean.class); - return (value != null ? value : true); + return (value != null) ? value : true; } } 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 0615e2cdf8f..7c82312e723 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 ? modelAndView : new ModelAndView("error", model)); + 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 935af9d0aa2..046b5e87268 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,12 @@ public class ErrorMvcAutoConfiguration { @Override public String resolvePlaceholder(String placeholderName) { Expression expression = this.expressions.get(placeholderName); - return escape(expression != null ? expression.getValue(this.context) : null); + return escape( + (expression != null) ? expression.getValue(this.context) : null); } private String escape(Object value) { - return HtmlUtils.htmlEscape(value != null ? value.toString() : null); + 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 2340d6527d1..1135f08f746 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.forceResponse : this.forceRequest); + 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 eec44d6cad7..cd6d06521d8 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,7 +64,7 @@ public class HttpMessageConvertersAutoConfiguration { @Bean @ConditionalOnMissingBean public HttpMessageConverters messageConverters() { - return new HttpMessageConverters(this.converters != null ? this.converters + return new HttpMessageConverters((this.converters != null) ? this.converters : Collections.>emptyList()); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java index 93550ec2db8..4adb60f535c 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java @@ -241,7 +241,7 @@ public class ResourceProperties implements ResourceLoaderAware, InitializingBean static Boolean getEnabled(boolean fixedEnabled, boolean contentEnabled, Boolean chainEnabled) { - return (fixedEnabled || contentEnabled ? Boolean.TRUE : chainEnabled); + return (fixedEnabled || contentEnabled) ? Boolean.TRUE : chainEnabled; } } 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 a87f0ade86d..47d7c6cdcc6 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 ? platform.isUsingForwardHeaders() : false); + return (platform != null) ? platform.isUsingForwardHeaders() : false; } public Integer getConnectionTimeout() { @@ -830,8 +830,8 @@ public class ServerProperties if (this.minSpareThreads > 0) { customizeMinThreads(factory); } - int maxHttpHeaderSize = (serverProperties.getMaxHttpHeaderSize() > 0 - ? serverProperties.getMaxHttpHeaderSize() : this.maxHttpHeaderSize); + int maxHttpHeaderSize = (serverProperties.getMaxHttpHeaderSize() > 0) + ? serverProperties.getMaxHttpHeaderSize() : this.maxHttpHeaderSize; if (maxHttpHeaderSize > 0) { customizeMaxHttpHeaderSize(factory, maxHttpHeaderSize); } 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 0ab16ef128a..1dc61e80c87 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,7 +381,7 @@ public class WebMvcAutoConfiguration { @Override public RequestMappingHandlerAdapter requestMappingHandlerAdapter() { RequestMappingHandlerAdapter adapter = super.requestMappingHandlerAdapter(); - adapter.setIgnoreDefaultModelOnRedirect(this.mvcProperties != null + 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 937d8ae863f..6a9207f9554 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/SpringApplicationLauncher.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationLauncher.java index 01068993a5a..ef4784d47a9 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationLauncher.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationLauncher.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,9 +51,9 @@ public class SpringApplicationLauncher { /** * Launches the application created using the given {@code sources}. The application * is launched with the given {@code args}. - * @param sources The sources for the application - * @param args The args for the application - * @return The application's {@code ApplicationContext} + * @param sources the sources for the application + * @param args the args for the application + * @return the application's {@code ApplicationContext} * @throws Exception if the launch fails */ public Object launch(Object[] sources, String[] args) throws Exception { 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 824e2771bc2..375df98f39b 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 ? new Manifest(stream) : null); + Manifest manifest = (stream != null) ? new Manifest(stream) : null; return manifest; } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandFactory.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandFactory.java index 0b6ff1a2e5c..da1b91d9200 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandFactory.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,7 +29,7 @@ public interface CommandFactory { /** * Returns the CLI {@link Command}s. - * @return The commands + * @return the commands */ Collection getCommands(); 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 205ee45718d..bc2a9c02f88 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 @@ -171,7 +171,7 @@ public class CommandRunner implements Iterable { ExitStatus result = run(argsWithoutDebugFlags); // The caller will hang up if it gets a non-zero status if (result != null && result.isHangup()) { - return (result.getCode() > 0 ? result.getCode() : 0); + return (result.getCode() > 0) ? result.getCode() : 0; } return 0; } @@ -260,7 +260,7 @@ public class CommandRunner implements Iterable { } protected boolean errorMessage(String message) { - Log.error(message != null ? message : "Unexpected error"); + 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/HelpExample.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/HelpExample.java index 5b267974998..43bab3c8d19 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/HelpExample.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/HelpExample.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ public class HelpExample { /** * Create a new {@link HelpExample} instance. - * @param description The description (in the form "to ....") + * @param description the description (in the form "to ....") * @param example the example */ public HelpExample(String description, String example) { 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 3910800a5dd..7e88cdb1740 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 @@ -239,7 +239,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 f227ab2dd0d..bb5494875d1 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 ? "examples:" : "example:"); + 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 42b472a255b..1ab12d63296 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 ? Integer.valueOf(args[0]) - 1 : 0); + 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/InitializrService.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java index 1a7e54dbd51..18c2a0e73e9 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -241,7 +241,7 @@ class InitializrService { private String getContent(HttpEntity entity) throws IOException { ContentType contentType = ContentType.getOrDefault(entity); Charset charset = contentType.getCharset(); - charset = (charset != null ? charset : UTF_8); + charset = (charset != null) ? charset : UTF_8; byte[] content = FileCopyUtils.copyToByteArray(entity.getContent()); return new String(content, charset); } 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 42edd732a10..e713326883a 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 @@ -418,7 +418,7 @@ class ProjectGenerationRequest { } if (this.output != null) { int i = this.output.lastIndexOf('.'); - return (i != -1 ? this.output.substring(0, i) : this.output); + 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/init/ProjectGenerator.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java index 9e04f501104..7c708ab6ca7 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,8 +46,8 @@ class ProjectGenerator { public void generateProject(ProjectGenerationRequest request, boolean force) throws IOException { ProjectGenerationResponse response = this.initializrService.generate(request); - String fileName = (request.getOutput() != null ? request.getOutput() - : response.getFileName()); + String fileName = (request.getOutput() != null) ? request.getOutput() + : response.getFileName(); if (shouldExtract(request, response)) { if (isZipArchive(response)) { extractProject(response, request.getOutput(), force); @@ -101,8 +101,8 @@ class ProjectGenerator { private void extractProject(ProjectGenerationResponse entity, String output, boolean overwrite) throws IOException { - File outputFolder = (output != null ? new File(output) - : new File(System.getProperty("user.dir"))); + File outputFolder = (output != null) ? new File(output) + : new File(System.getProperty("user.dir")); if (!outputFolder.exists()) { outputFolder.mkdirs(); } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/DependencyResolver.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/DependencyResolver.java index de664e512e3..211399c573f 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/DependencyResolver.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/DependencyResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,8 +31,8 @@ interface DependencyResolver { /** * Resolves the given {@code artifactIdentifiers}, typically in the form * "group:artifact:version", and their dependencies. - * @param artifactIdentifiers The artifacts to resolve - * @return The {@code File}s for the resolved artifacts + * @param artifactIdentifiers the artifacts to resolve + * @return the {@code File}s for the resolved artifacts * @throws Exception if dependency resolution fails */ List resolve(List artifactIdentifiers) throws Exception; diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/InstallCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/InstallCommand.java index a8856a4da12..dd96bf0a8ba 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/InstallCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/InstallCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public class InstallCommand extends OptionParsingCommand { } catch (Exception ex) { String message = ex.getMessage(); - Log.error(message != null ? message : ex.getClass().toString()); + Log.error((message != null) ? message : ex.getClass().toString()); } return ExitStatus.OK; } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/UninstallCommand.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/UninstallCommand.java index f7ccd54f9b8..2c547bef1e2 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/UninstallCommand.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/UninstallCommand.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -75,7 +75,7 @@ public class UninstallCommand extends OptionParsingCommand { } catch (Exception ex) { String message = ex.getMessage(); - Log.error(message != null ? message : ex.getClass().toString()); + Log.error((message != null) ? message : ex.getClass().toString()); } return ExitStatus.OK; } 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 9fb3918a151..256d1f0ed6d 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,8 @@ public class OptionHandler { OptionHelpAdapter(OptionDescriptor descriptor) { this.options = new LinkedHashSet(); for (String option : descriptor.options()) { - this.options.add((option.length() != 1 ? "--" : "-") + option); + String prefix = (option.length() != 1) ? "--" : "-"; + this.options.add(prefix + 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 00fd22e5190..f693040a6dc 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 @@ -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 fcf8c229685..e6d28a9f028 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/compiler/DependencyCustomizer.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java index 1b863b7d2c1..cc969e662a5 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -185,7 +185,7 @@ public class DependencyCustomizer { * Add dependencies and all of their dependencies. The group ID and version of the * dependencies are resolved from the modules using the customizer's * {@link ArtifactCoordinatesResolver}. - * @param modules The module IDs + * @param modules the module IDs * @return this {@link DependencyCustomizer} for continued use */ public DependencyCustomizer add(String... modules) { @@ -199,7 +199,7 @@ public class DependencyCustomizer { * Add a single dependency and, optionally, all of its dependencies. The group ID and * version of the dependency are resolved from the module using the customizer's * {@link ArtifactCoordinatesResolver}. - * @param module The module ID + * @param module the module ID * @param transitive {@code true} if the transitive dependencies should also be added, * otherwise {@code false}. * @return this {@link DependencyCustomizer} for continued use @@ -212,9 +212,9 @@ public class DependencyCustomizer { * Add a single dependency with the specified classifier and type and, optionally, all * of its dependencies. The group ID and version of the dependency are resolved from * the module by using the customizer's {@link ArtifactCoordinatesResolver}. - * @param module The module ID - * @param classifier The classifier, may be {@code null} - * @param type The type, may be {@code null} + * @param module the module ID + * @param classifier the classifier, may be {@code null} + * @param type the type, may be {@code null} * @param transitive {@code true} if the transitive dependencies should also be added, * otherwise {@code false}. * @return this {@link DependencyCustomizer} for continued use 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 50d98d33ac7..3e2ab92ea83 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 ? new ByteArrayInputStream(bytes) : null); + resourceStream = (bytes != null) ? new ByteArrayInputStream(bytes) : null; } return resourceStream; } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java index 723d9667647..d13da444391 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -77,7 +77,7 @@ public class ResolveDependencyCoordinatesTransformation Expression expression = annotation.getMember("value"); if (expression instanceof ConstantExpression) { Object value = ((ConstantExpression) expression).getValue(); - return (value instanceof String ? (String) value : null); + return (value instanceof String) ? (String) value : null; } return null; } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ArtifactCoordinatesResolver.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ArtifactCoordinatesResolver.java index 255e3471bde..d999a1ad381 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ArtifactCoordinatesResolver.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ArtifactCoordinatesResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,24 +31,24 @@ public interface ArtifactCoordinatesResolver { /** * Gets the group id of the artifact identified by the given {@code module}. Returns * {@code null} if the artifact is unknown to the resolver. - * @param module The id of the module - * @return The group id of the module + * @param module the id of the module + * @return the group id of the module */ String getGroupId(String module); /** * Gets the artifact id of the artifact identified by the given {@code module}. * Returns {@code null} if the artifact is unknown to the resolver. - * @param module The id of the module - * @return The artifact id of the module + * @param module the id of the module + * @return the artifact id of the module */ String getArtifactId(String module); /** * Gets the version of the artifact identified by the given {@code module}. Returns * {@code null} if the artifact is unknown to the resolver. - * @param module The id of the module - * @return The version of the module + * @param module the id of the module + * @return the version of the module */ String getVersion(String module); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java index 70aa289daae..778973007ac 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -98,22 +98,6 @@ public final class Dependency { return this.exclusions; } - @Override - public String toString() { - return this.groupId + ":" + this.artifactId + ":" + this.version; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + this.groupId.hashCode(); - result = prime * result + this.artifactId.hashCode(); - result = prime * result + this.version.hashCode(); - result = prime * result + this.exclusions.hashCode(); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -134,6 +118,22 @@ public final class Dependency { return false; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + this.groupId.hashCode(); + result = prime * result + this.artifactId.hashCode(); + result = prime * result + this.version.hashCode(); + result = prime * result + this.exclusions.hashCode(); + return result; + } + + @Override + public String toString() { + return this.groupId + ":" + this.artifactId + ":" + this.version; + } + /** * A dependency exclusion. */ @@ -166,16 +166,6 @@ public final class Dependency { return this.groupId; } - @Override - public String toString() { - return this.groupId + ":" + this.artifactId; - } - - @Override - public int hashCode() { - return this.groupId.hashCode() * 31 + this.artifactId.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -194,6 +184,16 @@ public final class Dependency { return false; } + @Override + public int hashCode() { + return this.groupId.hashCode() * 31 + this.artifactId.hashCode(); + } + + @Override + public String toString() { + return this.groupId + ":" + this.artifactId; + } + } } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java index 72be46223af..44fc2b55e39 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -40,7 +40,7 @@ public interface DependencyManagement { /** * Finds the managed dependency with the given {@code artifactId}. - * @param artifactId The artifact ID of the dependency to find + * @param artifactId the artifact ID of the dependency to find * @return the dependency, or {@code null} */ Dependency find(String artifactId); 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 c9a29422977..59cc21a8815 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 ? dependency.getGroupId() : null); + return (dependency != null) ? dependency.getGroupId() : null; } @Override public String getArtifactId(String id) { Dependency dependency = find(id); - return (dependency != null ? dependency.getArtifactId() : null); + 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 ? dependency.getVersion() : null); + 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 d3624ba0849..7d2a7aa2cc5 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 ? transitive : true); + 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 ? classLoader : this.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 0066c58ac28..76b8acec240 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,9 +51,9 @@ public class DefaultRepositorySystemSessionAutoConfiguration ProxySelector existing = session.getProxySelector(); if (existing == null || !(existing instanceof CompositeProxySelector)) { JreProxySelector fallback = new JreProxySelector(); - ProxySelector selector = (existing != null + ProxySelector selector = (existing != null) ? new CompositeProxySelector(Arrays.asList(existing, fallback)) - : 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 e6d6eebd559..f097f9588fa 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,10 +104,10 @@ public class DependencyResolutionContext { this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency), aetherDependency); } - this.dependencyManagement = (this.dependencyManagement != null + this.dependencyManagement = (this.dependencyManagement != null) ? new CompositeDependencyManagement(dependencyManagement, this.dependencyManagement) - : dependencyManagement); + : dependencyManagement; this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver( this.dependencyManagement); } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionFailedException.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionFailedException.java index 17a708cd4b7..70db6a12c0d 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionFailedException.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionFailedException.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -27,7 +27,7 @@ public class DependencyResolutionFailedException extends RuntimeException { /** * Creates a new {@code DependencyResolutionFailedException} with the given * {@code cause}. - * @param cause The cause of the resolution failure + * @param cause the cause of the resolution failure */ public DependencyResolutionFailedException(Throwable cause) { super(cause); diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java index 8c1ec3393f5..a0f5e5c2faf 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2014 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,8 +35,8 @@ public final class RepositoryConfiguration { /** * Creates a new {@code RepositoryConfiguration} instance. - * @param name The name of the repository - * @param uri The uri of the repository + * @param name the name of the repository + * @param uri the uri of the repository * @param snapshotsEnabled {@code true} if the repository should enable access to * snapshots, {@code false} otherwise */ @@ -54,12 +54,6 @@ public final class RepositoryConfiguration { return this.name; } - @Override - public String toString() { - return "RepositoryConfiguration [name=" + this.name + ", uri=" + this.uri - + ", snapshotsEnabled=" + this.snapshotsEnabled + "]"; - } - /** * Return the URI of the repository. * @return the repository URI @@ -76,11 +70,6 @@ public final class RepositoryConfiguration { return this.snapshotsEnabled; } - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.name); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -96,4 +85,15 @@ public final class RepositoryConfiguration { return ObjectUtils.nullSafeEquals(this.name, other.name); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.name); + } + + @Override + public String toString() { + return "RepositoryConfiguration [name=" + this.name + ", uri=" + this.uri + + ", snapshotsEnabled=" + this.snapshotsEnabled + "]"; + } + } diff --git a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettings.java b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettings.java index f3a6bbc3acd..ab4cbb5475e 100644 --- a/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettings.java +++ b/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettings.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -151,8 +151,9 @@ public class MavenSettings { PrintWriter printer = new PrintWriter(message); printer.println("Failed to determine active profiles:"); for (ModelProblemCollectorRequest problem : problemCollector.getProblems()) { - printer.println(" " + problem.getMessage() + (problem.getLocation() != null - ? " at " + problem.getLocation() : "")); + String location = (problem.getLocation() != null) + ? " at " + problem.getLocation() : ""; + printer.println(" " + problem.getMessage() + location); if (problem.getException() != null) { printer.println(indentStackTrace(problem.getException(), " ")); } 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 8743d0236fd..b3a9cdf9387 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 @@ -89,8 +89,8 @@ public abstract class AbstractHttpClientMockTests { CloseableHttpResponse response = mock(CloseableHttpResponse.class); mockHttpEntity(response, request.content, request.contentType); mockStatus(response, 200); - String header = (request.fileName != null - ? contentDispositionValue(request.fileName) : null); + String header = (request.fileName != null) + ? contentDispositionValue(request.fileName) : null; mockHttpHeader(response, "Content-Disposition", header); given(this.http.execute(argThat(getForNonMetadata()))).willReturn(response); } @@ -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-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java index 1dec8c59eac..f84239f0105 100644 --- a/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java +++ b/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -233,8 +233,8 @@ public class ProjectGenerationRequestTests { } public void setBuildAndFormat(String build, String format) { - this.request.setBuild(build != null ? build : "maven"); - this.request.setFormat(format != null ? format : "project"); + this.request.setBuild((build != null) ? build : "maven"); + this.request.setFormat((format != null) ? format : "project"); this.request.setDetectType(true); } 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 43b5f8f3773..f38b0906c47 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,9 +95,10 @@ public class RemoteDevToolsAutoConfiguration { @Bean public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() { Handler handler = new HttpStatusHandler(); - return new UrlHandlerMapper((this.serverProperties.getContextPath() != null - ? this.serverProperties.getContextPath() : "") - + this.properties.getRemote().getContextPath(), handler); + String serverContextPath = (this.serverProperties.getContextPath() != null) + ? this.serverProperties.getContextPath() : ""; + String remoteContextPath = this.properties.getRemote().getContextPath(); + return new UrlHandlerMapper(serverContextPath + remoteContextPath, handler); } @Bean @@ -136,9 +137,10 @@ public class RemoteDevToolsAutoConfiguration { @Bean @ConditionalOnMissingBean(name = "remoteRestartHandlerMapper") public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) { - String url = (this.serverProperties.getContextPath() != null - ? this.serverProperties.getContextPath() : "") - + this.properties.getRemote().getContextPath() + "/restart"; + String serverContextPath = (this.serverProperties.getContextPath() != null) + ? this.serverProperties.getContextPath() : ""; + String remoteContextPath = this.properties.getRemote().getContextPath(); + String url = serverContextPath + remoteContextPath + "/restart"; logger.warn("Listening for remote restart updates on " + url); Handler handler = new HttpRestartServerHandler(server); return new UrlHandlerMapper(url, handler); @@ -162,9 +164,10 @@ public class RemoteDevToolsAutoConfiguration { @ConditionalOnMissingBean(name = "remoteDebugHandlerMapper") public UrlHandlerMapper remoteDebugHandlerMapper( @Qualifier("remoteDebugHttpTunnelServer") HttpTunnelServer server) { - String url = (this.serverProperties.getContextPath() != null - ? this.serverProperties.getContextPath() : "") - + this.properties.getRemote().getContextPath() + "/debug"; + String serverContextPath = (this.serverProperties.getContextPath() != null) + ? this.serverProperties.getContextPath() : ""; + String remoteContextPath = this.properties.getRemote().getContextPath(); + String url = serverContextPath + remoteContextPath + "/debug"; logger.warn("Listening for remote debug traffic on " + url); Handler handler = new HttpTunnelServerHandler(server); return new UrlHandlerMapper(url, handler); 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 2eafb82f89a..3077664b5ae 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 ? new File(home, FILE_NAME) : null); + 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/filewatch/ChangedFile.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java index c60114e3721..9a098cf0d1a 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -81,11 +81,6 @@ public final class ChangedFile { return fileName.substring(folderName.length() + 1); } - @Override - public int hashCode() { - return this.file.hashCode() * 31 + this.type.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -101,6 +96,11 @@ public final class ChangedFile { return super.equals(obj); } + @Override + public int hashCode() { + return this.file.hashCode() * 31 + this.type.hashCode(); + } + @Override public String toString() { return this.file + " (" + this.type + ")"; diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java index 6e46461bd0d..54ed503930e 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,11 +61,6 @@ public final class ChangedFiles implements Iterable { return this.files; } - @Override - public int hashCode() { - return this.files.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null) { @@ -82,6 +77,11 @@ public final class ChangedFiles implements Iterable { return super.equals(obj); } + @Override + public int hashCode() { + return this.files.hashCode(); + } + @Override public String toString() { return this.sourceFolder + " " + this.files; 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 3b4eafec72d..c36a8857c72 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 @@ -134,8 +134,8 @@ public class ClassPathChangeUploader private void logUpload(ClassLoaderFiles classLoaderFiles) { int size = classLoaderFiles.size(); - logger.info( - "Uploaded " + size + " class " + (size != 1 ? "resources" : "resource")); + logger.info("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 - ? FileCopyUtils.copyToByteArray(changedFile.getFile()) : null); - long lastModified = (kind != Kind.DELETED ? changedFile.getFile().lastModified() - : System.currentTimeMillis()); + 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 ca2cf6cecd6..2ab2c6623d8 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/restart/classloader/RestartClassLoader.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoader.java index 66214be7439..3d126bacf0e 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoader.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/RestartClassLoader.java @@ -91,9 +91,9 @@ public class RestartClassLoader extends URLClassLoader implements SmartClassLoad } Method classLoadingLockMethod = ReflectionUtils.findMethod(ClassLoader.class, "getClassLoadingLock", String.class); - this.classLoadingLockSupplier = (classLoadingLockMethod != null + this.classLoadingLockSupplier = (classLoadingLockMethod != null) ? new StandardClassLoadingLockSupplier() - : new Java6ClassLoadingLockSupplier()); + : new Java6ClassLoadingLockSupplier(); } @Override 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 6ccafcfd179..e2d30c5d458 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 ? executor - : Executors.newCachedThreadPool(new TunnelThreadFactory())); + this.executor = (executor != null) ? executor + : Executors.newCachedThreadPool(new TunnelThreadFactory()); } @Override diff --git a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/TunnelConnection.java b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/TunnelConnection.java index 8ac5662b010..9223becbf0f 100644 --- a/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/TunnelConnection.java +++ b/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/TunnelConnection.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,10 +29,10 @@ public interface TunnelConnection { /** * Open the tunnel connection. - * @param incomingChannel A {@link WritableByteChannel} that should be used to write + * @param incomingChannel a {@link WritableByteChannel} that should be used to write * any incoming data received from the remote server. * @param closeable a closeable to call when the channel is closed - * @return A {@link WritableByteChannel} that should be used to send any outgoing data + * @return a {@link WritableByteChannel} that should be used to send any outgoing data * destined for the remote server * @throws Exception in case of errors */ 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 a0f72b7f7d7..c23918ae3dd 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 ? content.getBytes() : null); + .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 e95c78b8a0b..759d7402e53 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(builder.build()) : new TestRestTemplate()); + 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 8e21508bc83..1c45b83765d 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,9 +66,9 @@ abstract class AbstractApplicationLauncher extends ExternalResource { private Process startApplication() throws Exception { File workingDirectory = getWorkingDirectory(); - File serverPortFile = (workingDirectory != null + File serverPortFile = (workingDirectory != null) ? new File(workingDirectory, "target/server.port") - : new File("target/server.port")); + : new File("target/server.port"); serverPortFile.delete(); File archive = this.applicationBuilder.buildApplication(); List arguments = new ArrayList(); diff --git a/spring-boot-parent/pom.xml b/spring-boot-parent/pom.xml index 07e409f467c..38acebd0f70 100644 --- a/spring-boot-parent/pom.xml +++ b/spring-boot-parent/pom.xml @@ -24,7 +24,7 @@ UTF-8 UTF-8 3.1.1 - 0.0.2 + 0.0.6 http://github.com/spring-projects/spring-boot diff --git a/spring-boot-samples/pom.xml b/spring-boot-samples/pom.xml index d12b4a3b55b..bd9c2b78128 100644 --- a/spring-boot-samples/pom.xml +++ b/spring-boot-samples/pom.xml @@ -19,7 +19,7 @@ ${basedir}/.. 1.8 - 0.0.2 + 0.0.6 false 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 35b4b3e262a..c22e8ad760e 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 ? (int) Math.round(getAverageRating()) : null); + return (getAverageRating() != null) ? (int) Math.round(getAverageRating()) : null; } } diff --git a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java index e575741f23a..cb6acf9fd8f 100644 --- a/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java +++ b/spring-boot-samples/spring-boot-sample-data-jpa/src/main/java/sample/data/jpa/service/HotelServiceImpl.java @@ -91,7 +91,7 @@ class HotelServiceImpl implements HotelService { @Override public long getNumberOfReviewsWithRating(Rating rating) { Long count = this.ratingCount.get(rating); - return (count != null ? count : 0); + return (count != null) ? count : 0; } } 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 42d8d03585e..a3044c00dd3 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 ? (int) Math.round(getAverageRating()) : null); + return (getAverageRating() != null) ? (int) Math.round(getAverageRating()) : null; } } diff --git a/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/service/HotelServiceImpl.java b/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/service/HotelServiceImpl.java index e42947f1db9..15ddb8cb92f 100644 --- a/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/service/HotelServiceImpl.java +++ b/spring-boot-samples/spring-boot-sample-hibernate4/src/main/java/sample/hibernate4/service/HotelServiceImpl.java @@ -91,7 +91,7 @@ class HotelServiceImpl implements HotelService { @Override public long getNumberOfReviewsWithRating(Rating rating) { Long count = this.ratingCount.get(rating); - return (count != null ? count : 0); + return (count != null) ? count : 0; } } 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 693f141316c..68636d25b31 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 ? (int) Math.round(getAverageRating()) : null); + return (getAverageRating() != null) ? (int) Math.round(getAverageRating()) : null; } } diff --git a/spring-boot-samples/spring-boot-sample-hibernate52/src/main/java/sample/hibernate52/service/HotelServiceImpl.java b/spring-boot-samples/spring-boot-sample-hibernate52/src/main/java/sample/hibernate52/service/HotelServiceImpl.java index f1664ef1164..98a0656fd87 100644 --- a/spring-boot-samples/spring-boot-sample-hibernate52/src/main/java/sample/hibernate52/service/HotelServiceImpl.java +++ b/spring-boot-samples/spring-boot-sample-hibernate52/src/main/java/sample/hibernate52/service/HotelServiceImpl.java @@ -91,7 +91,7 @@ class HotelServiceImpl implements HotelService { @Override public long getNumberOfReviewsWithRating(Rating rating) { Long count = this.ratingCount.get(rating); - return (count != null ? count : 0); + return (count != null) ? count : 0; } } diff --git a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/domain/VehicleIdentificationNumber.java b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/domain/VehicleIdentificationNumber.java index c3ac249fe8c..8f6cc559cc5 100644 --- a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/domain/VehicleIdentificationNumber.java +++ b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/domain/VehicleIdentificationNumber.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,11 +33,6 @@ public final class VehicleIdentificationNumber { this.vin = vin; } - @Override - public int hashCode() { - return this.vin.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -49,6 +44,11 @@ public final class VehicleIdentificationNumber { return this.vin.equals(((VehicleIdentificationNumber) obj).vin); } + @Override + public int hashCode() { + return this.vin.hashCode(); + } + @Override public String toString() { return this.vin; diff --git a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleDetails.java b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleDetails.java index e0515ff56de..3daccef4449 100644 --- a/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleDetails.java +++ b/spring-boot-samples/spring-boot-sample-test/src/main/java/sample/test/service/VehicleDetails.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,11 +49,6 @@ public class VehicleDetails { return this.model; } - @Override - public int hashCode() { - return this.make.hashCode() * 31 + this.model.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -66,4 +61,9 @@ public class VehicleDetails { return this.make.equals(other.make) && this.model.equals(other.model); } + @Override + public int hashCode() { + return this.make.hashCode() * 31 + this.model.hashCode(); + } + } diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java index dcb00af08e3..91a128c3a5c 100644 --- a/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java +++ b/spring-boot-samples/spring-boot-sample-websocket-jetty/src/main/java/samples/websocket/jetty/echo/DefaultEchoService.java @@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService { private final String echoFormat; public DefaultEchoService(String echoFormat) { - this.echoFormat = (echoFormat != null ? echoFormat : "%s"); + this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; } @Override diff --git a/spring-boot-samples/spring-boot-sample-websocket-jetty93/src/main/java/samples/websocket/jetty93/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-jetty93/src/main/java/samples/websocket/jetty93/echo/DefaultEchoService.java index ae2cc6cb98c..5a2ac952dd4 100644 --- a/spring-boot-samples/spring-boot-sample-websocket-jetty93/src/main/java/samples/websocket/jetty93/echo/DefaultEchoService.java +++ b/spring-boot-samples/spring-boot-sample-websocket-jetty93/src/main/java/samples/websocket/jetty93/echo/DefaultEchoService.java @@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService { private final String echoFormat; public DefaultEchoService(String echoFormat) { - this.echoFormat = (echoFormat != null ? echoFormat : "%s"); + this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; } @Override diff --git a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java index d6b82ce10ad..d20efe0479b 100644 --- a/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java +++ b/spring-boot-samples/spring-boot-sample-websocket-tomcat/src/main/java/samples/websocket/tomcat/echo/DefaultEchoService.java @@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService { private final String echoFormat; public DefaultEchoService(String echoFormat) { - this.echoFormat = (echoFormat != null ? echoFormat : "%s"); + this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; } @Override diff --git a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java index 0326a0a2d79..aa5c28ee6d4 100644 --- a/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java +++ b/spring-boot-samples/spring-boot-sample-websocket-undertow/src/main/java/samples/websocket/undertow/echo/DefaultEchoService.java @@ -21,7 +21,7 @@ public class DefaultEchoService implements EchoService { private final String echoFormat; public DefaultEchoService(String echoFormat) { - this.echoFormat = (echoFormat != null ? echoFormat : "%s"); + this.echoFormat = (echoFormat != null) ? echoFormat : "%s"; } @Override diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java index f1f6d29719c..44957dacdfe 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -61,13 +61,13 @@ class OverrideAutoConfigurationContextCustomizerFactory } @Override - public int hashCode() { - return getClass().hashCode(); + public boolean equals(Object obj) { + return (obj != null && obj.getClass() == getClass()); } @Override - public boolean equals(Object obj) { - return (obj != null && obj.getClass() == getClass()); + public int hashCode() { + return getClass().hashCode(); } } diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java index 17281c01920..7fe59ab6967 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java @@ -117,21 +117,6 @@ public abstract class AnnotationCustomizableTypeExcludeFilter extends TypeExclud } - @Override - public int hashCode() { - final int prime = 31; - int result = 0; - result = prime * result + ObjectUtils.hashCode(hasAnnotation()); - for (FilterType filterType : FilterType.values()) { - result = prime * result - + ObjectUtils.nullSafeHashCode(getFilters(filterType)); - } - result = prime * result + ObjectUtils.hashCode(isUseDefaultFilters()); - result = prime * result + ObjectUtils.nullSafeHashCode(getDefaultIncludes()); - result = prime * result + ObjectUtils.nullSafeHashCode(getComponentIncludes()); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -155,4 +140,19 @@ public abstract class AnnotationCustomizableTypeExcludeFilter extends TypeExclud return result; } + @Override + public int hashCode() { + final int prime = 31; + int result = 0; + result = prime * result + ObjectUtils.hashCode(hasAnnotation()); + for (FilterType filterType : FilterType.values()) { + result = prime * result + + ObjectUtils.nullSafeHashCode(getFilters(filterType)); + } + result = prime * result + ObjectUtils.hashCode(isUseDefaultFilters()); + result = prime * result + ObjectUtils.nullSafeHashCode(getDefaultIncludes()); + result = prime * result + ObjectUtils.nullSafeHashCode(getComponentIncludes()); + return result; + } + } diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java index f815737ef29..aa8f1189ccd 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -73,17 +73,17 @@ class TypeExcludeFiltersContextCustomizer implements ContextCustomizer { } } - @Override - public int hashCode() { - return this.filters.hashCode(); - } - @Override public boolean equals(Object obj) { return (obj != null && getClass().equals(obj.getClass()) && this.filters .equals(((TypeExcludeFiltersContextCustomizer) obj).filters)); } + @Override + public int hashCode() { + return this.filters.hashCode(); + } + @Override public void customizeContext(ConfigurableApplicationContext context, MergedContextConfiguration mergedContextConfiguration) { 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 ed2e6bae3ed..0cef66a3430 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()); } @@ -201,11 +201,6 @@ public class AnnotationsPropertySource extends EnumerablePropertySource return this.properties.isEmpty(); } - @Override - public int hashCode() { - return this.properties.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -217,4 +212,9 @@ public class AnnotationsPropertySource extends EnumerablePropertySource return this.properties.equals(((AnnotationsPropertySource) obj).properties); } + @Override + public int hashCode() { + return this.properties.hashCode(); + } + } 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 a675e21fad0..faa2c53b85d 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 @@ -55,17 +55,17 @@ class PropertyMappingContextCustomizer implements ContextCustomizer { new PropertyMappingCheckBeanPostProcessor()); } - @Override - public int hashCode() { - return this.propertySource.hashCode(); - } - @Override public boolean equals(Object obj) { return (obj != null && getClass().equals(obj.getClass()) && this.propertySource .equals(((PropertyMappingContextCustomizer) obj).propertySource)); } + @Override + public int hashCode() { + return this.propertySource.hashCode(); + } + /** * {@link BeanPostProcessor} to check that {@link PropertyMapping} is only used on * test classes. @@ -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 ? "annotations " : "annotation "); + result.insert(0, (annotations.size() != 1) ? "annotations " : "annotation "); return result.toString(); } diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java index 4d47950250c..7916adf4bd0 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,11 +49,6 @@ class WebDriverContextCustomizerFactory implements ContextCustomizerFactory { WebDriverScope.registerWith(context); } - @Override - public int hashCode() { - return getClass().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -65,6 +60,11 @@ class WebDriverContextCustomizerFactory implements ContextCustomizerFactory { return true; } + @Override + public int hashCode() { + return getClass().hashCode(); + } + } } diff --git a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java index 8802e013160..d6f8a4b11ca 100644 --- a/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java +++ b/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -145,7 +145,7 @@ class WebDriverScope implements Scope { if (context instanceof ConfigurableApplicationContext) { Scope scope = ((ConfigurableApplicationContext) context).getBeanFactory() .getRegisteredScope(NAME); - return (scope instanceof WebDriverScope ? (WebDriverScope) scope : null); + return (scope instanceof WebDriverScope) ? (WebDriverScope) scope : null; } return null; } diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java index b7199c15834..5fcc39832db 100644 --- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -123,13 +123,13 @@ public class TypeExcludeFiltersContextCustomizerFactoryTests { } @Override - public int hashCode() { - return SimpleExclude.class.hashCode(); + public boolean equals(Object obj) { + return obj.getClass().equals(getClass()); } @Override - public boolean equals(Object obj) { - return obj.getClass().equals(getClass()); + public int hashCode() { + return SimpleExclude.class.hashCode(); } } diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java index 74b27023d91..6407a567bcc 100644 --- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,11 +33,6 @@ public class ExampleBasicObject { this.value = value; } - @Override - public int hashCode() { - return this.value.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj != null && obj.getClass().equals(getClass())) { @@ -46,4 +41,9 @@ public class ExampleBasicObject { return false; } + @Override + public int hashCode() { + return this.value.hashCode(); + } + } diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java index f25b04c02fc..181d8091486 100644 --- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,11 +29,6 @@ public class ExampleCustomObject { this.value = value; } - @Override - public int hashCode() { - return this.value.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj != null && obj.getClass().equals(getClass())) { @@ -42,6 +37,11 @@ public class ExampleCustomObject { return false; } + @Override + public int hashCode() { + return this.value.hashCode(); + } + @Override public String toString() { return this.value; diff --git a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java index 450c20ce358..76b9ad7b254 100644 --- a/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java +++ b/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,11 +48,6 @@ public class ExampleJsonObjectWithView { this.id = id; } - @Override - public int hashCode() { - return 0; - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -63,6 +58,11 @@ public class ExampleJsonObjectWithView { && ObjectUtils.nullSafeEquals(this.id, other.id); } + @Override + public int hashCode() { + return 0; + } + @Override public String toString() { return this.value + " " + this.id; 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 d330c8b7fb4..10ff2262f81 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 @@ -116,11 +116,6 @@ class ImportsContextCustomizer implements ContextCustomizer { return definition; } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -134,6 +129,11 @@ class ImportsContextCustomizer implements ContextCustomizer { return this.key.equals(other.key); } + @Override + public int hashCode() { + return this.key.hashCode(); + } + @Override public String toString() { return new ToStringCreator(this).append("key", this.key).toString(); @@ -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 - ? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null); - return (testClass != null ? new String[] { ((Class) testClass).getName() } - : NO_IMPORTS); + Object testClass = (definition != null) + ? definition.getAttribute(TEST_CLASS_ATTRIBUTE) : null; + return (testClass != null) ? new String[] { ((Class) testClass).getName() } + : NO_IMPORTS; } } @@ -246,7 +246,7 @@ class ImportsContextCustomizer implements ContextCustomizer { collectClassAnnotations(testClass, annotations, seen); Set determinedImports = determineImports(annotations, testClass); this.key = Collections.unmodifiableSet( - determinedImports != null ? determinedImports : annotations); + (determinedImports != null) ? determinedImports : annotations); } private void collectClassAnnotations(Class classType, @@ -339,17 +339,17 @@ class ImportsContextCustomizer implements ContextCustomizer { } } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { return (obj != null && getClass().equals(obj.getClass()) && this.key.equals(((ContextCustomizerKey) obj).key)); } + @Override + public int hashCode() { + return this.key.hashCode(); + } + @Override public String toString() { return this.key.toString(); 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 51ae3e637cc..1cf1b39d28d 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 ea211414ada..cd118f1a55f 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 @@ -98,9 +98,9 @@ public class SpringBootContextLoader extends AbstractContextLoader { if (!ObjectUtils.isEmpty(config.getActiveProfiles())) { setActiveProfiles(environment, config.getActiveProfiles()); } - ResourceLoader resourceLoader = (application.getResourceLoader() != null + ResourceLoader resourceLoader = (application.getResourceLoader() != null) ? application.getResourceLoader() - : new DefaultResourceLoader(getClass().getClassLoader())); + : new DefaultResourceLoader(getClass().getClassLoader()); TestPropertySourceUtils.addPropertiesFilesToEnvironment(environment, resourceLoader, config.getPropertySourceLocations()); TestPropertySourceUtils.addInlinedPropertiesToEnvironment(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 75f5f5b0488..162b733f3f0 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 - ? webAppConfiguration.value() : "src/main/webapp"); + 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 ? annotation.webEnvironment() : null); + return (annotation != null) ? annotation.webEnvironment() : null; } protected Class[] getClasses(Class testClass) { SpringBootTest annotation = getAnnotation(testClass); - return (annotation != null ? annotation.classes() : null); + return (annotation != null) ? annotation.classes() : null; } protected String[] getProperties(Class testClass) { SpringBootTest annotation = getAnnotation(testClass); - return (annotation != null ? annotation.properties() : null); + return (annotation != null) ? annotation.properties() : null; } protected SpringBootTest getAnnotation(Class testClass) { diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextCustomizer.java b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextCustomizer.java index c7517d0c0eb..255687ffe68 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextCustomizer.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -66,11 +66,6 @@ class SpringBootTestContextCustomizer implements ContextCustomizer { new RootBeanDefinition(TestRestTemplateFactory.class)); } - @Override - public int hashCode() { - return getClass().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -79,6 +74,11 @@ class SpringBootTestContextCustomizer implements ContextCustomizer { return true; } + @Override + public int hashCode() { + return getClass().hashCode(); + } + /** * {@link FactoryBean} used to create and configure a {@link TestRestTemplate}. */ diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java b/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java index 678bd3ef492..38ac24c60c4 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,11 +36,6 @@ class ExcludeFilterContextCustomizer implements ContextCustomizer { new TestTypeExcludeFilter()); } - @Override - public int hashCode() { - return getClass().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -52,4 +47,9 @@ class ExcludeFilterContextCustomizer implements ContextCustomizer { return true; } + @Override + public int hashCode() { + return getClass().hashCode(); + } + } diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java b/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java index a6f7ad90257..6ffa76c149b 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java @@ -354,7 +354,7 @@ public abstract class AbstractJsonMarshalTester { * Utility class used to support field initialization. Used by subclasses to support * {@code initFields}. * - * @param The marshaller type + * @param the marshaller type */ protected abstract static class FieldInitializer { diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java b/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java index 6efb110bc7b..b45ba0fd385 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -105,7 +105,7 @@ public class BasicJsonTester { * Create JSON content from the specified String source. The source can contain the * JSON itself or, if it ends with {@code .json}, the name of a resource to be loaded * using {@code resourceLoadClass}. - * @param source JSON content or a {@code .json} resource name + * @param source the JSON content or a {@code .json} resource name * @return the JSON content */ public JsonContent from(CharSequence source) { diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java b/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java index 9523e2959d7..065a1c8791b 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java @@ -86,11 +86,6 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa this.logger.warn(message); } - @Override - public int hashCode() { - return getClass().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -99,6 +94,11 @@ class DuplicateJsonObjectContextCustomizerFactory implements ContextCustomizerFa return true; } + @Override + public int hashCode() { + return getClass().hashCode(); + } + } } 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 3191c288d8a..83ffa52be50 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 99bdc498068..166e2765bf8 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 : Charset.forName("UTF-8")); + 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 94a5d51371a..0a00c6f1397 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 The actual type + * @param the actual type * @author Phillip Webb * @since 1.4.0 */ diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java index c9b96e17e07..5eaa44a79cb 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,7 +39,7 @@ abstract class Definition { Definition(String name, MockReset reset, boolean proxyTargetAware, QualifierDefinition qualifier) { this.name = name; - this.reset = (reset != null ? reset : MockReset.AFTER); + this.reset = (reset != null) ? reset : MockReset.AFTER; this.proxyTargetAware = proxyTargetAware; this.qualifier = qualifier; } @@ -76,17 +76,6 @@ abstract class Definition { return this.qualifier; } - @Override - public int hashCode() { - int result = 1; - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.name); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.reset); - result = MULTIPLIER * result - + ObjectUtils.nullSafeHashCode(this.proxyTargetAware); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.qualifier); - return result; - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -105,4 +94,15 @@ abstract class Definition { return result; } + @Override + public int hashCode() { + int result = 1; + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.name); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.reset); + result = MULTIPLIER * result + + ObjectUtils.nullSafeHashCode(this.proxyTargetAware); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.qualifier); + return result; + } + } diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java index 745c8a32c2c..af1efbdd2a4 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -56,7 +56,7 @@ class MockDefinition extends Definition { Assert.notNull(typeToMock, "TypeToMock must not be null"); this.typeToMock = typeToMock; this.extraInterfaces = asClassSet(extraInterfaces); - this.answer = (answer != null ? answer : Answers.RETURNS_DEFAULTS); + this.answer = (answer != null) ? answer : Answers.RETURNS_DEFAULTS; this.serializable = serializable; } @@ -100,16 +100,6 @@ class MockDefinition extends Definition { return this.serializable; } - @Override - public int hashCode() { - int result = super.hashCode(); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToMock); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.extraInterfaces); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.answer); - result = MULTIPLIER * result + (this.serializable ? 1231 : 1237); - return result; - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -128,6 +118,16 @@ class MockDefinition extends Definition { return result; } + @Override + public int hashCode() { + int result = super.hashCode(); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToMock); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.extraInterfaces); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.answer); + result = MULTIPLIER * result + (this.serializable ? 1231 : 1237); + return result; + } + @Override public String toString() { return new ToStringCreator(this).append("name", getName()) diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java index f2c31ad0839..575ab095046 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -46,11 +46,6 @@ class MockitoContextCustomizer implements ContextCustomizer { } } - @Override - public int hashCode() { - return this.definitions.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -63,4 +58,9 @@ class MockitoContextCustomizer implements ContextCustomizer { return this.definitions.equals(other.definitions); } + @Override + public int hashCode() { + return this.definitions.hashCode(); + } + } diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java index c66713b4685..04ae44ddedc 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -60,11 +60,6 @@ class QualifierDefinition { definition.setQualifiedElement(this.field); } - @Override - public int hashCode() { - return this.annotations.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -77,6 +72,11 @@ class QualifierDefinition { return this.annotations.equals(other.annotations); } + @Override + public int hashCode() { + return this.annotations.hashCode(); + } + public static QualifierDefinition forElement(AnnotatedElement element) { if (element != null && element instanceof Field) { Field field = (Field) element; diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java index 8b37dc5ff69..ffdb6f629df 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,13 +48,6 @@ class SpyDefinition extends Definition { return this.typeToSpy; } - @Override - public int hashCode() { - int result = super.hashCode(); - result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToSpy); - return result; - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -69,6 +62,13 @@ class SpyDefinition extends Definition { return result; } + @Override + public int hashCode() { + int result = super.hashCode(); + result = MULTIPLIER * result + ObjectUtils.nullSafeHashCode(this.typeToSpy); + return result; + } + @Override public String toString() { return new ToStringCreator(this).append("name", getName()) diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/util/EnvironmentTestUtils.java b/spring-boot-test/src/main/java/org/springframework/boot/test/util/EnvironmentTestUtils.java index d0f5b82fcce..cf5ce8a68d2 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/util/EnvironmentTestUtils.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/util/EnvironmentTestUtils.java @@ -71,8 +71,8 @@ public abstract class EnvironmentTestUtils { Map map = getOrAdd(sources, name); for (String pair : pairs) { int index = getSeparatorIndex(pair); - String key = pair.substring(0, index > 0 ? index : pair.length()); - String value = (index > 0 ? pair.substring(index + 1) : ""); + String key = pair.substring(0, (index > 0) ? index : pair.length()); + String value = (index > 0) ? pair.substring(index + 1) : ""; map.put(key.trim(), value.trim()); } } diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java b/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java index 3db0036a58a..b7c30a58cce 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,11 +43,6 @@ public class ExampleObject { this.age = age; } - @Override - public int hashCode() { - return 0; - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -58,6 +53,11 @@ public class ExampleObject { && ObjectUtils.nullSafeEquals(this.age, other.age); } + @Override + public int hashCode() { + return 0; + } + @Override public String toString() { return this.name + " " + this.age; diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java b/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java index 1bd501c0944..1171bb9bbb3 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,11 +48,6 @@ public class ExampleObjectWithView { this.age = age; } - @Override - public int hashCode() { - return 0; - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -63,6 +58,11 @@ public class ExampleObjectWithView { && ObjectUtils.nullSafeEquals(this.age, other.age); } + @Override + public int hashCode() { + return 0; + } + @Override public String toString() { return this.name + " " + this.age; diff --git a/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java b/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java index d27dffd4128..e3175542b90 100644 --- a/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java +++ b/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -150,7 +150,7 @@ public class AutoConfigureAnnotationProcessor extends AbstractProcessor { private String toCommaDelimitedString(List list) { StringBuilder result = new StringBuilder(); for (Object item : list) { - result.append(result.length() != 0 ? "," : ""); + result.append((result.length() != 0) ? "," : ""); result.append(item); } return result.toString(); 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 768837bdc33..a3cd8bb1f31 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 00f4b06033f..4920c0a7fde 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 @@ -357,7 +357,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor this.metadataCollector.add(ItemMetadata.newGroup(nestedPrefix, this.typeUtils.getQualifiedName(returnElement), this.typeUtils.getQualifiedName(element), - (getter != null ? getter.toString() : null))); + (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/MetadataCollector.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataCollector.java index 3757a27e225..38aafca9d47 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataCollector.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataCollector.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,8 +51,8 @@ public class MetadataCollector { /** * Creates a new {@code MetadataProcessor} instance. - * @param processingEnvironment The processing environment of the build - * @param previousMetadata Any previous metadata or {@code null} + * @param processingEnvironment the processing environment of the build + * @param previousMetadata any previous metadata or {@code null} */ public MetadataCollector(ProcessingEnvironment processingEnvironment, ConfigurationMetadata previousMetadata) { 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 adfa25074e6..d685af3a9ab 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 - ? this.env.getElementUtils().getDocComment(element) : null); + String javadoc = (element != null) + ? this.env.getElementUtils().getDocComment(element) : null; if (javadoc != null) { javadoc = javadoc.replaceAll("[\r\n]+", "").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 0a9e85cd7b5..0d7eeb31383 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 ? new Tree(tree) : null); + 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 f9eaeee750f..24300fe57d2 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 ? new ExpressionTree(instance) : null); + 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 bb7f974da29..665f37645bf 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 @@ -169,8 +169,8 @@ public class ConfigurationMetadata { private List getCandidates(String name) { List candidates = this.items.get(name); - return (candidates != null ? new ArrayList(candidates) - : new ArrayList()); + return (candidates != null) ? new ArrayList(candidates) + : new ArrayList(); } private boolean nullSafeEquals(Object o1, Object o2) { @@ -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 67af985603c..cba6e71c06f 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 @@ -68,13 +68,6 @@ public class ItemDeprecation { this.level = level; } - @Override - public String toString() { - return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", " - + "replacement='" + this.replacement + '\'' + ", " + "level='" - + this.level + '\'' + '}'; - } - @Override public boolean equals(Object o) { if (this == o) { @@ -97,6 +90,13 @@ public class ItemDeprecation { return result; } + @Override + public String toString() { + return "ItemDeprecation{" + "reason='" + this.reason + '\'' + ", " + + "replacement='" + this.replacement + '\'' + ", " + "level='" + + this.level + '\'' + '}'; + } + private boolean nullSafeEquals(Object o1, Object o2) { if (o1 == o2) { return true; @@ -108,7 +108,7 @@ public class ItemDeprecation { } private int nullSafeHashCode(Object o) { - return (o != null ? o.hashCode() : 0); + return (o != null) ? o.hashCode() : 0; } } diff --git a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java index 1851d41ca80..bf6f872bedc 100644 --- a/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java +++ b/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,10 +44,10 @@ public class ItemHint implements Comparable { public ItemHint(String name, List values, List providers) { this.name = toCanonicalName(name); - this.values = (values != null ? new ArrayList(values) - : new ArrayList()); - this.providers = (providers != null ? new ArrayList(providers) - : new ArrayList()); + this.values = (values != null) ? new ArrayList(values) + : new ArrayList(); + this.providers = (providers != null) ? new ArrayList(providers) + : new ArrayList(); } private String toCanonicalName(String name) { 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 a16e819be56..1ca4b5ed2f2 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(); } @@ -132,17 +132,6 @@ public final class ItemMetadata implements Comparable { this.deprecation = deprecation; } - @Override - public String toString() { - StringBuilder string = new StringBuilder(this.name); - buildToStringProperty(string, "type", this.type); - buildToStringProperty(string, "sourceType", this.sourceType); - buildToStringProperty(string, "description", this.description); - buildToStringProperty(string, "defaultValue", this.defaultValue); - buildToStringProperty(string, "deprecation", this.deprecation); - return string.toString(); - } - protected void buildToStringProperty(StringBuilder string, String property, Object value) { if (value != null) { @@ -182,6 +171,17 @@ public final class ItemMetadata implements Comparable { return result; } + @Override + public String toString() { + StringBuilder string = new StringBuilder(this.name); + buildToStringProperty(string, "type", this.type); + buildToStringProperty(string, "sourceType", this.sourceType); + buildToStringProperty(string, "description", this.description); + buildToStringProperty(string, "defaultValue", this.defaultValue); + buildToStringProperty(string, "deprecation", this.deprecation); + return string.toString(); + } + private boolean nullSafeEquals(Object o1, Object o2) { if (o1 == o2) { return true; @@ -193,7 +193,7 @@ public final class ItemMetadata implements Comparable { } private int nullSafeHashCode(Object o) { - return (o != null ? o.hashCode() : 0); + 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 23bd23efabb..f0200cfac5d 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 ? this.layout.layout : null); + 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 7aefe0416b9..1ac47883439 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 - ? this.project.getConfigurations().findByName(configurationName) : null); + Configuration configuration = (configurationName != null) + ? this.project.getConfigurations().findByName(configurationName) : null; if (configuration == null) { return null; } @@ -233,11 +233,6 @@ class ProjectLibraries implements Libraries { return name; } - @Override - public int hashCode() { - return getFile().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj instanceof GradleLibrary) { @@ -246,6 +241,11 @@ class ProjectLibraries implements Libraries { return false; } + @Override + public int hashCode() { + return getFile().hashCode(); + } + @Override public String toString() { return getFile().getAbsolutePath(); @@ -321,7 +321,7 @@ class ProjectLibraries implements Libraries { String configurationName = (String) this.getTargetConfiguration .invoke(projectDependency); return projectDependency.getDependencyProject().getConfigurations() - .getByName(configurationName != null ? configurationName + .getByName((configurationName != null) ? configurationName : Dependency.DEFAULT_CONFIGURATION); } catch (Exception 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 15c369d99ee..f826ce6c44d 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,7 +145,7 @@ public class RepackageTask extends DefaultTask { SpringBootPluginExtension extension = project.getExtensions() .getByType(SpringBootPluginExtension.class); ProjectLibraries libraries = new ProjectLibraries(project, extension, - this.excludeDevtools != null ? 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 984481c867a..99febe19147 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 - ? mainSourceSet.getOutput().getResourcesDir() : null); + 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 7b7ebc6455a..0622992d5cf 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 ? value.substring(1) : matcher.group(0)); + 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 d61926ed9b7..46df824bd29 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 @@ -157,8 +157,8 @@ public class JarWriter implements LoaderClassesWriter { /** * Writes an entry. The {@code inputStream} is closed once the entry has been written - * @param entryName The name of the entry - * @param inputStream The stream from which the entry's data can be read + * @param entryName the name of the entry + * @param inputStream the stream from which the entry's data can be read * @throws IOException if the write fails */ @Override @@ -340,7 +340,7 @@ public class JarWriter implements LoaderClassesWriter { @Override public int read() throws IOException { - int read = (this.headerStream != null ? this.headerStream.read() : -1); + int read = (this.headerStream != null) ? this.headerStream.read() : -1; if (read != -1) { this.position++; if (this.position >= this.headerLength) { @@ -358,8 +358,8 @@ public class JarWriter implements LoaderClassesWriter { @Override public int read(byte[] b, int off, int len) throws IOException { - int read = (this.headerStream != null ? this.headerStream.read(b, off, len) - : -1); + int read = (this.headerStream != null) ? this.headerStream.read(b, off, len) + : -1; if (read <= 0) { return readRemainder(b, off, len); } 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 d4ba8e43d16..14df64f39e6 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 ? name : file.getName()); + 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 0c358d39733..85e505e1c7d 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 @@ -312,7 +312,7 @@ public abstract class MainClassFinder { private static List getClassEntries(JarFile source, String classesLocation) { - classesLocation = (classesLocation != null ? classesLocation : ""); + classesLocation = (classesLocation != null) ? classesLocation : ""; Enumeration sourceEntries = source.entries(); List classEntries = new ArrayList(); while (sourceEntries.hasMoreElements()) { @@ -448,16 +448,6 @@ public abstract class MainClassFinder { return this.annotationNames; } - @Override - public String toString() { - return this.name; - } - - @Override - public int hashCode() { - return this.name.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -476,6 +466,16 @@ public abstract class MainClassFinder { return true; } + @Override + public int hashCode() { + return this.name.hashCode(); + } + + @Override + public String toString() { + return this.name; + } + } /** 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 8c997121c90..58754eed147 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 ? codeSource.getLocation().toURI() : null); - String path = (location != null ? location.getSchemeSpecificPart() : null); + 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 eb167edc141..b90a3d45d30 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 ? args.clone() : null); + 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 e4b6bdd7144..4069bdf3024 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,9 +438,9 @@ public class PropertiesLauncher extends Launcher { return SystemPropertyUtils.resolvePlaceholders(this.properties, value); } } - return (defaultValue != null + return (defaultValue != null) ? SystemPropertyUtils.resolvePlaceholders(this.properties, defaultValue) - : 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 5978e5f7ea2..7e06dc7b72b 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 ? bytes.length : 0)); + this(bytes, 0, (bytes != null) ? bytes.length : 0); } public ByteArrayRandomAccessData(byte[] bytes, long offset, long length) { - this.bytes = (bytes != null ? bytes : new byte[0]); + 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 8ee6d257139..0633324f97f 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 ? b.length : 0); + 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 ? 1 : 0); + moveOn((rtn != -1) ? 1 : 0); return rtn; } else { @@ -194,7 +194,7 @@ public class RandomAccessDataFile implements RandomAccessData { @Override public long skip(long n) throws IOException { - return (n <= 0 ? 0 : moveOn(cap(n))); + return (n <= 0) ? 0 : moveOn(cap(n)); } @Override diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java index d6b2ab42b28..577a7c9ca72 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -145,11 +145,25 @@ final class AsciiBytes { } @Override - public String toString() { - if (this.string == null) { - this.string = new String(this.bytes, this.offset, this.length, UTF_8); + public boolean equals(Object obj) { + if (obj == null) { + return false; } - return this.string; + if (this == obj) { + return true; + } + if (obj.getClass().equals(AsciiBytes.class)) { + AsciiBytes other = (AsciiBytes) obj; + if (this.length == other.length) { + for (int i = 0; i < this.length; i++) { + if (this.bytes[this.offset + i] != other.bytes[other.offset + i]) { + return false; + } + } + return true; + } + } + return false; } @Override @@ -193,25 +207,11 @@ final class AsciiBytes { } @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; + public String toString() { + if (this.string == null) { + this.string = new String(this.bytes, this.offset, this.length, UTF_8); } - if (this == obj) { - return true; - } - if (obj.getClass().equals(AsciiBytes.class)) { - AsciiBytes other = (AsciiBytes) obj; - if (this.length == other.length) { - for (int i = 0; i < this.length; i++) { - if (this.bytes[this.offset + i] != other.bytes[other.offset + i]) { - return false; - } - } - return true; - } - } - return false; + return this.string; } static String toString(byte[] bytes) { 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 aa4384f7808..07e2945dbd4 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 + suffix : name)); + 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/CentralDirectoryParser.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryParser.java index 4b8a694c224..73ffc0ecd7e 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryParser.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryParser.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,7 +43,7 @@ class CentralDirectoryParser { * Parse the source data, triggering {@link CentralDirectoryVisitor visitors}. * @param data the source data * @param skipPrefixBytes if prefix bytes should be skipped - * @return The actual archive data without any prefix bytes + * @return the actual archive data without any prefix bytes * @throws IOException on error */ public RandomAccessData parse(RandomAccessData data, boolean skipPrefixBytes) 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 77e74fca094..edfc0f2ceff 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 @@ -258,7 +258,7 @@ public class Handler extends URLStreamHandler { } private int hashCode(String protocol, String file) { - int result = (protocol != null ? protocol.hashCode() : 0); + int result = (protocol != null) ? protocol.hashCode() : 0; int separatorIndex = file.indexOf(SEPARATOR); if (separatorIndex == -1) { return result + file.hashCode(); @@ -327,7 +327,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 ? cache.get(file) : null); + 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 a265a2348e1..059b3332f63 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 ? manifest.getAttributes(getName()) : null); + 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 c44070d8244..f619fa15975 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 ? this.manifest.get() : null); + 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 ? ze.getName() : null), 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 af2ca23b030..01c2039cdd6 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 @@ -246,10 +246,10 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable { boolean cacheEntry) { try { FileHeader cached = this.entriesCache.get(index); - FileHeader entry = (cached != null ? cached + FileHeader entry = (cached != null) ? cached : CentralDirectoryFileHeader.fromRandomAccessData( this.centralDirectoryData, - this.centralDirectoryOffsets[index], this.filter)); + this.centralDirectoryOffsets[index], this.filter); if (CentralDirectoryFileHeader.class.equals(entry.getClass()) && type.equals(JarEntry.class)) { entry = new JarEntry(this.jarFile, (CentralDirectoryFileHeader) entry); @@ -280,7 +280,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable { } private AsciiBytes applyFilter(AsciiBytes name) { - return (this.filter != null ? this.filter.apply(name) : 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 4a81ed10bc8..557688449f4 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 ? (int) entry.getSize() : -1); + 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 ? this.jarEntryName.getContentType() : null); + 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 ? entry.getTime() : 0); + return (entry != null) ? entry.getTime() : 0; } catch (IOException ex) { return 0; @@ -388,8 +388,8 @@ final class JarURLConnection extends java.net.JarURLConnection { private String deduceContentType() { // Guess the content type, don't bother with streams as mark is not supported String type = (isEmpty() ? "x-java/jar" : null); - type = (type != null ? type : guessContentTypeFromName(toString())); - type = (type != null ? type : "content/unknown"); + type = (type != null) ? type : guessContentTypeFromName(toString()); + type = (type != null) ? type : "content/unknown"; return type; } diff --git a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java index 79a59d11e17..46d9600ea06 100644 --- a/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java +++ b/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java @@ -84,8 +84,8 @@ class ZipInflaterInputStream extends InflaterInputStream { private static int getInflaterBufferSize(long size) { size += 2; // inflater likes some space - size = (size > 65536 ? 8192 : size); - size = (size <= 0 ? 4096 : size); + size = (size > 65536) ? 8192 : size; + size = (size <= 0) ? 4096 : size; return (int) size; } 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 bc151316940..9fd0e7ad0db 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 ? properties.getProperty(placeholderName) : null); + return (properties != null) ? properties.getProperty(placeholderName) : null; } public static String getProperty(String key) { 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 bd37ab14c8b..5b6406602f5 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 @@ -358,10 +358,11 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { private void addClasspath(List args) throws MojoExecutionException { try { StringBuilder classpath = new StringBuilder(); - for (URL ele : getClassPathUrls()) { - classpath = classpath - .append((classpath.length() > 0 ? File.pathSeparator : "") - + new File(ele.toURI())); + for (URL url : getClassPathUrls()) { + if (classpath.length() > 0) { + classpath.append(File.pathSeparator); + } + classpath.append(new File(url.toURI())); } getLog().debug("Classpath for forked process: " + classpath); args.add("-cp"); @@ -481,7 +482,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 ? this.exception : ex); + this.exception = (this.exception != null) ? this.exception : ex; } getLog().warn(ex); } @@ -511,7 +512,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { LaunchRunner(String startClassName, String... args) { this.startClassName = startClassName; - this.args = (args != null ? args : new String[] {}); + this.args = (args != null) ? args : new String[] {}; } @Override 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 e3559d0c66e..6b67ba8ad46 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 ? existing + "," + value : 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 00631d9f4e8..115ceb61b09 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 ? description.replaceAll("\\s+", " ") : null); + return (description != null) ? description.replaceAll("\\s+", " ") : null; } private void putIfMissing(Properties properties, String key, 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 c23173a33f5..54578c18601 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 @@ -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 ? Arrays.asList(exclusions.value()) - : Collections.emptyList()); + 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 0699ecc732d..9c735b70d60 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 ? sourceClass : getStartClass()); + 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 - ? sourceClass.getProtectionDomain() : null); - CodeSource codeSource = (domain != null ? domain.getCodeSource() : null); - URL location = (codeSource != null ? codeSource.getLocation() : null); - File source = (location != null ? findSource(location) : null); + 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 ? homeDir : findDefaultHomeDir()); + 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 78bc8475124..6da30aa66e5 100644 --- a/spring-boot/src/main/java/org/springframework/boot/ApplicationPid.java +++ b/spring-boot/src/main/java/org/springframework/boot/ApplicationPid.java @@ -51,16 +51,6 @@ public class ApplicationPid { } } - @Override - public String toString() { - return (this.pid != null ? this.pid : "???"); - } - - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.pid); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -72,6 +62,16 @@ public class ApplicationPid { return false; } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.pid); + } + + @Override + public String toString() { + return (this.pid != null) ? this.pid : "???"; + } + /** * Write the PID to the specified file. * @param file the PID file diff --git a/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java b/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java index c394016f158..96baa1b7e89 100644 --- a/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java +++ b/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -223,8 +223,8 @@ class BeanDefinitionLoader { } private Resource[] findResources(String source) { - ResourceLoader loader = (this.resourceLoader != null ? this.resourceLoader - : new PathMatchingResourcePatternResolver()); + ResourceLoader loader = (this.resourceLoader != null) ? this.resourceLoader + : new PathMatchingResourcePatternResolver(); try { if (loader instanceof ResourcePatternResolver) { return ((ResourcePatternResolver) loader).getResources(source); 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 f3a11dfb59f..d3234466ed6 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 ? Collections.unmodifiableList(values) : null); + return (values != null) ? Collections.unmodifiableList(values) : null; } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java b/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java index d99ca1cf1d8..35a6882ae3b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java +++ b/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,8 +65,8 @@ final class EnvironmentConverter { * environment is already a {@code StandardEnvironment} and is not a * {@link ConfigurableWebEnvironment} no conversion is performed and it is returned * unchanged. - * @param environment The Environment to convert - * @return The converted Environment + * @param environment the Environment to convert + * @return the converted Environment */ StandardEnvironment convertToStandardEnvironmentIfNecessary( ConfigurableEnvironment environment) { 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 f82cb5b4bc0..f3b1cda7f02 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 ? exitCode : 1); + 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 455777cb3f8..53cca9a46b2 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 ? sourceClass.getPackage() : null); - return (sourcePackage != null ? sourcePackage.getImplementationVersion() : null); + 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 ? sourceClass.getPackage() : null); - return (sourcePackage != null ? sourcePackage.getImplementationTitle() : null); + 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 f52889c8d7e..09a7a3b05a5 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) { @@ -901,7 +901,7 @@ public class SpringApplication { /** * Sets the {@link Banner} instance which will be used to print the banner when no * static banner file is provided. - * @param banner The Banner instance to use + * @param banner the Banner instance to use */ public void setBanner(Banner banner) { this.banner = banner; @@ -1167,7 +1167,7 @@ public class SpringApplication { } catch (Exception ex) { ex.printStackTrace(); - exitCode = (exitCode != 0 ? exitCode : 1); + 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 9cabc1e6679..5b71cbf3996 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 ? sourceClass : this.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 9b2a68b371c..40f8ab74fa5 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 ? message : "no error 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 27a8c930164..2e850961a8d 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/SpringBootVersion.java b/spring-boot/src/main/java/org/springframework/boot/SpringBootVersion.java index 095d4ef24e8..e5ef31abd00 100644 --- a/spring-boot/src/main/java/org/springframework/boot/SpringBootVersion.java +++ b/spring-boot/src/main/java/org/springframework/boot/SpringBootVersion.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,7 +41,7 @@ public final class SpringBootVersion { */ public static String getVersion() { Package pkg = SpringApplication.class.getPackage(); - return (pkg != null ? pkg.getImplementationVersion() : null); + return (pkg != null) ? pkg.getImplementationVersion() : null; } } 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 155e84f0cc4..0f065e33501 100644 --- a/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java +++ b/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java @@ -95,8 +95,8 @@ class StartupInfoLogger { } private String getApplicationName() { - return (this.sourceClass != null ? ClassUtils.getShortName(this.sourceClass) - : "application"); + return (this.sourceClass != null) ? ClassUtils.getShortName(this.sourceClass) + : "application"; } private String getVersion(final Class source) { @@ -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 fa34f1e8515..8159675e9be 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 ? new Color(rgb) : (Color) null); + this((rgb != null) ? new Color(rgb) : (Color) null); } LabColor(Color color) { @@ -117,7 +117,7 @@ public final class AnsiColors { } private double f(double t) { - return (t > (216.0 / 24389.0) ? Math.cbrt(t) + return ((t > (216.0 / 24389.0)) ? Math.cbrt(t) : (1.0 / 3.0) * Math.pow(29.0 / 6.0, 2) * t + (4.0 / 29.0)); } 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 2a277afe2e5..9912ac502e4 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 48db3879852..463e4ec6e60 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 ? patterns.toArray(new String[patterns.size()]) - : new String[] {}); + 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/PropertiesConfigurationFactory.java b/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java index 2c9c8dfa47b..5d4b80889bc 100644 --- a/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/bind/PropertiesConfigurationFactory.java @@ -260,9 +260,9 @@ public class PropertiesConfigurationFactory implements FactoryBean, } private void doBindPropertiesToTarget() throws BindException { - RelaxedDataBinder dataBinder = (this.targetName != null + RelaxedDataBinder dataBinder = (this.targetName != null) ? new RelaxedDataBinder(this.target, this.targetName) - : new RelaxedDataBinder(this.target)); + : new RelaxedDataBinder(this.target); if (this.validator != null && this.validator.supports(dataBinder.getTarget().getClass())) { dataBinder.setValidator(this.validator); @@ -292,8 +292,8 @@ public class PropertiesConfigurationFactory implements FactoryBean, } private Iterable getRelaxedTargetNames() { - return (this.target != null && StringUtils.hasLength(this.targetName) - ? new RelaxedNames(this.targetName) : null); + return (this.target != null && StringUtils.hasLength(this.targetName)) + ? new RelaxedNames(this.targetName) : null; } private Set getNames(Iterable prefixes) { @@ -365,7 +365,7 @@ public class PropertiesConfigurationFactory implements FactoryBean, logger.error("Properties configuration failed validation"); for (ObjectError error : errors.getAllErrors()) { logger.error( - this.messageSource != null + (this.messageSource != null) ? this.messageSource.getMessage(error, Locale.getDefault()) + " (" + error + ")" : error); 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 d11c93cf019..f4e9739fb31 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 5cb4f65cac8..79f6d77084e 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 @@ -86,7 +86,7 @@ public class RelaxedDataBinder extends DataBinder { /** * Create a new {@link RelaxedDataBinder} instance. * @param target the target into which properties are bound - * @param namePrefix An optional prefix to be used when reading properties + * @param namePrefix an optional prefix to be used when reading properties */ public RelaxedDataBinder(Object target, String namePrefix) { super(wrapTarget(target), @@ -394,14 +394,14 @@ public class RelaxedDataBinder extends DataBinder { if (propertyName == null) { propertyName = resolveNestedPropertyName(target, prefix, name); } - return (propertyName != null ? propertyName : name); + return (propertyName != null) ? propertyName : name; } private String resolveNestedPropertyName(BeanWrapper target, String prefix, String name) { StringBuilder candidate = new StringBuilder(); for (String field : name.split("[_\\-\\.]")) { - candidate.append(candidate.length() > 0 ? "." : ""); + candidate.append((candidate.length() > 0) ? "." : ""); candidate.append(field); String nested = resolvePropertyName(target, prefix, candidate.toString()); if (nested != null) { @@ -739,7 +739,7 @@ public class RelaxedDataBinder extends DataBinder { } private boolean isBenign(PropertyOrigin origin) { - String name = (origin != null ? origin.getSource().getName() : null); + 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 282eee70b85..2c7e0506794 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); } @@ -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 ? StringUtils.capitalize(field) : field); + (builder.length() != 0) ? StringUtils.capitalize(field) : field); } char lastChar = value.charAt(value.length() - 1); for (char suffix : SUFFIXES) { @@ -250,8 +250,8 @@ public final class RelaxedNames implements Iterable { public static RelaxedNames forCamelCase(String name) { StringBuilder result = new StringBuilder(); for (char c : name.toCharArray()) { - result.append(Character.isUpperCase(c) && result.length() > 0 - && result.charAt(result.length() - 1) != '-' + result.append((Character.isUpperCase(c) && result.length() > 0 + && result.charAt(result.length() - 1) != '-') ? "-" + Character.toLowerCase(c) : c); } return new RelaxedNames(result.toString()); 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 3e7efac773e..e3296d92046 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 698ed6d77cc..f8a848f649e 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 ? forType.get(name) : null); - return (property != null ? property : super.getProperty(type, name)); + 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/ParentContextCloserApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java index 0872aee2e76..5d35c6545ba 100644 --- a/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2015 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -103,11 +103,6 @@ public class ParentContextCloserApplicationListener } } - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.childContext.get()); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -124,6 +119,11 @@ public class ParentContextCloserApplicationListener return super.equals(obj); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.childContext.get()); + } + } } 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 a4c0a69d8d7..ab559b53d00 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 @@ -91,8 +91,8 @@ public class SpringApplicationBuilder { * Creates a new {@link org.springframework.boot.SpringApplication} instances from the * given sources. Subclasses may override in order to provide a custom subclass of * {@link org.springframework.boot.SpringApplication} - * @param sources The sources - * @return The {@link org.springframework.boot.SpringApplication} instance + * @param sources the sources + * @return the {@link org.springframework.boot.SpringApplication} instance * @since 1.1.0 */ protected SpringApplication createSpringApplication(Object... sources) { @@ -318,7 +318,7 @@ public class SpringApplicationBuilder { /** * Sets the {@link Banner} instance which will be used to print the banner when no * static banner file is provided. - * @param banner The banner to use + * @param banner the banner to use * @return the current builder */ public SpringApplicationBuilder banner(Banner banner) { @@ -389,8 +389,8 @@ public class SpringApplicationBuilder { Map map = new HashMap(); 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 key = property.substring(0, (index > 0) ? index : property.length()); + 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 ? Math.min(index, candidateIndex) : 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 72b32043414..5dc7e0cbcfe 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 197a728644e..03ffdaa5219 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 ? resourceLoader - : new DefaultResourceLoader()); + 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 ? profile.getName() : null)); + (profile != null) ? profile.getName() : null); if (propertySource != null) { msg.append("Loaded "); handleProfileProperties(propertySource); @@ -646,7 +646,7 @@ public class ConfigFileApplicationListener private Set asResolvedSet(String value, String fallback) { List list = Arrays.asList(StringUtils.trimArrayElements( - StringUtils.commaDelimitedListToStringArray(value != null + StringUtils.commaDelimitedListToStringArray((value != null) ? this.environment.resolvePlaceholders(value) : fallback))); Collections.reverse(list); return new LinkedHashSet(list); @@ -699,16 +699,6 @@ public class ConfigFileApplicationListener return this.defaultProfile; } - @Override - public String toString() { - return this.name; - } - - @Override - public int hashCode() { - return this.name.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -720,6 +710,16 @@ public class ConfigFileApplicationListener return ((Profile) obj).name.equals(this.name); } + @Override + public int hashCode() { + return this.name.hashCode(); + } + + @Override + public String toString() { + return this.name; + } + } /** 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 510c3c19d69..f491555f268 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) @@ -224,7 +224,7 @@ public abstract class AbstractEmbeddedServletContainerFactory File getCodeSourceArchive(CodeSource codeSource) { try { - URL location = (codeSource != null ? codeSource.getLocation() : null); + URL location = (codeSource != null) ? codeSource.getLocation() : null; if (location == null) { return null; } @@ -269,7 +269,7 @@ public abstract class AbstractEmbeddedServletContainerFactory /** * Returns the absolute temp dir for given servlet container. * @param prefix servlet container name - * @return The temp dir for given servlet container. + * @return the temp dir for given servlet container. */ protected File createTempDir(String prefix) { try { 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 fe566ee2649..6af23e03d2b 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 ? previous.getMimeType() : null); + 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 ? mapping.getMimeType() : null); + return (mapping != null) ? mapping.getMimeType() : null; } /** @@ -302,12 +302,7 @@ public final class MimeMappings implements Iterable { */ public String remove(String extension) { Mapping previous = this.map.remove(extension); - return (previous != null ? previous.getMimeType() : null); - } - - @Override - public int hashCode() { - return this.map.hashCode(); + return (previous != null) ? previous.getMimeType() : null; } @Override @@ -325,6 +320,11 @@ public final class MimeMappings implements Iterable { return false; } + @Override + public int hashCode() { + return this.map.hashCode(); + } + /** * Create a new unmodifiable view of the specified mapping. Methods that attempt to * modify the returned map will throw {@link UnsupportedOperationException}s. @@ -359,11 +359,6 @@ public final class MimeMappings implements Iterable { return this.mimeType; } - @Override - public int hashCode() { - return this.extension.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null) { @@ -380,6 +375,11 @@ public final class MimeMappings implements Iterable { return false; } + @Override + public int hashCode() { + return this.extension.hashCode(); + } + @Override public String toString() { return "Mapping [extension=" + this.extension + ", mimeType=" + this.mimeType diff --git a/spring-boot/src/main/java/org/springframework/boot/context/embedded/WebApplicationContextServletContextAwareProcessor.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/WebApplicationContextServletContextAwareProcessor.java index c59b651e621..f145df3d4c2 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/WebApplicationContextServletContextAwareProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/WebApplicationContextServletContextAwareProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2013 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,13 +45,13 @@ public class WebApplicationContextServletContextAwareProcessor @Override protected ServletContext getServletContext() { ServletContext servletContext = this.webApplicationContext.getServletContext(); - return (servletContext != null ? servletContext : super.getServletContext()); + return (servletContext != null) ? servletContext : super.getServletContext(); } @Override protected ServletConfig getServletConfig() { ServletConfig servletConfig = this.webApplicationContext.getServletConfig(); - return (servletConfig != null ? servletConfig : super.getServletConfig()); + return (servletConfig != null) ? servletConfig : super.getServletConfig(); } } 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 f5152e0f78c..71a6d0edc9a 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 5860e0db474..ace742784df 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 @@ -169,7 +169,7 @@ public class JettyEmbeddedServletContainerFactory public EmbeddedServletContainer getEmbeddedServletContainer( ServletContextInitializer... initializers) { JettyEmbeddedWebAppContext context = new JettyEmbeddedWebAppContext(); - int port = (getPort() >= 0 ? getPort() : 0); + int port = (getPort() >= 0) ? getPort() : 0; InetSocketAddress address = new InetSocketAddress(getAddress(), port); Server server = createServer(address); configureWebAppContext(context, initializers); @@ -404,12 +404,12 @@ public class JettyEmbeddedServletContainerFactory private File getTempDirectory() { String temp = System.getProperty("java.io.tmpdir"); - return (temp != null ? new File(temp) : null); + return (temp != null) ? new File(temp) : null; } private void configureDocumentRoot(WebAppContext handler) { File root = getValidDocumentRoot(); - root = (root != null ? root : createTempDir("jetty-docbase")); + root = (root != null) ? root : createTempDir("jetty-docbase"); try { List resources = new ArrayList(); resources.add( @@ -1013,7 +1013,7 @@ public class JettyEmbeddedServletContainerFactory SessionDirectory sessionDirectory) { SessionHandler handler = context.getSessionHandler(); Object manager = getSessionManager(handler); - setMaxInactiveInterval(manager, timeout > 0 ? timeout : -1); + setMaxInactiveInterval(manager, (timeout > 0) ? timeout : -1); if (persist) { Class hashSessionManagerClass = ClassUtils.resolveClassName( "org.eclipse.jetty.server.session.HashSessionManager", @@ -1063,7 +1063,7 @@ public class JettyEmbeddedServletContainerFactory public void configure(WebAppContext context, int timeout, boolean persist, SessionDirectory sessionDirectory) { SessionHandler handler = context.getSessionHandler(); - handler.setMaxInactiveInterval(timeout > 0 ? timeout : -1); + handler.setMaxInactiveInterval((timeout > 0) ? timeout : -1); if (persist) { DefaultSessionCache cache = new DefaultSessionCache(handler); FileSessionDataStore store = new FileSessionDataStore(); 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 1745a7fe290..f7dff90d515 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 ? jarsToSkip : this.patterns)); + (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 bc70b39a92d..60f59ce00ca 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/TomcatEmbeddedServletContainerFactory.java b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java index 155ccc2955a..2ef42de235c 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/embedded/tomcat/TomcatEmbeddedServletContainerFactory.java @@ -163,8 +163,8 @@ public class TomcatEmbeddedServletContainerFactory public EmbeddedServletContainer getEmbeddedServletContainer( ServletContextInitializer... initializers) { Tomcat tomcat = new Tomcat(); - File baseDir = (this.baseDirectory != null ? this.baseDirectory - : createTempDir("tomcat")); + File baseDir = (this.baseDirectory != null) ? this.baseDirectory + : createTempDir("tomcat"); tomcat.setBaseDir(baseDir.getAbsolutePath()); Connector connector = new Connector(this.protocol); tomcat.getService().addConnector(connector); @@ -188,7 +188,7 @@ public class TomcatEmbeddedServletContainerFactory protected void prepareContext(Host host, ServletContextInitializer[] initializers) { File docBase = getValidDocumentRoot(); - docBase = (docBase != null ? docBase : createTempDir("tomcat-docbase")); + docBase = (docBase != null) ? docBase : createTempDir("tomcat-docbase"); final TomcatEmbeddedContext context = new TomcatEmbeddedContext(); context.setName(getContextPath()); context.setDisplayName(getDisplayName()); @@ -196,7 +196,7 @@ public class TomcatEmbeddedServletContainerFactory context.setDocBase(docBase.getAbsolutePath()); context.addLifecycleListener(new FixContextListener()); context.setParentClassLoader( - this.resourceLoader != null ? this.resourceLoader.getClassLoader() + (this.resourceLoader != null) ? this.resourceLoader.getClassLoader() : ClassUtils.getDefaultClassLoader()); resetDefaultLocaleMapping(context); addLocaleMappings(context); @@ -304,7 +304,7 @@ public class TomcatEmbeddedServletContainerFactory // Needs to be protected so it can be used by subclasses protected void customizeConnector(Connector connector) { - int port = (getPort() >= 0 ? getPort() : 0); + int port = (getPort() >= 0) ? getPort() : 0; connector.setPort(port); if (StringUtils.hasText(this.getServerHeader())) { connector.setAttribute("server", this.getServerHeader()); 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 c33d8a9abe7..96016dce531 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 ? result : doLoadClass(name)); + 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 ? resultClass : findLoadedClass(name)); + 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 ? result : findClassIgnoringNotFound(name)); + return (result != null) ? result : findClassIgnoringNotFound(name); } Class result = findClassIgnoringNotFound(name); - return (result != null ? result : loadFromParent(name)); + 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 262ffdd6607..0b538b0c442 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"); + Field field = ReflectionUtils.findField(channel.getClass(), "ssl"); + String protocol = (field != null) ? "https" : "http"; return new Port(((InetSocketAddress) socketAddress).getPort(), protocol); } return null; @@ -370,16 +370,6 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine return this.number; } - @Override - public String toString() { - return this.number + " (" + this.protocol + ")"; - } - - @Override - public int hashCode() { - return this.number; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -398,6 +388,16 @@ public class UndertowEmbeddedServletContainer implements EmbeddedServletContaine return true; } + @Override + public int hashCode() { + return this.number; + } + + @Override + public String toString() { + return this.number + " (" + this.protocol + ")"; + } + } private static class CompressibleMimeTypePredicate implements Predicate { 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 126cf7b4e10..60ea5a06f5a 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 @@ -314,8 +314,8 @@ public class UndertowEmbeddedServletContainerFactory KeyManagerFactory keyManagerFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); Ssl ssl = getSsl(); - char[] keyPassword = (ssl.getKeyPassword() != null - ? ssl.getKeyPassword().toCharArray() : null); + char[] keyPassword = (ssl.getKeyPassword() != null) + ? ssl.getKeyPassword().toCharArray() : null; if (keyPassword == null && ssl.getKeyStorePassword() != null) { keyPassword = ssl.getKeyStorePassword().toCharArray(); } @@ -375,13 +375,13 @@ public class UndertowEmbeddedServletContainerFactory private KeyStore loadKeyStore(String type, String resource, String password) throws Exception { - type = (type != null ? type : "JKS"); + 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 ? password.toCharArray() : null); + store.load(url.openStream(), (password != null) ? password.toCharArray() : null); return store; } @@ -415,7 +415,7 @@ public class UndertowEmbeddedServletContainerFactory DeploymentManager manager = Servlets.newContainer().addDeployment(deployment); manager.deploy(); SessionManager sessionManager = manager.getDeployment().getSessionManager(); - int sessionTimeout = (getSessionTimeout() > 0 ? getSessionTimeout() : -1); + int sessionTimeout = (getSessionTimeout() > 0) ? getSessionTimeout() : -1; sessionManager.setDefaultSessionTimeout(sessionTimeout); return manager; } @@ -424,8 +424,8 @@ public class UndertowEmbeddedServletContainerFactory try { createAccessLogDirectoryIfNecessary(); XnioWorker worker = createWorker(); - String prefix = (this.accessLogPrefix != null ? this.accessLogPrefix - : "access_log."); + String prefix = (this.accessLogPrefix != null) ? this.accessLogPrefix + : "access_log."; final DefaultAccessLogReceiver accessLogReceiver = new DefaultAccessLogReceiver( worker, this.accessLogDirectory, prefix, this.accessLogSuffix, this.accessLogRotate); @@ -537,7 +537,7 @@ public class UndertowEmbeddedServletContainerFactory private File getCanonicalDocumentRoot() { try { File root = getValidDocumentRoot(); - root = (root != null ? root : createTempDir("undertow-docbase")); + root = (root != null) ? root : createTempDir("undertow-docbase"); return root.getCanonicalFile(); } catch (IOException ex) { 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 a945f15906c..70c3234dcbb 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 ? AnnotationUtils.findAnnotation(method, type) : null); + 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 391ba7f0e4c..f628a8ec4f0 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,7 +316,7 @@ 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 + factory.setConversionService((this.conversionService != null) ? this.conversionService : getDefaultConversionService()); if (annotation != null) { factory.setIgnoreInvalidFields(annotation.ignoreInvalidFields()); 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 9e4f80dcdfa..26685cc32d8 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 ? (Object[]) attributes.getFirst("value") - : null); + 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 b4698f25e86..181f4124f65 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 ? classLoader : context.getClassLoader()); + 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 e6b4acf2cd7..b26ee57bcfa 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 ? cycleStart : index); + cycleStart = (cycleStart != -1) ? cycleStart : index; } candidate = candidate.getCause(); } @@ -79,10 +79,10 @@ class BeanCurrentlyInCreationFailureAnalyzer message.append(String.format("┌─────┐%n")); } else if (i > 0) { - String leftSide = (i < cycleStart ? " " : "↑"); + 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")); @@ -139,11 +139,6 @@ class BeanCurrentlyInCreationFailureAnalyzer return ((UnsatisfiedDependencyException) ex).getInjectionPoint(); } - @Override - public int hashCode() { - return this.name.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -155,6 +150,11 @@ class BeanCurrentlyInCreationFailureAnalyzer return this.name.equals(((BeanInCycle) obj).name); } + @Override + public int hashCode() { + return this.name.hashCode(); + } + @Override public String toString() { return this.name + this.description; 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 529a6069636..9a017598406 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 + "#" + profile : name); + 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 a8da5cbe0db..18f293caaa2 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 @@ -98,7 +98,7 @@ public class SpringApplicationJsonEnvironmentPostProcessor /** * Flatten the map keys using period separator. - * @param map The map that should be flattened + * @param map the map that should be flattened * @return the flattened map */ private Map flatten(Map map) { @@ -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/info/GitProperties.java b/spring-boot/src/main/java/org/springframework/boot/info/GitProperties.java index 64b7f73e49f..9b7b267cfe6 100644 --- a/spring-boot/src/main/java/org/springframework/boot/info/GitProperties.java +++ b/spring-boot/src/main/java/org/springframework/boot/info/GitProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -62,7 +62,7 @@ public class GitProperties extends InfoProperties { if (id == null) { return null; } - return (id.length() > 7 ? id.substring(0, 7) : id); + return (id.length() > 7) ? id.substring(0, 7) : id; } /** diff --git a/spring-boot/src/main/java/org/springframework/boot/jackson/JsonComponentModule.java b/spring-boot/src/main/java/org/springframework/boot/jackson/JsonComponentModule.java index e35641de203..4022026e7f5 100644 --- a/spring-boot/src/main/java/org/springframework/boot/jackson/JsonComponentModule.java +++ b/spring-boot/src/main/java/org/springframework/boot/jackson/JsonComponentModule.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -57,9 +57,9 @@ public class JsonComponentModule extends SimpleModule implements BeanFactoryAwar if (beanFactory instanceof ListableBeanFactory) { addJsonBeans((ListableBeanFactory) beanFactory); } - beanFactory = (beanFactory instanceof HierarchicalBeanFactory + beanFactory = (beanFactory instanceof HierarchicalBeanFactory) ? ((HierarchicalBeanFactory) beanFactory).getParentBeanFactory() - : null); + : null; } } diff --git a/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java b/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java index 1c868f4919c..330cf29257f 100644 --- a/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java +++ b/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java @@ -260,7 +260,7 @@ public enum DatabaseDriver { /** * Find a {@link DatabaseDriver} for the given URL. - * @param url JDBC URL + * @param url the JDBC URL * @return the database driver or {@link #UNKNOWN} if not found */ public static DatabaseDriver fromJdbcUrl(String url) { 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 809a8470d90..2235fede97e 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 ? Arrays.asList(array) : Collections.emptyList()); + return (array != null) ? Arrays.asList(array) : Collections.emptyList(); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java index 225326c5268..a2dda4d3223 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -185,7 +185,7 @@ public abstract class AbstractLoggingSystem extends LoggingSystem { /** * Maintains a mapping between native levels and {@link LogLevel}. * - * @param The native level type + * @param the native level type */ protected static class LogLevels { diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java index 5e9bbe26b0d..73df6b6012d 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2017 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -72,22 +72,6 @@ public final class LoggerConfiguration { return this.name; } - @Override - public String toString() { - return "LoggerConfiguration [name=" + this.name + ", configuredLevel=" - + this.configuredLevel + ", effectiveLevel=" + this.effectiveLevel + "]"; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ObjectUtils.nullSafeHashCode(this.name); - result = prime * result + ObjectUtils.nullSafeHashCode(this.configuredLevel); - result = prime * result + ObjectUtils.nullSafeHashCode(this.effectiveLevel); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -109,4 +93,20 @@ public final class LoggerConfiguration { return super.equals(obj); } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ObjectUtils.nullSafeHashCode(this.name); + result = prime * result + ObjectUtils.nullSafeHashCode(this.configuredLevel); + result = prime * result + ObjectUtils.nullSafeHashCode(this.effectiveLevel); + return result; + } + + @Override + public String toString() { + return "LoggerConfiguration [name=" + this.name + ", configuredLevel=" + + this.configuredLevel + ", effectiveLevel=" + this.effectiveLevel + "]"; + } + } diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java index 4d33be2ff7c..829907bc23e 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -145,7 +145,7 @@ public abstract class LoggingSystem { /** * Detect and return the logging system in use. Supports Logback and Java Logging. * @param classLoader the classloader - * @return The logging system + * @return the logging system */ public static LoggingSystem get(ClassLoader classLoader) { String loggingSystem = System.getProperty(SYSTEM_PROPERTY); 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 6348973dc22..0c374fe7728 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 82083207cc3..11a7868ecf0 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 ? ELEMENTS.get(options[1]) : null); + 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 ? element : AnsiColor.GREEN); + 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 349a5cdabc3..fe93f822aaa 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 ? element : AnsiColor.GREEN); + 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 91eff815b77..07fba2b1b70 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,8 @@ 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 ? new RemappedLoggingEvent(event) : event); + logger.callAppenders( + (remapped != null) ? new RemappedLoggingEvent(event) : event); } protected AppendableLogger getLogger(String name) { @@ -88,7 +89,7 @@ public class LevelRemappingAppender extends AppenderBase { /** * Set the remapped level. - * @param remapLevels Comma separated String of remapped levels in the form + * @param remapLevels comma separated String of remapped levels in the form * {@literal "FROM->TO"}. For example, {@literal "DEBUG->TRACE,ERROR->WARN"}. */ public void setRemapLevels(String remapLevels) { @@ -140,7 +141,7 @@ public class LevelRemappingAppender extends AppenderBase { public Level getLevel() { Level remappedLevel = LevelRemappingAppender.this.remapLevels .get(this.event.getLevel()); - return (remappedLevel != null ? remappedLevel : this.event.getLevel()); + return (remappedLevel != null) ? remappedLevel : this.event.getLevel(); } @Override diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index 3e3fef8df5a..6143b950161 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -153,7 +153,7 @@ public class LogbackLoggingSystem extends Slf4JLoggingSystem { StringBuilder errors = new StringBuilder(); for (Status status : statuses) { if (status.getLevel() == Status.ERROR) { - errors.append(errors.length() > 0 ? String.format("%n") : ""); + errors.append((errors.length() > 0) ? String.format("%n") : ""); errors.append(status.toString()); } } diff --git a/spring-boot/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java b/spring-boot/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java index ca40524dede..105950c3ef2 100644 --- a/spring-boot/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java +++ b/spring-boot/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +59,7 @@ public class EntityManagerFactoryBuilder { * Create a new instance passing in the common pieces that will be shared if multiple * EntityManagerFactory instances are created. * @param jpaVendorAdapter a vendor adapter - * @param jpaProperties JPA properties to be passed to the persistence provider. + * @param jpaProperties the JPA properties to be passed to the persistence provider * @param persistenceUnitManager optional source of persistence unit information (can * be null) */ @@ -72,7 +72,7 @@ public class EntityManagerFactoryBuilder { * Create a new instance passing in the common pieces that will be shared if multiple * EntityManagerFactory instances are created. * @param jpaVendorAdapter a vendor adapter - * @param jpaProperties JPA properties to be passed to the persistence provider. + * @param jpaProperties the JPA properties to be passed to the persistence provider * @param persistenceUnitManager optional source of persistence unit information (can * be null) * @param persistenceUnitRootLocation the persistence unit root location to use as a 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 58097b83b77..124ebd08912 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 ? Boolean.parseBoolean(value) : false); + 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/system/SystemProperties.java b/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java index 6a35eb9f14d..dc8996cad2b 100644 --- a/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java +++ b/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,7 +30,7 @@ final class SystemProperties { for (String property : properties) { try { String override = System.getProperty(property); - override = (override != null ? override : System.getenv(property)); + override = (override != null) ? override : System.getenv(property); if (override != null) { return override; } 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 2f058656f82..3b2c5277079 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 ? set : Collections.emptySet()); + (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 ? set : Collections.emptySet()); + (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 e33e74ebabf..90cac0b676b 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 ? this.status.value() : 0); + 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 ? this.exception.getName() : null); + return (this.exception != null) ? this.exception.getName() : null; } /** @@ -104,16 +104,6 @@ public class ErrorPage { return (this.status == null && this.exception == null); } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ObjectUtils.nullSafeHashCode(getExceptionName()); - result = prime * result + ObjectUtils.nullSafeHashCode(this.path); - result = prime * result + this.getStatusCode(); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -134,4 +124,14 @@ public class ErrorPage { return false; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ObjectUtils.nullSafeHashCode(getExceptionName()); + result = prime * result + ObjectUtils.nullSafeHashCode(this.path); + result = prime * result + this.getStatusCode(); + return result; + } + } diff --git a/spring-boot/src/main/java/org/springframework/boot/web/servlet/RegistrationBean.java b/spring-boot/src/main/java/org/springframework/boot/web/servlet/RegistrationBean.java index 1f2f25082b9..7dbd856c9a9 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/servlet/RegistrationBean.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/servlet/RegistrationBean.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,7 +126,7 @@ public abstract class RegistrationBean implements ServletContextInitializer, Ord * @return the deduced name */ protected final String getOrDeduceName(Object value) { - return (this.name != null ? this.name : Conventions.getVariableName(value)); + return (this.name != null) ? this.name : Conventions.getVariableName(value); } /** 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 a638a5fda7e..b4faa9dc363 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 999969310fa..67bc4adb4f3 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 @@ -207,8 +207,8 @@ public class ErrorPageFilter implements Filter, ErrorPageRegistry { * @since 1.5.0 */ protected String getDescription(HttpServletRequest request) { - return "[" + request.getServletPath() - + (request.getPathInfo() != null ? request.getPathInfo() : "") + "]"; + String pathInfo = (request.getPathInfo() != null) ? request.getPathInfo() : ""; + return "[" + request.getServletPath() + pathInfo + "]"; } 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 d4c797257a3..5ff93b16574 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,10 +95,10 @@ public class SpringProfileDocumentMatcher implements DocumentMatcher { } private ProfilesMatcher getProfilesMatcher() { - return (this.activeProfiles.length != 0 + return (this.activeProfiles.length != 0) ? new ActiveProfilesMatcher( new HashSet(Arrays.asList(this.activeProfiles))) - : new EmptyProfilesMatcher()); + : new EmptyProfilesMatcher(); } private Set extractProfiles(List profiles, ProfileType type) { @@ -112,7 +112,7 @@ public class SpringProfileDocumentMatcher implements DocumentMatcher { candidateType = ProfileType.NEGATIVE; } if (candidateType == type) { - extractedProfiles.add(type != ProfileType.POSITIVE + extractedProfiles.add((type != ProfileType.POSITIVE) ? candidate.substring(1) : candidate); } } 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 350cd1e7ea5..e4ecaa6fe44 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 ? resource : new ClassPathResource("doesnotexist")); + 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 85b415df120..1ab22d50393 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 497d71960c5..45829b19a3a 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 ? getContainer().servletContext : null); + return (getContainer() != null) ? getContainer().servletContext : null; } public RegisteredServlet getRegisteredServlet(int index) { - return (getContainer() != null ? getContainer().getRegisteredServlets().get(index) - : null); + return (getContainer() != null) + ? getContainer().getRegisteredServlets().get(index) : null; } public RegisteredFilter getRegisteredFilter(int index) { - return (getContainer() != null ? getContainer().getRegisteredFilters().get(index) - : null); + 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 4737cb96604..12e2d40a03f 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 @@ -482,7 +482,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 f652a4e1012..5a0edda05f0 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 b37c7d82a2a..db626fbfb8d 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