diff --git a/pom.xml b/pom.xml index d673e1dc10..02075aa623 100644 --- a/pom.xml +++ b/pom.xml @@ -24,7 +24,7 @@ - 0.0.3 + 0.0.6 @@ -36,7 +36,7 @@ com.puppycrawl.tools checkstyle - 8.8 + 8.11 io.spring.javaformat diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java index 38566757bf..c1216fb362 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/CloudFoundryWebEndpointDiscoverer.java @@ -72,7 +72,7 @@ public class CloudFoundryWebEndpointDiscoverer extends WebEndpointDiscoverer { AnnotationAttributes attributes = AnnotatedElementUtils .getMergedAnnotationAttributes(extensionBean.getClass(), EndpointWebExtension.class); - Class endpoint = (attributes != null ? attributes.getClass("endpoint") : null); + Class endpoint = (attributes != null) ? attributes.getClass("endpoint") : null; return (endpoint != null && HealthEndpoint.class.isAssignableFrom(endpoint)); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java index 2638905105..efd7ee2ebd 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/reactive/ReactiveCloudFoundryActuatorAutoConfiguration.java @@ -126,8 +126,8 @@ public class ReactiveCloudFoundryActuatorAutoConfiguration { String cloudControllerUrl = environment.getProperty("vcap.application.cf_api"); boolean skipSslValidation = environment.getProperty( "management.cloudfoundry.skip-ssl-validation", Boolean.class, false); - return (cloudControllerUrl != null ? new ReactiveCloudFoundrySecurityService( - webClientBuilder, cloudControllerUrl, skipSslValidation) : null); + return (cloudControllerUrl != null) ? new ReactiveCloudFoundrySecurityService( + webClientBuilder, cloudControllerUrl, skipSslValidation) : null; } private CorsConfiguration getCorsConfiguration() { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java index 9f7d5f5b46..343af361cc 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java @@ -130,8 +130,8 @@ public class CloudFoundryActuatorAutoConfiguration { String cloudControllerUrl = environment.getProperty("vcap.application.cf_api"); boolean skipSslValidation = environment.getProperty( "management.cloudfoundry.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-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java index ba471945a9..35818c14e9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/condition/ConditionsReportEndpoint.java @@ -125,8 +125,8 @@ public class ConditionsReportEndpoint { this.unconditionalClasses = report.getUnconditionalClasses(); report.getConditionAndOutcomesBySource().forEach( (source, conditionAndOutcomes) -> add(source, conditionAndOutcomes)); - this.parentId = (context.getParent() != null ? context.getParent().getId() - : null); + this.parentId = (context.getParent() != null) ? context.getParent().getId() + : null; } private void add(String source, ConditionAndOutcomes conditionAndOutcomes) { diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java index ecb984b9d5..47ea3b0c54 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/elasticsearch/ElasticsearchHealthIndicatorAutoConfiguration.java @@ -82,7 +82,7 @@ public class ElasticsearchHealthIndicatorAutoConfiguration { protected ElasticsearchHealthIndicator createHealthIndicator(Client client) { Duration responseTimeout = this.properties.getResponseTimeout(); return new ElasticsearchHealthIndicator(client, - responseTimeout != null ? responseTimeout.toMillis() : 100, + (responseTimeout != null) ? responseTimeout.toMillis() : 100, this.properties.getIndices()); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java index 2c2ec8aadb..d61b0370c9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/ExposeExcludePropertyEndpointFilter.java @@ -36,7 +36,7 @@ import org.springframework.util.Assert; * {@link EndpointFilter} that will filter endpoints based on {@code include} and * {@code exclude} properties. * - * @param The endpoint type + * @param the endpoint type * @author Phillip Webb * @since 2.0.0 */ diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java index 4f1f155ee6..9484ac44fe 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/jdbc/DataSourceHealthIndicatorAutoConfiguration.java @@ -112,7 +112,7 @@ public class DataSourceHealthIndicatorAutoConfiguration extends 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-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java index b1907d7b3a..198a3e994c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryConfigurer.java @@ -51,9 +51,9 @@ class MeterRegistryConfigurer { Collection filters, Collection> customizers, boolean addToGlobalRegistry) { - this.binders = (binders != null ? binders : Collections.emptyList()); - this.filters = (filters != null ? filters : Collections.emptyList()); - this.customizers = (customizers != null ? customizers : Collections.emptyList()); + this.binders = (binders != null) ? binders : Collections.emptyList(); + this.filters = (filters != null) ? filters : Collections.emptyList(); + this.customizers = (customizers != null) ? customizers : Collections.emptyList(); this.addToGlobalRegistry = addToGlobalRegistry; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryCustomizer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryCustomizer.java index 0f1775d117..97c8670815 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryCustomizer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/MeterRegistryCustomizer.java @@ -27,7 +27,7 @@ import io.micrometer.core.instrument.MeterRegistry; * the registry. * * @author Jon Schneider - * @param The registry type to customize + * @param the registry type to customize * @since 2.0.0 */ @FunctionalInterface diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java index cadd7c36e5..99d89e22c0 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java @@ -90,10 +90,10 @@ public class PropertiesMeterFilter implements MeterFilter { } private long[] convertSla(Meter.Type meterType, ServiceLevelAgreementBoundary[] sla) { - long[] converted = Arrays.stream(sla != null ? sla : EMPTY_SLA) + long[] converted = Arrays.stream((sla != null) ? sla : EMPTY_SLA) .map((candidate) -> candidate.getValue(meterType)) .filter(Objects::nonNull).mapToLong(Long::longValue).toArray(); - return (converted.length != 0 ? converted : null); + return (converted.length != 0) ? converted : null; } private T lookup(Map values, Id id, T defaultValue) { @@ -107,7 +107,7 @@ public class PropertiesMeterFilter implements MeterFilter { return result; } int lastDot = name.lastIndexOf('.'); - name = (lastDot != -1 ? name.substring(0, lastDot) : ""); + name = (lastDot != -1) ? name.substring(0, lastDot) : ""; } return values.getOrDefault("all", defaultValue); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/PropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/PropertiesConfigAdapter.java index 90eead2575..8f40ea3f7e 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/PropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/PropertiesConfigAdapter.java @@ -24,7 +24,7 @@ import org.springframework.util.Assert; /** * Base class for properties to config adapters. * - * @param The properties type + * @param the properties type * @author Phillip Webb * @author Nikolay Rybak * @since 2.0.0 @@ -51,7 +51,7 @@ public class PropertiesConfigAdapter { */ protected final V get(Function getter, Supplier fallback) { V value = getter.apply(this.properties); - return (value != null ? value : fallback.get()); + return (value != null) ? value : fallback.get(); } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesConfigAdapter.java index f087c376d5..f8e758d7e7 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/properties/StepRegistryPropertiesConfigAdapter.java @@ -23,7 +23,7 @@ import io.micrometer.core.instrument.step.StepRegistryConfig; /** * Base class for {@link StepRegistryProperties} to {@link StepRegistryConfig} adapters. * - * @param The properties type + * @param the properties type * @author Jon Schneider * @author Phillip Webb * @since 2.0.0 diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java index 5d873338ba..3151cddca2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/export/wavefront/WavefrontPropertiesConfigAdapter.java @@ -60,7 +60,7 @@ public class WavefrontPropertiesConfigAdapter } private String getUriAsString(WavefrontProperties properties) { - return (properties.getUri() != null ? properties.getUri().toString() : null); + return (properties.getUri() != null) ? properties.getUri().toString() : null; } } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java index ba2ff2570c..6d37da4f4d 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/web/tomcat/TomcatMetricsAutoConfiguration.java @@ -47,7 +47,8 @@ public class TomcatMetricsAutoConfiguration { @Bean @ConditionalOnMissingBean public TomcatMetrics tomcatMetrics() { - return new TomcatMetrics(this.context != null ? this.context.getManager() : null, + return new TomcatMetrics( + (this.context != null) ? this.context.getManager() : null, Collections.emptyList()); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java index ad9c37f9a5..0c4b8a8896 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextConfigurationImportSelector.java @@ -125,17 +125,17 @@ class ManagementContextConfigurationImportSelector Map annotationAttributes = annotationMetadata .getAnnotationAttributes( ManagementContextConfiguration.class.getName()); - return (annotationAttributes != null + return (annotationAttributes != null) ? (ManagementContextType) annotationAttributes.get("value") - : ManagementContextType.ANY); + : ManagementContextType.ANY; } 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-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementPortType.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementPortType.java index cbea996445..eccc7b59e1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementPortType.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementPortType.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. @@ -47,9 +47,9 @@ public enum ManagementPortType { if (managementPort != null && managementPort < 0) { return DISABLED; } - return ((managementPort == null) + return ((managementPort == null || (serverPort == null && managementPort.equals(8080)) - || (managementPort != 0 && managementPort.equals(serverPort)) ? SAME + || (managementPort != 0 && managementPort.equals(serverPort))) ? SAME : DIFFERENT); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/MockServletWebServerFactory.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/MockServletWebServerFactory.java index 6d4dcc8037..c364634cc5 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/MockServletWebServerFactory.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/MockServletWebServerFactory.java @@ -52,17 +52,17 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory } public ServletContext getServletContext() { - return (getWebServer() != null ? getWebServer().getServletContext() : null); + return (getWebServer() != null) ? getWebServer().getServletContext() : null; } public RegisteredServlet getRegisteredServlet(int index) { - return (getWebServer() != null ? getWebServer().getRegisteredServlet(index) - : null); + return (getWebServer() != null) ? getWebServer().getRegisteredServlet(index) + : null; } public RegisteredFilter getRegisteredFilter(int index) { - return (getWebServer() != null ? getWebServer().getRegisteredFilters(index) - : null); + return (getWebServer() != null) ? getWebServer().getRegisteredFilters(index) + : null; } public static class MockServletWebServer diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java index e8cdb500a7..58a7a2a0fc 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEvent.java @@ -55,9 +55,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(Instant.now(), principal, type, data); @@ -66,9 +66,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(Instant.now(), principal, type, convert(data)); @@ -76,17 +76,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(Instant 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-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEventsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEventsEndpoint.java index f5936ef18c..913bf8fc4d 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEventsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/audit/AuditEventsEndpoint.java @@ -50,7 +50,7 @@ public class AuditEventsEndpoint { } private Instant getInstant(OffsetDateTime offsetDateTime) { - return (offsetDateTime != null ? offsetDateTime.toInstant() : null); + return (offsetDateTime != null) ? offsetDateTime.toInstant() : null; } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/beans/BeansEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/beans/BeansEndpoint.java index aefaf59ed4..4f1446297d 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/beans/BeansEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/beans/BeansEndpoint.java @@ -118,7 +118,7 @@ public class BeansEndpoint { } ConfigurableApplicationContext parent = getConfigurableParent(context); return new ContextBeans(describeBeans(context.getBeanFactory()), - parent != null ? parent.getId() : null); + (parent != null) ? parent.getId() : null); } private static Map describeBeans( diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java index 4dd46dc166..d7275ba376 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpoint.java @@ -118,7 +118,7 @@ public class ConfigurationPropertiesReportEndpoint implements ApplicationContext prefix, sanitize(prefix, safeSerialize(mapper, bean, prefix)))); }); return new ContextConfigurationProperties(beanDescriptors, - context.getParent() != null ? context.getParent().getId() : null); + (context.getParent() != null) ? context.getParent().getId() : null); } private ConfigurationBeanFactoryMetadata getBeanFactoryMetadata( diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java index 5fdd8d3ad8..3b2cd6d797 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/elasticsearch/ElasticsearchHealthIndicator.java @@ -55,7 +55,7 @@ public class ElasticsearchHealthIndicator extends AbstractHealthIndicator { public ElasticsearchHealthIndicator(Client client, long responseTimeout, List indices) { this(client, responseTimeout, - (indices != null ? StringUtils.toStringArray(indices) : null)); + (indices != null) ? StringUtils.toStringArray(indices) : null); } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractExposableEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractExposableEndpoint.java index b8e6e41e8b..c7a87cdf2b 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractExposableEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/AbstractExposableEndpoint.java @@ -26,7 +26,7 @@ import org.springframework.util.Assert; /** * Abstract base class for {@link ExposableEndpoint} implementations. * - * @param The operation type. + * @param the operation type. * @author Phillip Webb * @since 2.0.0 */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java index 622c80dd97..6cd73db8e8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/AbstractDiscoveredEndpoint.java @@ -28,7 +28,7 @@ import org.springframework.util.Assert; * Abstract base class for {@link ExposableEndpoint endpoints} discovered by a * {@link EndpointDiscoverer}. * - * @param The operation type + * @param the operation type * @author Phillip Webb * @since 2.0.0 */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredEndpoint.java index 73a917b98c..25e3543a4d 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredEndpoint.java @@ -22,7 +22,7 @@ import org.springframework.boot.actuate.endpoint.Operation; /** * An {@link ExposableEndpoint endpoint} discovered by an {@link EndpointDiscoverer}. * - * @param The operation type + * @param the operation type * @author Phillip Webb * @since 2.0.0 */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredOperationsFactory.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredOperationsFactory.java index 4b9b64527c..6a900109a0 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredOperationsFactory.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/DiscoveredOperationsFactory.java @@ -40,7 +40,7 @@ import org.springframework.core.annotation.AnnotationAttributes; * Factory to create an {@link Operation} for annotated methods on an * {@link Endpoint @Endpoint} or {@link EndpointExtension @EndpointExtension}. * - * @param The operation type + * @param the operation type * @author Andy Wilkinson * @author Stephane Nicoll * @author Phillip Webb diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java index 7c462310da..e01b0a91bd 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java @@ -54,8 +54,8 @@ import org.springframework.util.StringUtils; * {@link Endpoint @Endpoint} beans and {@link EndpointExtension @EndpointExtension} beans * in an application context. * - * @param The endpoint type - * @param The operation type + * @param the endpoint type + * @param the operation type * @author Andy Wilkinson * @author Stephane Nicoll * @author Phillip Webb @@ -382,11 +382,6 @@ public abstract class EndpointDiscoverer, O exten this.description = description; } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -398,6 +393,11 @@ public abstract class EndpointDiscoverer, O exten return this.key.equals(((OperationKey) obj).key); } + @Override + public int hashCode() { + return this.key.hashCode(); + } + @Override public String toString() { return this.description.get(); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapper.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapper.java index 13653db37f..2989b7fbe7 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapper.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/jmx/JacksonJmxOperationResponseMapper.java @@ -39,7 +39,7 @@ public class JacksonJmxOperationResponseMapper implements JmxOperationResponseMa private final JavaType mapType; public JacksonJmxOperationResponseMapper(ObjectMapper objectMapper) { - this.objectMapper = (objectMapper != null ? objectMapper : new ObjectMapper()); + this.objectMapper = (objectMapper != null) ? objectMapper : new ObjectMapper(); this.listType = this.objectMapper.getTypeFactory() .constructParametricType(List.class, Object.class); this.mapType = this.objectMapper.getTypeFactory() diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java index b3d3b97eab..b2d270fb20 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/PathMappedEndpoints.java @@ -46,7 +46,7 @@ public class PathMappedEndpoints implements Iterable { */ public PathMappedEndpoints(String basePath, EndpointsSupplier supplier) { Assert.notNull(supplier, "Supplier must not be null"); - this.basePath = (basePath != null ? basePath : ""); + this.basePath = (basePath != null) ? basePath : ""; this.endpoints = getEndpoints(Collections.singleton(supplier)); } @@ -58,7 +58,7 @@ public class PathMappedEndpoints implements Iterable { public PathMappedEndpoints(String basePath, Collection> suppliers) { Assert.notNull(suppliers, "Suppliers must not be null"); - this.basePath = (basePath != null ? basePath : ""); + this.basePath = (basePath != null) ? basePath : ""; this.endpoints = getEndpoints(suppliers); } @@ -91,7 +91,7 @@ public class PathMappedEndpoints implements Iterable { */ public String getRootPath(String endpointId) { PathMappedEndpoint endpoint = getEndpoint(endpointId); - return (endpoint != null ? endpoint.getRootPath() : null); + return (endpoint != null) ? endpoint.getRootPath() : null; } /** @@ -144,7 +144,7 @@ public class PathMappedEndpoints implements Iterable { } private String getPath(PathMappedEndpoint endpoint) { - return (endpoint != null ? this.basePath + "/" + endpoint.getRootPath() : null); + return (endpoint != null) ? this.basePath + "/" + endpoint.getRootPath() : null; } private List asList(Stream stream) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java index 26f761962b..bc4daca0a3 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java @@ -47,7 +47,7 @@ public class ServletEndpointRegistrar implements ServletContextInitializer { public ServletEndpointRegistrar(String basePath, Collection servletEndpoints) { Assert.notNull(servletEndpoints, "ServletEndpoints must not be null"); - this.basePath = (basePath != null ? basePath : ""); + this.basePath = (basePath != null) ? basePath : ""; this.servletEndpoints = servletEndpoints; } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperationRequestPredicate.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperationRequestPredicate.java index cf8494b2f5..f571c08df4 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperationRequestPredicate.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/WebOperationRequestPredicate.java @@ -88,32 +88,6 @@ public final class WebOperationRequestPredicate { return Collections.unmodifiableCollection(this.produces); } - @Override - public String toString() { - StringBuilder result = new StringBuilder( - this.httpMethod + " to path '" + this.path + "'"); - if (!CollectionUtils.isEmpty(this.consumes)) { - result.append(" consumes: " - + StringUtils.collectionToCommaDelimitedString(this.consumes)); - } - if (!CollectionUtils.isEmpty(this.produces)) { - result.append(" produces: " - + StringUtils.collectionToCommaDelimitedString(this.produces)); - } - return result.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + this.consumes.hashCode(); - result = prime * result + this.httpMethod.hashCode(); - result = prime * result + this.canonicalPath.hashCode(); - result = prime * result + this.produces.hashCode(); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -131,4 +105,30 @@ public final class WebOperationRequestPredicate { return result; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + this.consumes.hashCode(); + result = prime * result + this.httpMethod.hashCode(); + result = prime * result + this.canonicalPath.hashCode(); + result = prime * result + this.produces.hashCode(); + return result; + } + + @Override + public String toString() { + StringBuilder result = new StringBuilder( + this.httpMethod + " to path '" + this.path + "'"); + if (!CollectionUtils.isEmpty(this.consumes)) { + result.append(" consumes: " + + StringUtils.collectionToCommaDelimitedString(this.consumes)); + } + if (!CollectionUtils.isEmpty(this.produces)) { + result.append(" produces: " + + StringUtils.collectionToCommaDelimitedString(this.produces)); + } + return result.toString(); + } + } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java index 4a9bbe5f92..b007915524 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/jersey/JerseyEndpointResourceFactory.java @@ -179,7 +179,7 @@ public class JerseyEndpointResourceFactory { Map result = new HashMap<>(); multivaluedMap.forEach((name, values) -> { if (!CollectionUtils.isEmpty(values)) { - result.put(name, values.size() != 1 ? values : values.get(0)); + result.put(name, (values.size() != 1) ? values : values.get(0)); } }); return result; diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java index d666810e24..060ae160b8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/AbstractWebFluxEndpointHandlerMapping.java @@ -310,7 +310,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping arguments.putAll(body); } exchange.getRequest().getQueryParams().forEach((name, values) -> arguments - .put(name, values.size() != 1 ? values : values.get(0))); + .put(name, (values.size() != 1) ? values : values.get(0))); return arguments; } @@ -324,7 +324,7 @@ public abstract class AbstractWebFluxEndpointHandlerMapping .onErrorMap(InvalidEndpointRequestException.class, (ex) -> new ResponseStatusException(HttpStatus.BAD_REQUEST, ex.getReason())) - .defaultIfEmpty(new ResponseEntity<>(httpMethod != HttpMethod.GET + .defaultIfEmpty(new ResponseEntity<>((httpMethod != HttpMethod.GET) ? HttpStatus.NO_CONTENT : HttpStatus.NOT_FOUND)); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java index 20dc83ea4e..a689ec4d0d 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/AbstractWebMvcEndpointHandlerMapping.java @@ -257,7 +257,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping arguments.putAll(body); } request.getParameterMap().forEach((name, values) -> arguments.put(name, - values.length != 1 ? Arrays.asList(values) : values[0])); + (values.length != 1) ? Arrays.asList(values) : values[0])); return arguments; } @@ -269,7 +269,7 @@ public abstract class AbstractWebMvcEndpointHandlerMapping private Object handleResult(Object result, HttpMethod httpMethod) { if (result == null) { - return new ResponseEntity<>(httpMethod != HttpMethod.GET + return new ResponseEntity<>((httpMethod != HttpMethod.GET) ? HttpStatus.NO_CONTENT : HttpStatus.NOT_FOUND); } if (!(result instanceof WebEndpointResponse)) { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java index 71d644d641..8280882cc2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/env/EnvironmentEndpoint.java @@ -160,7 +160,7 @@ public class EnvironmentEndpoint { private String getOrigin(OriginLookup lookup, String name) { Origin origin = lookup.getOrigin(name); - return (origin != null ? origin.toString() : null); + return (origin != null) ? origin.toString() : null; } private PlaceholdersResolver getResolver() { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java index 6f578acfc6..f8a1c4f497 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/flyway/FlywayEndpoint.java @@ -59,7 +59,7 @@ public class FlywayEndpoint { .put(name, new FlywayDescriptor(flyway.info().all()))); ApplicationContext parent = target.getParent(); contextFlywayBeans.put(target.getId(), new ContextFlywayBeans(flywayBeans, - parent != null ? parent.getId() : null)); + (parent != null) ? parent.getId() : null)); target = parent; } return new ApplicationFlywayBeans(contextFlywayBeans); @@ -170,7 +170,7 @@ public class FlywayEndpoint { } 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-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java index e1c4858bb4..756f82a92c 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/CompositeReactiveHealthIndicator.java @@ -82,8 +82,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator ReactiveHealthIndicatorRegistry registry) { this.registry = registry; this.healthAggregator = healthAggregator; - this.timeoutCompose = (mono) -> (this.timeout != null ? mono.timeout( - Duration.ofMillis(this.timeout), Mono.just(this.timeoutHealth)) : mono); + this.timeoutCompose = (mono) -> (this.timeout != null) ? mono.timeout( + Duration.ofMillis(this.timeout), Mono.just(this.timeoutHealth)) : mono; } /** @@ -115,8 +115,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator public CompositeReactiveHealthIndicator timeoutStrategy(long timeout, Health timeoutHealth) { this.timeout = timeout; - this.timeoutHealth = (timeoutHealth != null ? timeoutHealth - : Health.unknown().build()); + this.timeoutHealth = (timeoutHealth != null) ? timeoutHealth + : Health.unknown().build(); return this; } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java index a459b0d21f..39042a1133 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/OrderedHealthAggregator.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,7 +98,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-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java index c3a5d89b70..b62ec82388 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/health/Status.java +++ b/spring-boot-project/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-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java index faf1d7a3c3..38373dfce8 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/jdbc/DataSourceHealthIndicator.java @@ -86,7 +86,7 @@ public class DataSourceHealthIndicator extends AbstractHealthIndicator super("DataSource health check failed"); this.dataSource = dataSource; this.query = query; - this.jdbcTemplate = (dataSource != null ? new JdbcTemplate(dataSource) : null); + this.jdbcTemplate = (dataSource != null) ? new JdbcTemplate(dataSource) : null; } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java index f3283c7341..1dd4b551b3 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/liquibase/LiquibaseEndpoint.java @@ -69,7 +69,7 @@ public class LiquibaseEndpoint { createReport(liquibase, service, factory))); ApplicationContext parent = target.getParent(); contextBeans.put(target.getId(), new ContextLiquibaseBeans(liquibaseBeans, - parent != null ? parent.getId() : null)); + (parent != null) ? parent.getId() : null)); target = parent; } return new ApplicationLiquibaseBeans(contextBeans); @@ -210,7 +210,7 @@ public class LiquibaseEndpoint { this.execType = ranChangeSet.getExecType(); this.id = ranChangeSet.getId(); this.labels = ranChangeSet.getLabels().getLabels(); - this.checksum = (ranChangeSet.getLastCheckSum() != null + this.checksum = ((ranChangeSet.getLastCheckSum() != null) ? ranChangeSet.getLastCheckSum().toString() : null); this.orderExecuted = ranChangeSet.getOrderExecuted(); this.tag = ranChangeSet.getTag(); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java index 6454b3526f..b5fae560a1 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/logging/LoggersEndpoint.java @@ -73,7 +73,7 @@ public class LoggersEndpoint { 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; } @WriteOperation @@ -112,7 +112,7 @@ public class LoggersEndpoint { } 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-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java index 9138ef1dd7..c82731c955 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/management/HeapDumpWebEndpoint.java @@ -78,7 +78,7 @@ public class HeapDumpWebEndpoint { if (this.lock.tryLock(this.timeout, TimeUnit.MILLISECONDS)) { try { return new WebEndpointResponse<>( - dumpHeap(live != null ? live : true)); + dumpHeap((live != null) ? live : true)); } finally { this.lock.unlock(); diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/amqp/RabbitMetrics.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/amqp/RabbitMetrics.java index 05be8e9eb2..c248c6115a 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/amqp/RabbitMetrics.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/amqp/RabbitMetrics.java @@ -47,7 +47,7 @@ public class RabbitMetrics implements MeterBinder { public RabbitMetrics(ConnectionFactory connectionFactory, Iterable tags) { Assert.notNull(connectionFactory, "ConnectionFactory must not be null"); this.connectionFactory = connectionFactory; - this.tags = (tags != null ? tags : Collections.emptyList()); + this.tags = (tags != null) ? tags : Collections.emptyList(); } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMeterBinderProvider.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMeterBinderProvider.java index 3d44d5d64f..f8ae3ed9a2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMeterBinderProvider.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/cache/CacheMeterBinderProvider.java @@ -24,7 +24,7 @@ import org.springframework.cache.Cache; /** * Provide a {@link MeterBinder} based on a {@link Cache}. * - * @param The cache type + * @param the cache type * @author Stephane Nicoll * @since 2.0.0 */ diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java index 60139b4324..9725c60c4f 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/client/RestTemplateExchangeTags.java @@ -73,7 +73,7 @@ public final class RestTemplateExchangeTags { } private static String ensureLeadingSlash(String url) { - return (url == null || url.startsWith("/") ? url : "/" + url); + return (url == null || url.startsWith("/")) ? url : "/" + url; } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java index c24fe63097..c64c644cbd 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/metrics/web/servlet/WebMvcTags.java @@ -60,7 +60,7 @@ public final class WebMvcTags { * @return the method tag whose value is a capitalized method (e.g. GET). */ public static Tag method(HttpServletRequest request) { - return (request != null ? Tag.of("method", request.getMethod()) : METHOD_UNKNOWN); + return (request != null) ? Tag.of("method", request.getMethod()) : METHOD_UNKNOWN; } /** @@ -69,9 +69,9 @@ public final class WebMvcTags { * @return the status tag derived from the status of the response */ public static Tag status(HttpServletResponse response) { - return (response != null + return (response != null) ? Tag.of("status", Integer.toString(response.getStatus())) - : STATUS_UNKNOWN); + : STATUS_UNKNOWN; } /** diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java index e88969ccc6..27d18b1625 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/solr/SolrHealthIndicator.java @@ -48,7 +48,7 @@ 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("status", statusCode); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/MappingsEndpoint.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/MappingsEndpoint.java index 6c647e6271..3014e59058 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/MappingsEndpoint.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/MappingsEndpoint.java @@ -59,7 +59,7 @@ public class MappingsEndpoint { this.descriptionProviders .forEach((provider) -> mappings.put(provider.getMappingName(), provider.describeMappings(applicationContext))); - return new ContextMappings(mappings, applicationContext.getParent() != null + return new ContextMappings(mappings, (applicationContext.getParent() != null) ? applicationContext.getId() : null); } diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java index 4ab0d3b899..d2afc78f34 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/mappings/servlet/DispatcherServletHandlerMappings.java @@ -64,7 +64,7 @@ final class DispatcherServletHandlerMappings { initializeDispatcherServletIfPossible(); handlerMappings = this.dispatcherServlet.getHandlerMappings(); } - return (handlerMappings != null ? handlerMappings : Collections.emptyList()); + return (handlerMappings != null) ? handlerMappings : Collections.emptyList(); } private void initializeDispatcherServletIfPossible() { diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/HttpTraceWebFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/HttpTraceWebFilter.java index 837adc2cfe..6809c23d69 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/HttpTraceWebFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/HttpTraceWebFilter.java @@ -98,8 +98,8 @@ public class HttpTraceWebFilter implements WebFilter, Ordered { HttpTrace trace = this.tracer.receivedRequest(request); return chain.filter(exchange).doAfterSuccessOrError((aVoid, ex) -> { TraceableServerHttpResponse response = new TraceableServerHttpResponse( - (ex != null ? new CustomStatusResponseDecorator(ex, - exchange.getResponse()) : exchange.getResponse())); + (ex != null) ? new CustomStatusResponseDecorator(ex, + exchange.getResponse()) : exchange.getResponse()); this.tracer.sendingResponse(trace, response, () -> principal, () -> getStartedSessionId(session)); this.repository.add(trace); @@ -107,7 +107,7 @@ public class HttpTraceWebFilter implements WebFilter, Ordered { } private String getStartedSessionId(WebSession session) { - return (session != null && session.isStarted() ? session.getId() : null); + return (session != null && session.isStarted()) ? session.getId() : null; } private static final class CustomStatusResponseDecorator @@ -117,9 +117,9 @@ public class HttpTraceWebFilter implements WebFilter, Ordered { private CustomStatusResponseDecorator(Throwable ex, ServerHttpResponse delegate) { super(delegate); - this.status = (ex instanceof ResponseStatusException + this.status = (ex instanceof ResponseStatusException) ? ((ResponseStatusException) ex).getStatus() - : HttpStatus.INTERNAL_SERVER_ERROR); + : HttpStatus.INTERNAL_SERVER_ERROR; } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/ServerWebExchangeTraceableRequest.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/ServerWebExchangeTraceableRequest.java index 9daace7a71..a70a9ce2f1 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/ServerWebExchangeTraceableRequest.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/ServerWebExchangeTraceableRequest.java @@ -45,8 +45,8 @@ class ServerWebExchangeTraceableRequest implements TraceableRequest { this.method = request.getMethodValue(); this.headers = request.getHeaders(); this.uri = request.getURI(); - this.remoteAddress = (request.getRemoteAddress() != null - ? request.getRemoteAddress().getAddress().toString() : null); + this.remoteAddress = (request.getRemoteAddress() != null) + ? request.getRemoteAddress().getAddress().toString() : null; } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/TraceableServerHttpResponse.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/TraceableServerHttpResponse.java index 9721d0fb3f..db1f44c71c 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/TraceableServerHttpResponse.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/reactive/TraceableServerHttpResponse.java @@ -38,8 +38,8 @@ class TraceableServerHttpResponse implements TraceableResponse { @Override public int getStatus() { - return (this.response.getStatusCode() != null - ? this.response.getStatusCode().value() : 200); + return (this.response.getStatusCode() != null) + ? this.response.getStatusCode().value() : 200; } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/servlet/HttpTraceFilter.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/servlet/HttpTraceFilter.java index 30ad132bea..9ced019ee2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/servlet/HttpTraceFilter.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/web/trace/servlet/HttpTraceFilter.java @@ -92,7 +92,7 @@ public class HttpTraceFilter extends OncePerRequestFilter implements Ordered { } finally { TraceableHttpServletResponse traceableResponse = new TraceableHttpServletResponse( - status != response.getStatus() + (status != response.getStatus()) ? new CustomStatusResponseWrapper(response, status) : response); this.tracer.sendingResponse(trace, traceableResponse, @@ -113,7 +113,7 @@ public class HttpTraceFilter extends OncePerRequestFilter implements Ordered { private String getSessionId(HttpServletRequest request) { HttpSession session = request.getSession(false); - return (session != null ? session.getId() : null); + return (session != null) ? session.getId() : null; } private static final class CustomStatusResponseWrapper diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointTests.java index 8de2b2426f..2c131961a1 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/context/properties/ConfigurationPropertiesReportEndpointTests.java @@ -255,7 +255,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-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/ReflectiveOperationInvokerTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/ReflectiveOperationInvokerTests.java index 66f848b947..4c6aa132a2 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/ReflectiveOperationInvokerTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/invoke/reflect/ReflectiveOperationInvokerTests.java @@ -56,8 +56,8 @@ public class ReflectiveOperationInvokerTests { this.operationMethod = new OperationMethod( ReflectionUtils.findMethod(Example.class, "reverse", String.class), OperationType.READ); - this.parameterValueMapper = (parameter, - value) -> (value != null ? value.toString() : null); + this.parameterValueMapper = (parameter, value) -> (value != null) + ? value.toString() : null; } @Test diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java index 01759b1098..b196e96363 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/JmxEndpointExporterTests.java @@ -190,9 +190,9 @@ public class JmxEndpointExporterTests { @Override public ObjectName getObjectName(ExposableJmxEndpoint endpoint) throws MalformedObjectNameException { - return (endpoint != null + return (endpoint != null) ? new ObjectName("boot:type=Endpoint,name=" + endpoint.getId()) - : null); + : null; } } diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestJmxOperation.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestJmxOperation.java index 1da6edd794..86c740028c 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestJmxOperation.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/jmx/TestJmxOperation.java @@ -68,8 +68,8 @@ public class TestJmxOperation implements JmxOperation { @Override public Object invoke(InvocationContext context) { - return (this.invoke != null ? this.invoke.apply(context.getArguments()) - : "result"); + return (this.invoke != null) ? this.invoke.apply(context.getArguments()) + : "result"; } @Override diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java index 2786f2694d..6b7dbd0e7d 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/web/annotation/AbstractWebEndpointIntegrationTests.java @@ -835,7 +835,7 @@ public abstract class AbstractWebEndpointIntegrationTests filter(List configurations, @@ -296,7 +296,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoader.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoader.java index c99e217209..a3ffda0094 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationMetadataLoader.java +++ b/spring-boot-project/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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java index 2e6ae495e5..59702c09c2 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationPackages.java @@ -147,9 +147,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 @@ -160,8 +159,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java index 833f5298e9..1e3bc0bed7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/AutoConfigurationSorter.java @@ -213,8 +213,8 @@ class AutoConfigurationSorter { } Map attributes = getAnnotationMetadata() .getAnnotationAttributes(AutoConfigureOrder.class.getName()); - return (attributes != null ? (Integer) attributes.get("value") - : AutoConfigureOrder.DEFAULT_ORDER); + return (attributes != null) ? (Integer) attributes.get("value") + : AutoConfigureOrder.DEFAULT_ORDER; } private boolean wasProcessed() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java index ce0f019c79..a34c829fa8 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/ImportAutoConfigurationImportSelector.java @@ -109,8 +109,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java index f5da11de3a..59211edc1e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/AbstractRabbitListenerContainerFactoryConfigurer.java @@ -26,6 +26,7 @@ import org.springframework.amqp.rabbit.retry.MessageRecoverer; import org.springframework.amqp.rabbit.retry.RejectAndDontRequeueRecoverer; import org.springframework.amqp.support.converter.MessageConverter; import org.springframework.boot.autoconfigure.amqp.RabbitProperties.ListenerRetry; +import org.springframework.retry.support.RetryTemplate; import org.springframework.util.Assert; /** @@ -117,15 +118,15 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer builder = (retryConfig.isStateless() + RetryInterceptorBuilder builder = (retryConfig.isStateless()) ? RetryInterceptorBuilder.stateless() - : RetryInterceptorBuilder.stateful()); - builder.retryOperations( - new RetryTemplateFactory(this.retryTemplateCustomizers) - .createRetryTemplate(retryConfig, - RabbitRetryTemplateCustomizer.Target.LISTENER)); - MessageRecoverer recoverer = (this.messageRecoverer != null - ? this.messageRecoverer : new RejectAndDontRequeueRecoverer()); + : RetryInterceptorBuilder.stateful(); + RetryTemplate retryTemplate = new RetryTemplateFactory( + this.retryTemplateCustomizers).createRetryTemplate(retryConfig, + RabbitRetryTemplateCustomizer.Target.LISTENER); + builder.retryOperations(retryTemplate); + MessageRecoverer recoverer = (this.messageRecoverer != null) + ? this.messageRecoverer : new RejectAndDontRequeueRecoverer(); builder.recoverer(recoverer); factory.setAdviceChain(builder.build()); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java index 97ac74e236..b5610970b7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java @@ -195,7 +195,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(); } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 87d55e7199..9cc6d68f85 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -206,7 +206,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) { @@ -229,7 +229,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) { @@ -256,7 +256,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheManagerCustomizers.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheManagerCustomizers.java index ff3a3273fc..d0998e8649 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheManagerCustomizers.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/cache/CacheManagerCustomizers.java @@ -36,8 +36,8 @@ public class CacheManagerCustomizers { public CacheManagerCustomizers( List> customizers) { - this.customizers = (customizers != null ? new ArrayList<>(customizers) - : Collections.emptyList()); + this.customizers = (customizers != null) ? new ArrayList<>(customizers) + : Collections.emptyList(); } /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java index 98ebcdb266..a5c4c19b1e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/AbstractNestedCondition.java @@ -147,8 +147,8 @@ public 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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportAutoConfigurationImportListener.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportAutoConfigurationImportListener.java index 208c7e25d0..20e29dbf52 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionEvaluationReportAutoConfigurationImportListener.java +++ b/spring-boot-project/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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java index 07283b11c5..c2cd484287 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionMessage.java @@ -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. @@ -358,7 +358,7 @@ public final class ConditionMessage { * @return a built {@link ConditionMessage} */ public ConditionMessage items(Style style, Object... items) { - return items(style, items != null ? Arrays.asList(items) : null); + return items(style, (items != null) ? Arrays.asList(items) : null); } /** @@ -415,7 +415,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java index e83ae08c04..6e9b7604af 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/ConditionOutcome.java @@ -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. @@ -122,12 +122,6 @@ public class ConditionOutcome { return this.message; } - @Override - public int hashCode() { - return Boolean.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 Boolean.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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java index d6460a03f8..30ff152a4b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java @@ -444,7 +444,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java index 1f0036eec6..d0abfc1bd4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnJavaCondition.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. @@ -53,7 +53,7 @@ class OnJavaCondition extends SpringBootCondition { JavaVersion version) { boolean match = isWithin(runningVersion, 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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java index 2f696a5308..eb93acbca9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnPropertyCondition.java @@ -139,7 +139,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java index 2578260110..3097c7a9ad 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnResourceCondition.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 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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java index 1591b17326..9dbe6d12da 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseProperties.java @@ -194,8 +194,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java index ec210504e3..048c26fbe3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/diagnostics/analyzer/NoSuchBeanDefinitionFailureAnalyzer.java @@ -87,7 +87,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))); for (AutoConfigurationResult result : autoConfigurationResults) { message.append(String.format("\t- %s%n", result)); @@ -97,9 +97,8 @@ class NoSuchBeanDefinitionFailureAnalyzer } String action = String.format("Consider %s %s in your configuration.", (!autoConfigurationResults.isEmpty() - || !userConfigurationResults.isEmpty() - ? "revisiting the entries above or defining" - : "defining"), + || !userConfigurationResults.isEmpty()) + ? "revisiting the entries above or defining" : "defining", getBeanDescription(cause)); return new FailureAnalysis(message.toString(), action, cause); } @@ -193,8 +192,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() { @@ -254,8 +253,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java index ccb26b84de..301c59ea85 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java @@ -179,7 +179,7 @@ public class FlywayAutoConfiguration { private String getProperty(Supplier property, Supplier defaultValue) { String value = property.get(); - return (value != null ? value : defaultValue.get()); + return (value != null) ? value : defaultValue.get(); } private void checkLocationExists(String... locations) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java index 5ca3a78cc1..fce63d348a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayProperties.java @@ -109,7 +109,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpEncodingProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpEncodingProperties.java index 790deec4d4..9706a1ddf6 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpEncodingProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpEncodingProperties.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. @@ -104,7 +104,7 @@ public class HttpEncodingProperties { } public 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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java index b0d90a5f6d..97aa3e3462 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.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. @@ -69,7 +69,7 @@ public class HttpMessageConvertersAutoConfiguration { @ConditionalOnMissingBean public HttpMessageConverters messageConverters() { return new HttpMessageConverters( - this.converters != null ? this.converters : Collections.emptyList()); + (this.converters != null) ? this.converters : Collections.emptyList()); } @Configuration diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java index 11ed13c74e..7d88679549 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/info/ProjectInfoAutoConfiguration.java @@ -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. @@ -91,7 +91,7 @@ public class ProjectInfoAutoConfiguration { public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) { ResourceLoader loader = context.getResourceLoader(); - loader = (loader != null ? loader : this.defaultResourceLoader); + loader = (loader != null) ? loader : this.defaultResourceLoader; Environment environment = context.getEnvironment(); String location = environment.getProperty("spring.info.git.location"); if (location == null) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java index ccf9e557af..4c4e8d2c94 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration.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. @@ -121,7 +121,7 @@ public class DataSourceAutoConfiguration { private ClassLoader getDataSourceClassLoader(ConditionContext context) { Class dataSourceClass = DataSourceBuilder .findType(context.getClassLoader()); - return (dataSourceClass != null ? dataSourceClass.getClassLoader() : null); + return (dataSourceClass != null) ? dataSourceClass.getClassLoader() : null; } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java index 72a26206f2..f700d990e4 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceInitializer.java @@ -68,8 +68,8 @@ class DataSourceInitializer { ResourceLoader resourceLoader) { this.dataSource = dataSource; this.properties = properties; - this.resourceLoader = (resourceLoader != null ? resourceLoader - : new DefaultResourceLoader()); + this.resourceLoader = (resourceLoader != null) ? resourceLoader + : new DefaultResourceLoader(); } /** diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java index 839bfacdb3..aa9878a2e7 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jdbc/DataSourceProperties.java @@ -277,8 +277,8 @@ public class DataSourceProperties implements BeanClassLoaderAware, InitializingB return this.url; } String databaseName = determineDatabaseName(); - String url = (databaseName != null - ? this.embeddedDatabaseConnection.getUrl(databaseName) : null); + String url = (databaseName != null) + ? this.embeddedDatabaseConnection.getUrl(databaseName) : null; if (!StringUtils.hasText(url)) { throw new DataSourceBeanCreationException( "Failed to determine suitable jdbc url", this, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java index eff79905d5..454edc959d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/JmsProperties.java @@ -188,9 +188,9 @@ 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)); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryFactory.java index 65e8134cd0..b974955aa1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/jms/activemq/ActiveMQConnectionFactoryFactory.java +++ b/spring-boot-project/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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java index 58c7d25039..06675abae9 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java @@ -177,7 +177,7 @@ public class LiquibaseAutoConfiguration { private String getProperty(Supplier property, Supplier defaultValue) { String value = property.get(); - return (value != null ? value : defaultValue.get()); + return (value != null) ? value : defaultValue.get(); } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java index 5aee853903..ddd542605b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoClientFactory.java @@ -81,8 +81,8 @@ public class MongoClientFactory { if (options == null) { options = MongoClientOptions.builder().build(); } - String host = (this.properties.getHost() != null ? this.properties.getHost() - : "localhost"); + String host = (this.properties.getHost() != null) ? this.properties.getHost() + : "localhost"; return new MongoClient(Collections.singletonList(new ServerAddress(host, port)), options); } @@ -101,8 +101,8 @@ public class MongoClientFactory { int port = getValue(properties.getPort(), MongoProperties.DEFAULT_PORT); List seeds = Collections .singletonList(new ServerAddress(host, port)); - return (credentials != null ? new MongoClient(seeds, credentials, options) - : new MongoClient(seeds, options)); + return (credentials != null) ? new MongoClient(seeds, credentials, options) + : new MongoClient(seeds, options); } return createMongoClient(MongoProperties.DEFAULT_URI, options); } @@ -112,7 +112,7 @@ public class MongoClientFactory { } private T getValue(T value, T fallback) { - return (value != null ? value : fallback); + return (value != null) ? value : fallback; } private boolean hasCustomAddress() { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java index 584601f41b..c26607957d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/MongoProperties.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. @@ -143,7 +143,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) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java index 0664cd14fd..f18cf8df1a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/ReactiveMongoClientFactory.java @@ -54,8 +54,8 @@ public class ReactiveMongoClientFactory { List builderCustomizers) { this.properties = properties; this.environment = environment; - this.builderCustomizers = (builderCustomizers != null ? builderCustomizers - : Collections.emptyList()); + this.builderCustomizers = (builderCustomizers != null) ? builderCustomizers + : Collections.emptyList(); } /** @@ -86,8 +86,8 @@ public class ReactiveMongoClientFactory { private MongoClient createEmbeddedMongoClient(MongoClientSettings settings, int port) { Builder builder = builder(settings); - String host = (this.properties.getHost() != null ? this.properties.getHost() - : "localhost"); + String host = (this.properties.getHost() != null) ? this.properties.getHost() + : "localhost"; ClusterSettings clusterSettings = ClusterSettings.builder() .hosts(Collections.singletonList(new ServerAddress(host, port))).build(); builder.clusterSettings(clusterSettings); @@ -119,16 +119,16 @@ public class ReactiveMongoClientFactory { } private void applyCredentials(Builder builder) { - String database = (this.properties.getAuthenticationDatabase() != null + String database = (this.properties.getAuthenticationDatabase() != null) ? this.properties.getAuthenticationDatabase() - : this.properties.getMongoClientDatabase()); + : this.properties.getMongoClientDatabase(); builder.credential((MongoCredential.createCredential( this.properties.getUsername(), database, this.properties.getPassword()))); } private T getOrDefault(T value, T defaultValue) { - return (value != null ? value : defaultValue); + return (value != null) ? value : defaultValue; } private MongoClient createMongoClient(Builder builder) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java index 4cc10f460f..2fbd777fef 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java @@ -130,13 +130,12 @@ public class EmbeddedMongoAutoConfiguration { this.embeddedProperties.getFeatures().toArray(new Feature[0])); 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)); + 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) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java index fdfc2815f8..e22308245a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/DataSourceInitializedPublisher.java @@ -88,8 +88,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java index f1f560fc12..1850710ec5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/HibernateSettings.java @@ -38,7 +38,7 @@ public class HibernateSettings { } public String getDdlAuto() { - return (this.ddlAuto != null ? this.ddlAuto.get() : null); + return (this.ddlAuto != null) ? this.ddlAuto.get() : null; } public HibernateSettings hibernatePropertiesCustomizers( diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java index 22163734d9..09b9685512 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfiguration.java @@ -155,7 +155,7 @@ public class QuartzAutoConfiguration { private DataSource getDataSource(DataSource dataSource, ObjectProvider quartzDataSource) { DataSource dataSourceIfAvailable = quartzDataSource.getIfAvailable(); - return (dataSourceIfAvailable != null ? dataSourceIfAvailable : dataSource); + return (dataSourceIfAvailable != null) ? dataSourceIfAvailable : dataSource; } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java index 5879c46cec..a12c7864bc 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/security/oauth2/client/OAuth2ClientPropertiesRegistrationAdapter.java @@ -102,15 +102,15 @@ public final class OAuth2ClientPropertiesRegistrationAdapter { private static Builder getBuilder(String registrationId, String configuredProviderId, Map providers) { - String providerId = (configuredProviderId != null ? configuredProviderId - : registrationId); + String providerId = (configuredProviderId != null) ? configuredProviderId + : registrationId; CommonOAuth2Provider provider = getCommonProvider(providerId); if (provider == null && !providers.containsKey(providerId)) { throw new IllegalStateException( getErrorMessage(configuredProviderId, registrationId)); } - Builder builder = (provider != null ? provider.getBuilder(registrationId) - : ClientRegistration.withRegistrationId(registrationId)); + Builder builder = (provider != null) ? provider.getBuilder(registrationId) + : ClientRegistration.withRegistrationId(registrationId); if (providers.containsKey(providerId)) { return getBuilder(builder, providers.get(providerId)); } @@ -119,7 +119,7 @@ public final class OAuth2ClientPropertiesRegistrationAdapter { private static String getErrorMessage(String configuredProviderId, String registrationId) { - return (configuredProviderId != null + return ((configuredProviderId != null) ? "Unknown provider ID '" + configuredProviderId + "'" : "Provider ID must be specified for client registration '" + registrationId + "'"); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java index a659958ae0..c468c35d1b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/session/SessionStoreMappings.java @@ -93,7 +93,7 @@ final class SessionStoreMappings { } private String getName(Class configuration) { - return (configuration != null ? configuration.getName() : null); + return (configuration != null) ? configuration.getName() : null; } } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractViewResolverProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractViewResolverProperties.java index 6cb46236de..03be72cf7e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractViewResolverProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/AbstractViewResolverProperties.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. @@ -120,7 +120,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java index 506d185dfa..92b8bd1d19 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/template/TemplateAvailabilityProviders.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. @@ -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); } /** @@ -143,12 +143,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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.java index 91931cb3ef..aa6b58aa03 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/PlatformTransactionManagerCustomizer.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. @@ -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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java index c965588d85..7eebe2fd4f 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/transaction/TransactionManagerCustomizers.java @@ -36,8 +36,8 @@ public class TransactionManagerCustomizers { public TransactionManagerCustomizers( Collection> customizers) { - this.customizers = (customizers != null ? new ArrayList<>(customizers) - : Collections.emptyList()); + this.customizers = (customizers != null) ? new ArrayList<>(customizers) + : Collections.emptyList(); } @SuppressWarnings("unchecked") diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java index 17e83d472c..58d2f82c1a 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java @@ -164,7 +164,7 @@ public class ResourceProperties { 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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java index 8df3d8db5c..a39f6df1a3 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java @@ -110,9 +110,9 @@ public class TomcatWebServerFactoryCustomizer implements } private int determineMaxHttpHeaderSize() { - return (this.serverProperties.getMaxHttpHeaderSize() > 0 + return (this.serverProperties.getMaxHttpHeaderSize() > 0) ? this.serverProperties.getMaxHttpHeaderSize() - : this.serverProperties.getTomcat().getMaxHttpHeaderSize()); + : this.serverProperties.getTomcat().getMaxHttpHeaderSize(); } private void customizeAcceptCount(ConfigurableTomcatWebServerFactory factory, diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java index 4fa410548a..2ad1eb96b1 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/reactive/error/AbstractErrorWebExceptionHandler.java @@ -205,7 +205,7 @@ public abstract class AbstractErrorWebExceptionHandler } private String htmlEscape(Object input) { - return (input != null ? HtmlUtils.htmlEscape(input.toString()) : null); + return (input != null) ? HtmlUtils.htmlEscape(input.toString()) : null; } @Override diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java index 9caa86c226..1ce1bb8c40 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.java @@ -338,7 +338,7 @@ public class WebMvcAutoConfiguration { } private Integer getSeconds(Duration cachePeriod) { - return (cachePeriod != null ? (int) cachePeriod.getSeconds() : null); + return (cachePeriod != null) ? (int) cachePeriod.getSeconds() : null; } @Bean diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java index ef472ac31e..a70a62a194 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorController.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/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-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java index 098d797358..7622691600 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfiguration.java @@ -318,11 +318,13 @@ public class ErrorMvcAutoConfiguration { @Override public String resolvePlaceholder(String placeholderName) { Expression expression = this.expressions.get(placeholderName); - return escape(expression != null ? expression.getValue(this.context) : null); + Object expressionValue = (expression != null) + ? expression.getValue(this.context) : null; + return escape(expressionValue); } 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-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java index 71eafedf2d..7cc6b73b78 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/hazelcast/HazelcastJpaDependencyAutoConfigurationTests.java @@ -102,7 +102,7 @@ public class HazelcastJpaDependencyAutoConfigurationTests { String[] dependsOn = ((BeanDefinitionRegistry) context .getSourceApplicationContext()).getBeanDefinition("entityManagerFactory") .getDependsOn(); - return (dependsOn != null ? Arrays.asList(dependsOn) : Collections.emptyList()); + return (dependsOn != null) ? Arrays.asList(dependsOn) : Collections.emptyList(); } @Configuration diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java index 7807b0a586..038bea9422 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/MockServletWebServerFactory.java @@ -52,17 +52,17 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory } public ServletContext getServletContext() { - return (getWebServer() != null ? getWebServer().getServletContext() : null); + return (getWebServer() != null) ? getWebServer().getServletContext() : null; } public RegisteredServlet getRegisteredServlet(int index) { - return (getWebServer() != null ? getWebServer().getRegisteredServlet(index) - : null); + return (getWebServer() != null) ? getWebServer().getRegisteredServlet(index) + : null; } public RegisteredFilter getRegisteredFilter(int index) { - return (getWebServer() != null ? getWebServer().getRegisteredFilters(index) - : null); + return (getWebServer() != null) ? getWebServer().getRegisteredFilters(index) + : null; } public static class MockServletWebServer diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationLauncher.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationLauncher.java index 16faeba2fe..44f64a6bee 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationLauncher.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationLauncher.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,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(Class[] sources, String[] args) throws Exception { diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java index a466688de8..0f9c76b6a8 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/app/SpringApplicationWebApplicationInitializer.java +++ b/spring-boot-project/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"); - return (stream != null ? new Manifest(stream) : null); + return (stream != null) ? new Manifest(stream) : null; } @Override diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandFactory.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandFactory.java index 8b6e069eec..0ad790baaa 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandFactory.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandFactory.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. @@ -30,7 +30,7 @@ public interface CommandFactory { /** * Returns the CLI {@link Command}s. - * @return The commands + * @return the commands */ Collection getCommands(); diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java index 1a0e202e3d..b3693f42bf 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/CommandRunner.java @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/HelpExample.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/HelpExample.java index 9627ee7031..43bab3c8d1 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/HelpExample.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/HelpExample.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java index 84fb7a6095..7f72e75db2 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/archive/ArchiveCommand.java @@ -230,7 +230,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java index c101cf7125..6f1c29a06b 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HelpCommand.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java index 5eef4fd948..8abbe89e33 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/core/HintCommand.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,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java index 0f0849ca9e..a9b05bc4d4 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/InitializrService.java @@ -240,7 +240,7 @@ class InitializrService { private String getContent(HttpEntity entity) throws IOException { ContentType contentType = ContentType.getOrDefault(entity); Charset charset = contentType.getCharset(); - charset = (charset != null ? charset : StandardCharsets.UTF_8); + charset = (charset != null) ? charset : StandardCharsets.UTF_8; byte[] content = FileCopyUtils.copyToByteArray(entity.getContent()); return new String(content, charset); } diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java index c01ad6d6e9..dbf0a12622 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerationRequest.java @@ -416,7 +416,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java index 0c9725182a..bf9faf2a3c 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/init/ProjectGenerator.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 @@ 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); @@ -100,8 +100,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/DependencyResolver.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/DependencyResolver.java index 2e5b464a46..1a22874444 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/DependencyResolver.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/DependencyResolver.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. @@ -32,8 +32,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/InstallCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/InstallCommand.java index a8856a4da1..dd96bf0a8b 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/InstallCommand.java +++ b/spring-boot-project/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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/UninstallCommand.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/UninstallCommand.java index 1e07bc48a0..2c547bef1e 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/UninstallCommand.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/install/UninstallCommand.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java index db0a2236ee..871be69a99 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/OptionHandler.java @@ -157,7 +157,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java index 78695d83ad..0ccecf0632 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/options/SourceOptions.java @@ -130,7 +130,7 @@ public class SourceOptions { } private String asString(Object arg) { - return (arg != null ? String.valueOf(arg) : null); + return (arg != null) ? String.valueOf(arg) : null; } public List getSources() { diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java index 13e1d7e8d9..4fbfec961f 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/CommandCompleter.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java index 3edd30777e..ef6ff2f8ce 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/command/shell/Shell.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. @@ -140,7 +140,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java index 8ba830ae80..b13f57df73 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/DependencyCustomizer.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 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,9 +199,9 @@ 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}. + * otherwise {@code false} * @return this {@link DependencyCustomizer} for continued use */ public DependencyCustomizer add(String module, boolean transitive) { @@ -212,11 +212,11 @@ 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}. + * otherwise {@code false} * @return this {@link DependencyCustomizer} for continued use */ public DependencyCustomizer add(String module, String classifier, String type, diff --git a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java index 22bc88a63e..3538dba54b 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ExtendedGroovyClassLoader.java @@ -115,7 +115,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java index 4db5495306..5b284f766a 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/ResolveDependencyCoordinatesTransformation.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ArtifactCoordinatesResolver.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ArtifactCoordinatesResolver.java index 4a0e8f6961..d999a1ad38 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ArtifactCoordinatesResolver.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/ArtifactCoordinatesResolver.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java index 34c8f16fb7..e703714f06 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/Dependency.java +++ b/spring-boot-project/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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java index 29fe8b75ef..44fc2b55e3 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagement.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java index 2bb1a7517c..59cc21a881 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/dependencies/DependencyManagementArtifactCoordinatesResolver.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java index eec15605b8..6673ba406d 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/AetherGrapeEngine.java @@ -197,7 +197,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) { @@ -219,7 +219,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java index 75ba927636..76b8acec24 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DefaultRepositorySystemSessionAutoConfiguration.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,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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java index f7d0773a28..ef345b7e23 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionContext.java +++ b/spring-boot-project/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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionFailedException.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionFailedException.java index ef0eda448a..70db6a12c0 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionFailedException.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/DependencyResolutionFailedException.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java index 73c0a17f58..a0f5e5c2fa 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/grape/RepositoryConfiguration.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. @@ -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-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettings.java b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettings.java index 76f6a16245..c102665d92 100644 --- a/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettings.java +++ b/spring-boot-project/spring-boot-cli/src/main/java/org/springframework/boot/cli/compiler/maven/MavenSettings.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,8 +150,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-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java index f4c1e57404..538363188b 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.java +++ b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/AbstractHttpClientMockTests.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. @@ -88,8 +88,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); } @@ -119,8 +119,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; @@ -138,7 +138,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-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java b/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java index 4ccd46a2fd..c08d9f61d8 100644 --- a/spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/command/init/ProjectGenerationRequestTests.java +++ b/spring-boot-project/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. @@ -232,8 +232,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-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java index c5bf669617..8ddb7ae0be 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/autoconfigure/RemoteDevToolsAutoConfiguration.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,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.autoconfigure.web.ServerProperties.Servlet; import org.springframework.boot.context.properties.EnableConfigurationProperties; import org.springframework.boot.devtools.remote.server.AccessManager; import org.springframework.boot.devtools.remote.server.Dispatcher; @@ -84,10 +85,11 @@ public class RemoteDevToolsAutoConfiguration { @Bean public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() { Handler handler = new HttpStatusHandler(); + Servlet servlet = this.serverProperties.getServlet(); + String servletContextPath = (servlet.getContextPath() != null) + ? servlet.getContextPath() : ""; return new UrlHandlerMapper( - (this.serverProperties.getServlet().getContextPath() != null - ? this.serverProperties.getServlet().getContextPath() : "") - + this.properties.getRemote().getContextPath(), + servletContextPath + this.properties.getRemote().getContextPath(), handler); } @@ -127,9 +129,11 @@ public class RemoteDevToolsAutoConfiguration { @Bean @ConditionalOnMissingBean(name = "remoteRestartHandlerMapper") public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) { - String url = (this.serverProperties.getServlet().getContextPath() != null - ? this.serverProperties.getServlet().getContextPath() : "") - + this.properties.getRemote().getContextPath() + "/restart"; + Servlet servlet = this.serverProperties.getServlet(); + RemoteDevToolsProperties remote = this.properties.getRemote(); + String servletContextPath = (servlet.getContextPath() != null) + ? servlet.getContextPath() : ""; + String url = servletContextPath + remote.getContextPath() + "/restart"; logger.warn("Listening for remote restart updates on " + url); Handler handler = new HttpRestartServerHandler(server); return new UrlHandlerMapper(url, handler); diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java index 174f050a64..3077664b5a 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/env/DevToolsHomePropertiesPostProcessor.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. @@ -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-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java index 9490a697ab..9b45058434 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFile.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,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-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java index f4482f5b46..54ed503930 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/filewatch/ChangedFiles.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. @@ -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-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java index 6ae40514b0..091c0e0221 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploader.java @@ -132,8 +132,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 { @@ -160,10 +160,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-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java index 6b52921383..bcfc900e8d 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/restart/classloader/ClassLoaderFile.java +++ b/spring-boot-project/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 " : "") + Assert.isTrue((kind != Kind.DELETED) ? contents != null : contents == null, + () -> "Contents must " + ((kind != Kind.DELETED) ? "not " : "") + "be null"); this.kind = kind; this.lastModified = lastModified; diff --git a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java index 121adb0c43..8d56dfa1cd 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnection.java @@ -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. @@ -88,8 +88,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-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/TunnelConnection.java b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/TunnelConnection.java index de562f9bb7..2f01b34780 100644 --- a/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/TunnelConnection.java +++ b/spring-boot-project/spring-boot-devtools/src/main/java/org/springframework/boot/devtools/tunnel/client/TunnelConnection.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. @@ -30,10 +30,10 @@ public interface TunnelConnection { /** * Open the tunnel connection. - * @param incomingChannel A {@link WritableByteChannel} that should be used to write - * any incoming data received from the remote server. + * @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-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java index ee3b92b777..de9de9d1ed 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/ClassPathChangeUploaderTests.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. @@ -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-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/test/MockClientHttpRequestFactory.java b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/test/MockClientHttpRequestFactory.java index 42ab33fb59..053d404817 100644 --- a/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/test/MockClientHttpRequestFactory.java +++ b/spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/test/MockClientHttpRequestFactory.java @@ -119,7 +119,7 @@ public class MockClientHttpRequestFactory implements ClientHttpRequestFactory { public ClientHttpResponse asHttpResponse(AtomicLong seq) { MockClientHttpResponse httpResponse = new MockClientHttpResponse( - this.payload != null ? this.payload : NO_DATA, this.status); + (this.payload != null) ? this.payload : NO_DATA, this.status); waitForDelay(); if (this.payload != null) { httpResponse.getHeaders().setContentLength(this.payload.length); diff --git a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java index ce0e2900fd..7a8b1f0ea6 100644 --- a/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/test/spock/SpockTestRestTemplateExample.java +++ b/spring-boot-project/spring-boot-docs/src/main/java/org/springframework/boot/docs/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) - : new TestRestTemplate()); + TestRestTemplate template = (builder != null) ? new TestRestTemplate(builder) + : new TestRestTemplate(); template.setUriTemplateHandler(new LocalHostUriTemplateHandler(environment)); return template; } diff --git a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java index a193c3bca3..41c9245905 100644 --- a/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java +++ b/spring-boot-project/spring-boot-properties-migrator/src/main/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationReport.java @@ -148,7 +148,7 @@ class PropertiesMigrationReport { } private List asNewList(List source) { - return (source != null ? new ArrayList<>(source) : Collections.emptyList()); + return (source != null) ? new ArrayList<>(source) : Collections.emptyList(); } public List getRenamed() { diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java index cc03f38616..4a1e34b4ab 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/OverrideAutoConfigurationContextCustomizerFactory.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,13 +62,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-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java index 3207ad95fd..e59ac1f59e 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/AnnotationCustomizableTypeExcludeFilter.java +++ b/spring-boot-project/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 + Boolean.hashCode(hasAnnotation()); - for (FilterType filterType : FilterType.values()) { - result = prime * result - + ObjectUtils.nullSafeHashCode(getFilters(filterType)); - } - result = prime * result + Boolean.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 + Boolean.hashCode(hasAnnotation()); + for (FilterType filterType : FilterType.values()) { + result = prime * result + + ObjectUtils.nullSafeHashCode(getFilters(filterType)); + } + result = prime * result + Boolean.hashCode(isUseDefaultFilters()); + result = prime * result + ObjectUtils.nullSafeHashCode(getDefaultIncludes()); + result = prime * result + ObjectUtils.nullSafeHashCode(getComponentIncludes()); + return result; + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java index a3df07bf13..66252fefbb 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizer.java @@ -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() == 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-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java index 81f45d838b..6cfaa96377 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java @@ -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-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java index e5c48656d4..775478c625 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/PropertyMappingContextCustomizer.java +++ b/spring-boot-project/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() == 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-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java index 39e1c04fca..9d17c49e19 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverContextCustomizerFactory.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. @@ -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-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java index f8aec348ec..5cee44093f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/web/servlet/WebDriverScope.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. @@ -139,7 +139,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-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java index a375465fce..2d0b73ee8f 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/filter/TypeExcludeFiltersContextCustomizerFactoryTests.java @@ -119,13 +119,13 @@ public class TypeExcludeFiltersContextCustomizerFactoryTests { } @Override - public int hashCode() { - return SimpleExclude.class.hashCode(); + public boolean equals(Object obj) { + return obj.getClass() == getClass(); } @Override - public boolean equals(Object obj) { - return obj.getClass() == getClass(); + public int hashCode() { + return SimpleExclude.class.hashCode(); } } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java index 8d99d71ea4..ba1be0f35a 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleBasicObject.java @@ -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() == getClass()) { @@ -46,4 +41,9 @@ public class ExampleBasicObject { return false; } + @Override + public int hashCode() { + return this.value.hashCode(); + } + } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java index 3376f45e5f..372e4f206e 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleCustomObject.java @@ -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() == 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-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java index 450c20ce35..76b9ad7b25 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/app/ExampleJsonObjectWithView.java +++ b/spring-boot-project/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-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java index d2510b9ef0..2e86dfa669 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/AnnotatedClassFinder.java @@ -100,7 +100,7 @@ public final class AnnotatedClassFinder { 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-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java index fcee0a2d28..8ab6b50e2d 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/ImportsContextCustomizer.java @@ -115,11 +115,6 @@ class ImportsContextCustomizer implements ContextCustomizer { return registry.getBeanDefinition(beanName); } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -133,6 +128,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(); @@ -168,10 +168,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; } } @@ -245,7 +245,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, @@ -338,17 +338,17 @@ class ImportsContextCustomizer implements ContextCustomizer { } } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { return (obj != null && getClass() == 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-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java index d320b31b1a..1250f39fdb 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootContextLoader.java @@ -110,9 +110,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-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java index f9f3c259cc..f2bf39c8c5 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootTestContextBootstrapper.java @@ -166,8 +166,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); } @@ -316,17 +316,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-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssert.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssert.java index 4e2d1aaa8c..4cb9615b92 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssert.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssert.java @@ -42,7 +42,7 @@ import static org.assertj.core.api.Assertions.assertThat; * AssertJ {@link org.assertj.core.api.Assert assertions} that can be applied to an * {@link ApplicationContext}. * - * @param The application context type + * @param the application context type * @author Phillip Webb * @author Andy Wilkinson * @since 2.0.0 @@ -278,8 +278,8 @@ public class ApplicationContextAssert "%nExpecting:%n <%s>%nsingle bean of type:%n <%s>%nbut found:%n <%s>", getApplicationContext(), type, names)); } - T bean = (names.length != 0 ? getApplicationContext().getBean(names[0], type) - : null); + T bean = (names.length != 0) ? getApplicationContext().getBean(names[0], type) + : null; return Assertions.assertThat(bean).as("Bean of type <%s> from <%s>", type, getApplicationContext()); } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProvider.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProvider.java index b6f07318bf..fd618dd385 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProvider.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/assertj/ApplicationContextAssertProvider.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,7 +41,7 @@ import org.springframework.util.Assert; * Any {@link ApplicationContext} method called on a context that has failed to start will * throw an {@link IllegalStateException}. * - * @param The application context type + * @param the application context type * @author Phillip Webb * @see AssertableApplicationContext * @see AssertableWebApplicationContext diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java index 652a0ec20b..38ac24c60c 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/filter/ExcludeFilterContextCustomizer.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. @@ -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-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java index e149fd66ac..9c971ef59d 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunner.java @@ -84,9 +84,9 @@ import org.springframework.util.Assert; * } *

* - * @param The "self" type for this runner - * @param The context type - * @param The application context assertion provider + * @param the "self" type for this runner + * @param the context type + * @param the application context assertion provider * @author Stephane Nicoll * @author Andy Wilkinson * @author Phillip Webb diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ContextConsumer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ContextConsumer.java index e6da8ca150..6c887a489e 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ContextConsumer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/ContextConsumer.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. @@ -24,7 +24,7 @@ import org.springframework.context.ApplicationContext; * * @author Stephane Nicoll * @author Andy Wilkinson - * @param The application context type + * @param the application context type * @since 2.0.0 * @see AbstractApplicationContextRunner */ diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java index ff5fe56abb..8a5924c9c2 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/runner/WebApplicationContextRunner.java @@ -93,11 +93,11 @@ public final class WebApplicationContextRunner extends */ public static Supplier withMockServletContext( Supplier contextFactory) { - return (contextFactory != null ? () -> { + return (contextFactory != null) ? () -> { ConfigurableWebApplicationContext context = contextFactory.get(); context.setServletContext(new MockServletContext()); return context; - } : null); + } : null; } } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java index 46e3ef20fc..8567e79478 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/AbstractJsonMarshalTester.java @@ -352,7 +352,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-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java index 187d834a07..4605b62480 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/BasicJsonTester.java @@ -101,7 +101,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-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java index 0f043b0e86..bd875e9034 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/DuplicateJsonObjectContextCustomizerFactory.java +++ b/spring-boot-project/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-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java index 798fffc80a..3ba1e62f84 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContent.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. @@ -74,8 +74,8 @@ public final class JsonContent implements AssertProvider { @Override public String toString() { - return "JsonContent " + this.json - + (this.type != null ? " created from " + this.type : ""); + String createdFrom = (this.type != null) ? " created from " + this.type : ""; + return "JsonContent " + this.json + createdFrom; } } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java index 8e25f6ffca..cee123ebb5 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/JsonContentAssert.java @@ -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. @@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert resourceLoadClass, Charset charset) { this.resourceLoadClass = resourceLoadClass; - this.charset = (charset != null ? charset : StandardCharsets.UTF_8); + this.charset = (charset != null) ? charset : StandardCharsets.UTF_8; } Class getResourceLoadClass() { diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java index 1dc778fff6..1bb06e959f 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/json/ObjectContent.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,8 +62,8 @@ 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-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java index c9b96e17e0..5eaa44a79c 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/Definition.java +++ b/spring-boot-project/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-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java index b6cb980db7..991d44b666 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockDefinition.java @@ -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 + Boolean.hashCode(this.serializable); - 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 + Boolean.hashCode(this.serializable); + return result; + } + @Override public String toString() { return new ToStringCreator(this).append("name", getName()) diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java index 048f0ab287..4fd7a1146c 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/MockitoContextCustomizer.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,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-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java index dad2d1d972..b5783ea028 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/QualifierDefinition.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. @@ -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-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java index 9af4d6eccd..5d4b240e7a 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/mock/mockito/SpyDefinition.java +++ b/spring-boot-project/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. @@ -51,13 +51,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) { @@ -72,6 +65,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-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java index 83f2fb8f5c..6b051f5ea7 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/util/TestPropertyValues.java @@ -235,7 +235,7 @@ public final class TestPropertyValues { } protected String applySuffix(String name) { - return (this.suffix != null ? name + "-" + this.suffix : name); + return (this.suffix != null) ? name + "-" + this.suffix : name; } } @@ -261,8 +261,8 @@ public final class TestPropertyValues { public static Pair parse(String pair) { int index = getSeparatorIndex(pair); - String name = (index > 0 ? pair.substring(0, index) : pair); - String value = (index > 0 ? pair.substring(index + 1) : ""); + String name = (index > 0) ? pair.substring(0, index) : pair; + String value = (index > 0) ? pair.substring(index + 1) : ""; return of(name.trim(), value.trim()); } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java index e4061073eb..fae15fd275 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java @@ -130,7 +130,7 @@ public class TestRestTemplate { */ public TestRestTemplate(RestTemplateBuilder restTemplateBuilder, String username, String password, HttpClientOption... httpClientOptions) { - this(restTemplateBuilder != null ? restTemplateBuilder.build() : null, username, + this((restTemplateBuilder != null) ? restTemplateBuilder.build() : null, username, password, httpClientOptions); } diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java index 4129048c6f..262d790e5a 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplateContextCustomizer.java @@ -74,11 +74,6 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer { definition); } - @Override - public int hashCode() { - return getClass().hashCode(); - } - @Override public boolean equals(Object obj) { if (obj == null || obj.getClass() != getClass()) { @@ -87,6 +82,11 @@ class TestRestTemplateContextCustomizer implements ContextCustomizer { return true; } + @Override + public int hashCode() { + return getClass().hashCode(); + } + /** * {@link BeanDefinitionRegistryPostProcessor} that runs after the * {@link ConfigurationClassPostProcessor} and add a {@link TestRestTemplateFactory} diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java index d5292f7b93..0f700d903a 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/reactive/server/WebTestClientContextCustomizer.java @@ -78,13 +78,13 @@ class WebTestClientContextCustomizer implements ContextCustomizer { } @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-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java index 3db0036a58..b7c30a58cc 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObject.java +++ b/spring-boot-project/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-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java b/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java index 1bd501c094..1171bb9bbb 100644 --- a/spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/json/ExampleObjectWithView.java +++ b/spring-boot-project/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-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java index d3d06890f8..6c6a893725 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-autoconfigure-processor/src/main/java/org/springframework/boot/autoconfigureprocessor/AutoConfigureAnnotationProcessor.java @@ -152,7 +152,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-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/AbstractConfigurationMetadataTests.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/AbstractConfigurationMetadataTests.java index 86e407ee8e..a3cd8bb1f3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/AbstractConfigurationMetadataTests.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-metadata/src/test/java/org/springframework/boot/configurationmetadata/AbstractConfigurationMetadataTests.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 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-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java index 175d4d2b46..08e8423f55 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/ConfigurationMetadataAnnotationProcessor.java @@ -317,8 +317,9 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor reason = (String) elementValues.get("reason"); replacement = (String) elementValues.get("replacement"); } - return new ItemDeprecation(("".equals(reason) ? null : reason), - ("".equals(replacement) ? null : replacement)); + reason = "".equals(reason) ? null : reason; + replacement = "".equals(replacement) ? null : replacement; + return new ItemDeprecation(reason, replacement); } private void processSimpleLombokTypes(String prefix, TypeElement element, @@ -420,7 +421,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); } } @@ -453,7 +454,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor this.metadataCollector.add(ItemMetadata.newProperty(endpointKey, "enabled", Boolean.class.getName(), type, null, String.format("Whether to enable the %s endpoint.", endpointId), - (enabledByDefault != null ? enabledByDefault : true), null)); + (enabledByDefault != null) ? enabledByDefault : true, null)); if (hasMainReadOperation(element)) { this.metadataCollector.add(ItemMetadata.newProperty(endpointKey, "cache.time-to-live", Duration.class.getName(), type, null, diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataCollector.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataCollector.java index a6d129acb9..58e68af44d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/MetadataCollector.java +++ b/spring-boot-project/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-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java index 019206fa7f..b78fbc1074 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeElementMembers.java @@ -156,8 +156,8 @@ class TypeElementMembers { } private String getAccessorName(String methodName) { - String name = (methodName.startsWith("is") ? methodName.substring(2) - : methodName.substring(3)); + String name = methodName.startsWith("is") ? methodName.substring(2) + : methodName.substring(3); name = Character.toLowerCase(name.charAt(0)) + name.substring(1); return name; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java index 0ceb795157..ce3e6d3275 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/TypeUtils.java @@ -139,12 +139,12 @@ 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(); } - return ("".equals(javadoc) ? null : javadoc); + return "".equals(javadoc) ? null : javadoc; } public TypeMirror getWrapperOrPrimitiveFor(TypeMirror typeMirror) { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java index 0e0aa7f346..a56ce83b5c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/JavaCompilerFieldValuesParser.java @@ -178,7 +178,7 @@ public class JavaCompilerFieldValuesParser implements FieldValuesParser { String type = instance.toString(); type = type.substring(DURATION_OF.length(), type.indexOf('(')); String suffix = DURATION_SUFFIX.get(type); - return (suffix != null ? factoryValue + suffix : null); + return (suffix != null) ? factoryValue + suffix : null; } return factoryValue; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/Trees.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/Trees.java index 2a57711472..e1516d3962 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/Trees.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/Trees.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. @@ -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-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.java index a2beaa3a0f..255ab0e7e2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/fieldvalues/javac/VariableTree.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,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-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java index 6c377ef71d..8689ba1059 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ConfigurationMetadata.java @@ -174,9 +174,9 @@ 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); + nestedPrefix += "".equals(nestedPrefix) ? dashedName : "." + dashedName; return nestedPrefix; } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java index b3a24d613a..cba6e71c06 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemDeprecation.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. @@ -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-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java index 94adc8f157..81ce69ed80 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemHint.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. @@ -44,9 +44,9 @@ 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-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java index fc3012e6b3..4784c04822 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-configuration-processor/src/main/java/org/springframework/boot/configurationprocessor/metadata/ItemMetadata.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. @@ -61,11 +61,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(); } @@ -133,24 +133,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) { - string.append(" ").append(property).append(":").append(value); - } - } - @Override public boolean equals(Object o) { if (this == o) { @@ -196,7 +178,25 @@ public final class ItemMetadata implements Comparable { } private int nullSafeHashCode(Object o) { - return (o != null ? o.hashCode() : 0); + return (o != null) ? o.hashCode() : 0; + } + + @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) { + string.append(" ").append(property).append(":").append(value); + } } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle index 939c79c4aa..10341c0d21 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/build.gradle @@ -1,8 +1,20 @@ +buildscript { + repositories { + mavenLocal() + mavenCentral() + } + dependencies { + classpath("io.spring.javaformat:spring-javaformat-gradle-plugin:0.0.6") + } +} + plugins { id 'java' id 'eclipse' } +apply plugin: 'io.spring.javaformat' + repositories { mavenLocal() mavenCentral() @@ -29,15 +41,6 @@ test { } } -eclipseJdt { - inputFile = rootProject.file('../../../eclipse/org.eclipse.jdt.core.prefs') - doLast { - project.file('.settings/org.eclipse.jdt.ui.prefs').withWriter { writer -> - writer << file('../../../eclipse/org.eclipse.jdt.ui.prefs').text - } - } -} - javadoc { options { author() diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java index 884908f3b7..b39252029f 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/dsl/SpringBootExtension.java @@ -119,7 +119,7 @@ public class SpringBootExtension { private String determineArtifactBaseName() { Jar artifactTask = findArtifactTask(); - return (artifactTask != null ? artifactTask.getBaseName() : null); + return (artifactTask != null) ? artifactTask.getBaseName() : null; } private Jar findArtifactTask() { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java index c6ed35affa..fae59a4136 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/plugin/JavaPluginAction.java @@ -162,9 +162,9 @@ final class JavaPluginAction implements PluginApplicationAction { } private boolean hasConfigurationProcessorOnClasspath(JavaCompile compile) { - Set files = (compile.getOptions().getAnnotationProcessorPath() != null + Set files = (compile.getOptions().getAnnotationProcessorPath() != null) ? compile.getOptions().getAnnotationProcessorPath().getFiles() - : compile.getClasspath().getFiles()); + : compile.getClasspath().getFiles(); return files.stream().map(File::getName).anyMatch( (name) -> name.startsWith("spring-boot-configuration-processor")); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java index 310bffb99d..fe8423336e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfo.java @@ -53,17 +53,14 @@ public class BuildInfo extends ConventionTask { @TaskAction public void generateBuildProperties() { try { - new BuildPropertiesWriter( - new File(getDestinationDir(), "build-info.properties")) - .writeBuildProperties(new ProjectDetails( - this.properties.getGroup(), - this.properties.getArtifact() != null - ? this.properties.getArtifact() - : "unspecified", - this.properties.getVersion(), - this.properties.getName(), this.properties.getTime(), - coerceToStringValues( - this.properties.getAdditional()))); + new BuildPropertiesWriter(new File(getDestinationDir(), + "build-info.properties")).writeBuildProperties(new ProjectDetails( + this.properties.getGroup(), + (this.properties.getArtifact() != null) + ? this.properties.getArtifact() : "unspecified", + this.properties.getVersion(), this.properties.getName(), + this.properties.getTime(), + coerceToStringValues(this.properties.getAdditional()))); } catch (IOException ex) { throw new TaskExecutionException(this, ex); @@ -77,8 +74,8 @@ public class BuildInfo extends ConventionTask { */ @OutputDirectory public File getDestinationDir() { - return (this.destinationDir != null ? this.destinationDir - : getProject().getBuildDir()); + return (this.destinationDir != null) ? this.destinationDir + : getProject().getBuildDir(); } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java index 850ce266c8..3cf46cba62 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/buildinfo/BuildInfoProperties.java @@ -162,6 +162,36 @@ public class BuildInfoProperties implements Serializable { this.additionalProperties = additionalProperties; } + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null || getClass() != obj.getClass()) { + return false; + } + BuildInfoProperties other = (BuildInfoProperties) obj; + boolean result = true; + result = result + && nullSafeEquals(this.additionalProperties, other.additionalProperties); + result = result && nullSafeEquals(this.artifact, other.artifact); + result = result && nullSafeEquals(this.group, other.group); + result = result && nullSafeEquals(this.name, other.name); + result = result && nullSafeEquals(this.version, other.version); + result = result && nullSafeEquals(this.time, other.time); + return result; + } + + private boolean nullSafeEquals(Object o1, Object o2) { + if (o1 == o2) { + return true; + } + if (o1 == null || o2 == null) { + return false; + } + return (o1.equals(o2)); + } + @Override public int hashCode() { final int prime = 31; @@ -177,67 +207,4 @@ public class BuildInfoProperties implements Serializable { return result; } - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - BuildInfoProperties other = (BuildInfoProperties) obj; - if (this.additionalProperties == null) { - if (other.additionalProperties != null) { - return false; - } - } - else if (!this.additionalProperties.equals(other.additionalProperties)) { - return false; - } - if (this.artifact == null) { - if (other.artifact != null) { - return false; - } - } - else if (!this.artifact.equals(other.artifact)) { - return false; - } - if (this.group == null) { - if (other.group != null) { - return false; - } - } - else if (!this.group.equals(other.group)) { - return false; - } - if (this.name == null) { - if (other.name != null) { - return false; - } - } - else if (!this.name.equals(other.name)) { - return false; - } - if (this.version == null) { - if (other.version != null) { - return false; - } - } - else if (!this.version.equals(other.version)) { - return false; - } - if (this.time == null) { - if (other.time != null) { - return false; - } - } - else if (!this.time.equals(other.time)) { - return false; - } - return true; - } - } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java index d69e3f846c..9e26f4e6aa 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootJar.java @@ -58,8 +58,8 @@ public class BootJar extends Jar implements BootArchive { private Action classpathFiles(Spec filter) { return (copySpec) -> copySpec - .from((Callable>) () -> (this.classpath != null - ? this.classpath.filter(filter) : Collections.emptyList())); + .from((Callable>) () -> (this.classpath != null) + ? this.classpath.filter(filter) : Collections.emptyList()); } @@ -125,7 +125,7 @@ public class BootJar extends Jar implements BootArchive { public void classpath(Object... classpath) { FileCollection existingClasspath = this.classpath; this.classpath = getProject().files( - existingClasspath != null ? existingClasspath : Collections.emptyList(), + (existingClasspath != null) ? existingClasspath : Collections.emptyList(), classpath); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java index 83c1dd8a2b..fec816a0ca 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootWar.java @@ -51,8 +51,8 @@ public class BootWar extends War implements BootArchive { public BootWar() { getWebInf().into("lib-provided", (copySpec) -> copySpec.from( - (Callable>) () -> (this.providedClasspath != null - ? this.providedClasspath : Collections.emptyList()))); + (Callable>) () -> (this.providedClasspath != null) + ? this.providedClasspath : Collections.emptyList())); } @Override @@ -127,7 +127,7 @@ public class BootWar extends War implements BootArchive { public void providedClasspath(Object... classpath) { FileCollection existingClasspath = this.providedClasspath; this.providedClasspath = getProject().files( - existingClasspath != null ? existingClasspath : Collections.emptyList(), + (existingClasspath != null) ? existingClasspath : Collections.emptyList(), classpath); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java index c2166fd8c5..47dd1b3eac 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java @@ -119,7 +119,6 @@ class BootZipCopyAction implements CopyAction { return () -> true; } - @SuppressWarnings("unchecked") private Spec createExclusionSpec( Spec loaderEntries) { return Specs.union(loaderEntries, this.exclusions); @@ -284,8 +283,8 @@ class BootZipCopyAction implements CopyAction { } private long getTime(FileCopyDetails details) { - return (this.preserveFileTimestamps ? details.getLastModified() - : CONSTANT_TIME_FOR_ZIP_ENTRIES); + return this.preserveFileTimestamps ? details.getLastModified() + : CONSTANT_TIME_FOR_ZIP_ENTRIES; } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java index 6320939b62..4d908d1a46 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/LaunchScriptConfiguration.java @@ -41,7 +41,6 @@ public class LaunchScriptConfiguration implements Serializable { private File script; public LaunchScriptConfiguration() { - } LaunchScriptConfiguration(AbstractArchiveTask archiveTask) { @@ -89,25 +88,12 @@ public class LaunchScriptConfiguration implements Serializable { this.script = script; } - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result - + ((this.properties == null) ? 0 : this.properties.hashCode()); - result = prime * result + ((this.script == null) ? 0 : this.script.hashCode()); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { return true; } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { + if (obj == null || getClass() != obj.getClass()) { return false; } LaunchScriptConfiguration other = (LaunchScriptConfiguration) obj; @@ -137,12 +123,22 @@ public class LaunchScriptConfiguration implements Serializable { } } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + + ((this.properties == null) ? 0 : this.properties.hashCode()); + result = prime * result + ((this.script == null) ? 0 : this.script.hashCode()); + return result; + } + private String removeLineBreaks(String string) { - return (string != null ? string.replaceAll("\\s+", " ") : null); + return (string != null) ? string.replaceAll("\\s+", " ") : null; } private String augmentLineBreaks(String string) { - return (string != null ? string.replaceAll("\n", "\n# ") : null); + return (string != null) ? string.replaceAll("\n", "\n# ") : null; } private void putIfMissing(Map properties, String key, diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java index d4242f3694..f16d6ec514 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/DefaultLaunchScript.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. @@ -109,8 +109,8 @@ public class DefaultLaunchScript implements LaunchScript { } } else { - value = (defaultValue != null ? defaultValue.substring(1) - : matcher.group(0)); + value = (defaultValue != null) ? defaultValue.substring(1) + : matcher.group(0); } matcher.appendReplacement(expanded, value.replace("$", "\\$")); } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java index 2316552991..ba7bc8559d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/JarWriter.java @@ -160,8 +160,8 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable { /** * 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 @@ -363,7 +363,7 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable { @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) { @@ -381,8 +381,8 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable { @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-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java index e9fbd2a632..14df64f39e 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/Library.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. @@ -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-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java index 4284914649..219e1da870 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader-tools/src/main/java/org/springframework/boot/loader/tools/MainClassFinder.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. @@ -248,7 +248,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()) { @@ -384,16 +384,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) { @@ -412,6 +402,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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java index 6b265e4aaa..dd434c70f6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/Launcher.java +++ b/spring-boot-project/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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java index 9ef7a245e0..b90a3d45d3 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/MainMethodRunner.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. @@ -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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java index 2b89514879..66bde9b39f 100755 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/PropertiesLauncher.java @@ -434,9 +434,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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java index 76dac5420d..00cfc094f2 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/data/RandomAccessDataFile.java @@ -144,7 +144,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 { @Override public long skip(long n) throws IOException { - return (n <= 0 ? 0 : moveOn(cap(n))); + return (n <= 0) ? 0 : moveOn(cap(n)); } /** diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java index e4f7bc0669..7ce5433537 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/AsciiBytes.java @@ -124,24 +124,10 @@ final class AsciiBytes { return new AsciiBytes(this.bytes, this.offset + beginIndex, length); } - @Override - public String toString() { - if (this.string == null) { - if (this.length == 0) { - this.string = EMPTY_STRING; - } - else { - this.string = new String(this.bytes, this.offset, this.length, - StandardCharsets.UTF_8); - } - } - return this.string; - } - public boolean matches(CharSequence name, char suffix) { int charIndex = 0; int nameLen = name.length(); - int totalLen = (nameLen + (suffix != 0 ? 1 : 0)); + int totalLen = nameLen + ((suffix != 0) ? 1 : 0); for (int i = this.offset; i < this.offset + this.length; i++) { int b = this.bytes[i]; int remainingUtfBytes = getNumberOfUtfBytes(b) - 1; @@ -178,30 +164,6 @@ final class AsciiBytes { return 0; } - @Override - public int hashCode() { - int hash = this.hash; - if (hash == 0 && this.bytes.length > 0) { - for (int i = this.offset; i < this.offset + this.length; i++) { - int b = this.bytes[i]; - int remainingUtfBytes = getNumberOfUtfBytes(b) - 1; - b &= INITIAL_BYTE_BITMASK[remainingUtfBytes]; - for (int j = 0; j < remainingUtfBytes; j++) { - b = (b << 6) + (this.bytes[++i] & SUBSEQUENT_BYTE_BITMASK); - } - if (b <= 0xFFFF) { - hash = 31 * hash + b; - } - else { - hash = 31 * hash + ((b >> 0xA) + 0xD7C0); - hash = 31 * hash + ((b & 0x3FF) + 0xDC00); - } - } - this.hash = hash; - } - return hash; - } - private int getNumberOfUtfBytes(int b) { if ((b & 0x80) == 0) { return 1; @@ -236,6 +198,44 @@ final class AsciiBytes { return false; } + @Override + public int hashCode() { + int hash = this.hash; + if (hash == 0 && this.bytes.length > 0) { + for (int i = this.offset; i < this.offset + this.length; i++) { + int b = this.bytes[i]; + int remainingUtfBytes = getNumberOfUtfBytes(b) - 1; + b &= INITIAL_BYTE_BITMASK[remainingUtfBytes]; + for (int j = 0; j < remainingUtfBytes; j++) { + b = (b << 6) + (this.bytes[++i] & SUBSEQUENT_BYTE_BITMASK); + } + if (b <= 0xFFFF) { + hash = 31 * hash + b; + } + else { + hash = 31 * hash + ((b >> 0xA) + 0xD7C0); + hash = 31 * hash + ((b & 0x3FF) + 0xDC00); + } + } + this.hash = hash; + } + return hash; + } + + @Override + public String toString() { + if (this.string == null) { + if (this.length == 0) { + this.string = EMPTY_STRING; + } + else { + this.string = new String(this.bytes, this.offset, this.length, + StandardCharsets.UTF_8); + } + } + return this.string; + } + static String toString(byte[] bytes) { return new String(bytes, StandardCharsets.UTF_8); } @@ -250,7 +250,7 @@ final class AsciiBytes { } public static int hashCode(int hash, char suffix) { - return (suffix != 0 ? (31 * hash + suffix) : hash); + return (suffix != 0) ? (31 * hash + suffix) : hash; } } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryParser.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryParser.java index a29f53b293..e6c23e0016 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryParser.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/CentralDirectoryParser.java @@ -44,7 +44,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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java index 22576ad9d0..39cf82d6e6 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/Handler.java @@ -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. @@ -250,7 +250,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(); @@ -319,7 +319,7 @@ public class Handler extends URLStreamHandler { String path = name.substring(FILE_PROTOCOL.length()); File file = new File(URLDecoder.decode(path, "UTF-8")); Map cache = rootFileCache.get(); - JarFile result = (cache != null ? 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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java index a6188eeed6..733d4fe8b8 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarEntry.java @@ -77,7 +77,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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java index a66c1ac156..9c16b0b74d 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFile.java @@ -120,7 +120,7 @@ public class JarFile extends java.util.jar.JarFile { parser.addVisitor(centralDirectoryVisitor()); this.data = parser.parse(data, filter == null); this.type = type; - this.manifestSupplier = (manifestSupplier != null ? manifestSupplier : () -> { + this.manifestSupplier = (manifestSupplier != null) ? manifestSupplier : () -> { try (InputStream inputStream = getInputStream(MANIFEST_NAME)) { if (inputStream == null) { return null; @@ -130,7 +130,7 @@ public class JarFile extends java.util.jar.JarFile { catch (IOException ex) { throw new RuntimeException(ex); } - }); + }; } private CentralDirectoryVisitor centralDirectoryVisitor() { @@ -168,7 +168,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) { try { manifest = this.manifestSupplier.get(); @@ -218,11 +218,11 @@ public class JarFile extends java.util.jar.JarFile { } @Override - public synchronized InputStream getInputStream(ZipEntry ze) throws IOException { - if (ze instanceof JarEntry) { - return this.entries.getInputStream((JarEntry) ze); + public synchronized InputStream getInputStream(ZipEntry entry) throws IOException { + if (entry instanceof JarEntry) { + return this.entries.getInputStream((JarEntry) entry); } - return getInputStream(ze != null ? ze.getName() : null); + return getInputStream((entry != null) ? entry.getName() : null); } InputStream getInputStream(String name) throws IOException { diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java index 67a4fa3cf0..48196a8196 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarFileEntries.java @@ -243,10 +243,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); @@ -277,7 +277,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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java index 2130ba1395..343a90523c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/JarURLConnection.java @@ -204,7 +204,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; @@ -219,7 +219,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 @@ -241,7 +241,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; @@ -387,8 +387,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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java index 85cf87bbe1..896c45561b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/StringSequence.java @@ -36,7 +36,7 @@ final class StringSequence implements CharSequence { private int hash; StringSequence(String source) { - this(source, 0, source != null ? source.length() : -1); + this(source, 0, (source != null) ? source.length() : -1); } StringSequence(String source, int start, int end) { @@ -106,23 +106,6 @@ final class StringSequence implements CharSequence { return subSequence(offset, offset + prefix.length()).equals(prefix); } - @Override - public String toString() { - return this.source.substring(this.start, this.end); - } - - @Override - public int hashCode() { - int hash = this.hash; - if (hash == 0 && length() > 0) { - for (int i = this.start; i < this.end; i++) { - hash = 31 * hash + this.source.charAt(i); - } - this.hash = hash; - } - return hash; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -146,4 +129,21 @@ final class StringSequence implements CharSequence { return true; } + @Override + public int hashCode() { + int hash = this.hash; + if (hash == 0 && length() > 0) { + for (int i = this.start; i < this.end; i++) { + hash = 31 * hash + this.source.charAt(i); + } + this.hash = hash; + } + return hash; + } + + @Override + public String toString() { + return this.source.substring(this.start, this.end); + } + } diff --git a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java index c545e71f9f..696a4b7a87 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/jar/ZipInflaterInputStream.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. @@ -74,8 +74,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-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java b/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java index 0b9d0bfdb9..6885845b1c 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-loader/src/main/java/org/springframework/boot/loader/util/SystemPropertyUtils.java +++ b/spring-boot-project/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-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java index 14f1c6ef37..75a44323dc 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/AbstractRunMojo.java @@ -392,7 +392,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo { StringBuilder classpath = new StringBuilder(); for (URL ele : getClassPathUrls()) { classpath = classpath - .append((classpath.length() > 0 ? File.pathSeparator : "") + .append(((classpath.length() > 0) ? File.pathSeparator : "") + new File(ele.toURI())); } if (getLog().isDebugEnabled()) { @@ -511,7 +511,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); } @@ -541,7 +541,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-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java index ce4a0b4320..6cb2af240b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/PropertiesMergingResourceTransformer.java @@ -68,7 +68,7 @@ public class PropertiesMergingResourceTransformer implements ResourceTransformer private void process(String name, String value) { String existing = this.data.getProperty(name); - this.data.setProperty(name, (existing != null ? existing + "," + value : value)); + this.data.setProperty(name, (existing != null) ? existing + "," + value : value); } @Override diff --git a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java index 3d0a699e75..306d93ce8b 100644 --- a/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java +++ b/spring-boot-project/spring-boot-tools/spring-boot-maven-plugin/src/main/java/org/springframework/boot/maven/RepackageMojo.java @@ -251,7 +251,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.isEmpty() && !classifier.startsWith("-")) { classifier = "-" + classifier; } @@ -312,7 +312,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-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java index 7089669307..ce38cf8e57 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/BeanDefinitionLoader.java @@ -219,8 +219,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-project/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java index 8ea84f92f6..555a96d5a9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/DefaultApplicationArguments.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 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-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java index 8087f70fe8..840636088e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/EnvironmentConverter.java +++ b/spring-boot-project/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-project/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java index 4f317e4ab3..d491b73fa6 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ExitCodeGenerators.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. @@ -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-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java index 247249f572..76f64f532e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ImageBanner.java @@ -161,9 +161,9 @@ public class ImageBanner implements Banner { IIOMetadataNode root = (IIOMetadataNode) metadata .getAsTree(metadata.getNativeMetadataFormatName()); IIOMetadataNode extension = findNode(root, "GraphicControlExtension"); - String attribute = (extension != null ? extension.getAttribute("delayTime") - : null); - return (attribute != null ? Integer.parseInt(attribute) * 10 : 0); + String attribute = (extension != null) ? extension.getAttribute("delayTime") + : null; + return (attribute != null) ? Integer.parseInt(attribute) * 10 : 0; } private static IIOMetadataNode findNode(IIOMetadataNode rootNode, String nodeName) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java index a22ee6b6e3..77b0b64dab 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ResourceBanner.java @@ -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. @@ -107,8 +107,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() { @@ -132,14 +132,14 @@ public class ResourceBanner implements Banner { MutablePropertySources sources = new MutablePropertySources(); String applicationTitle = getApplicationTitle(sourceClass); Map titleMap = Collections.singletonMap("application.title", - (applicationTitle != null ? applicationTitle : "")); + (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-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index 90dbc2ecac..d9e5bf6e3f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -563,8 +563,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) { @@ -995,7 +995,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; @@ -1301,7 +1301,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-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java index 947fc2f28b..46c0af194f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationBannerPrinter.java @@ -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. @@ -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-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java index 16c94e87fe..27e1c71fea 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplicationRunListeners.java @@ -99,7 +99,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-project/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java index 99e60aceed..ae491ffa59 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootBanner.java +++ b/spring-boot-project/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 + ")" : ""; StringBuilder padding = new StringBuilder(); while (padding.length() < STRAP_LINE_SIZE - (version.length() + SPRING_BOOT.length())) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootVersion.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootVersion.java index 971b98753d..d80f1790d8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootVersion.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringBootVersion.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,7 +41,7 @@ public final class SpringBootVersion { */ public static String getVersion() { Package pkg = SpringBootVersion.class.getPackage(); - return (pkg != null ? pkg.getImplementationVersion() : null); + return (pkg != null) ? pkg.getImplementationVersion() : null; } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java index f3164e2ea7..a8b69cb091 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/StartupInfoLogger.java @@ -97,8 +97,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(Class source) { @@ -117,8 +117,8 @@ class StartupInfoLogger { String startedBy = getValue("started by ", () -> System.getProperty("user.name")); String in = getValue("in ", () -> System.getProperty("user.dir")); 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-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java index 9f5868fc97..e01a398ba3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/ansi/AnsiColors.java +++ b/spring-boot-project/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) : null); + this((rgb != null) ? new Color(rgb) : null); } LabColor(Color color) { @@ -117,8 +117,8 @@ public final class AnsiColors { } private double f(double 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)); + 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); } // See http://en.wikipedia.org/wiki/Color_difference#CIE94 diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java index 9f69bd5dd2..2499e70d3d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/ParentContextCloserApplicationListener.java @@ -101,11 +101,6 @@ public class ParentContextCloserApplicationListener } } - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.childContext.get()); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -122,6 +117,11 @@ public class ParentContextCloserApplicationListener return super.equals(obj); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.childContext.get()); + } + } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index 3d4c07157b..e05f8868af 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java @@ -94,8 +94,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(Class... sources) { @@ -313,7 +313,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) { @@ -384,8 +384,8 @@ public class SpringApplicationBuilder { Map map = new HashMap<>(); for (String property : properties) { int index = lowestIndexOf(property, ":", "="); - String key = (index > 0 ? property.substring(0, index) : property); - String value = (index > 0 ? property.substring(index + 1) : ""); + String key = (index > 0) ? property.substring(0, index) : property; + String value = (index > 0) ? property.substring(index + 1) : ""; map.put(key, value); } return map; @@ -396,7 +396,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-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java index 4425eb29ba..2fe560627a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/cloud/CloudFoundryVcapEnvironmentPostProcessor.java @@ -225,7 +225,7 @@ public class CloudFoundryVcapEnvironmentPostProcessor properties.put(name, value.toString()); } else { - properties.put(name, value != null ? value : ""); + properties.put(name, (value != null) ? value : ""); } }); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java index 03bff0b9de..2673168d77 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/ApplicationPidFileWriter.java @@ -163,7 +163,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-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index 46a1f4de8a..56c1ffc904 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -311,8 +311,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(); this.propertySourceLoaders = SpringFactoriesLoader.loadFactories( PropertySourceLoader.class, getClass().getClassLoader()); } @@ -586,8 +586,8 @@ public class ConfigFileApplicationListener private String getDescription(String location, Resource resource, Profile profile) { String description = getDescription(location, resource); - return (profile != null ? description + " for profile " + profile - : description); + return (profile != null) ? description + " for profile " + profile + : description; } private String getDescription(String location, Resource resource) { @@ -663,7 +663,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); @@ -729,16 +729,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) { @@ -750,6 +740,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; + } + } /** @@ -766,11 +766,6 @@ public class ConfigFileApplicationListener this.resource = resource; } - @Override - public int hashCode() { - return this.loader.hashCode() * 31 + this.resource.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -784,6 +779,11 @@ public class ConfigFileApplicationListener && this.resource.equals(other.resource); } + @Override + public int hashCode() { + return this.loader.hashCode() * 31 + this.resource.hashCode(); + } + } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java index 4987b4bccd..687dfbab62 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationBeanFactoryMetadata.java @@ -77,7 +77,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; } public Method findFactoryMethod(String beanName) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java index 743b72a3cb..ff0a5a5fb9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java @@ -98,9 +98,9 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc private void bind(Object bean, String beanName, ConfigurationProperties annotation) { ResolvableType type = getBeanType(bean, beanName); Validated validated = getAnnotation(bean, beanName, Validated.class); - Annotation[] annotations = (validated != null + Annotation[] annotations = (validated != null) ? new Annotation[] { annotation, validated } - : new Annotation[] { annotation }); + : new Annotation[] { annotation }; Bindable target = Bindable.of(type).withExistingValue(bean) .withAnnotations(annotations); try { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java index d5dee53d7a..2e42438f97 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/EnableConfigurationPropertiesImportSelector.java @@ -75,7 +75,7 @@ class EnableConfigurationPropertiesImportSelector implements ImportSelector { MultiValueMap attributes = metadata .getAllAnnotationAttributes( EnableConfigurationProperties.class.getName(), false); - return collectClasses(attributes != null ? attributes.get("value") + return collectClasses((attributes != null) ? attributes.get("value") : Collections.emptyList()); } @@ -96,7 +96,7 @@ class EnableConfigurationPropertiesImportSelector implements ImportSelector { private String getName(Class type) { ConfigurationProperties annotation = AnnotationUtils.findAnnotation(type, ConfigurationProperties.class); - String prefix = (annotation != null ? annotation.prefix() : ""); + String prefix = (annotation != null) ? annotation.prefix() : ""; return (StringUtils.hasText(prefix) ? prefix + "-" + type.getName() : type.getName()); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/AggregateBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/AggregateBinder.java index 677b159c3a..ddbe0a5d34 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/AggregateBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/AggregateBinder.java @@ -92,7 +92,7 @@ abstract class AggregateBinder { /** * Internal class used to supply the aggregate and cache the value. * - * @param The aggregate type + * @param the aggregate type */ protected static class AggregateSupplier { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanBinder.java index ca7bb27ac9..9805018fc0 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BeanBinder.java @@ -34,7 +34,7 @@ interface BeanBinder { * @param target the bindable to bind * @param context the bind context * @param propertyBinder property binder - * @param The source type + * @param the source type * @return a bound instance or {@code null} */ T bind(ConfigurationPropertyName name, Bindable target, Context context, diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java index c8de87f60f..daf60ba523 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindConverter.java @@ -124,7 +124,7 @@ class BindConverter { public boolean canConvert(Class sourceType, Class targetType) { Assert.notNull(targetType, "Target type to convert to cannot be null"); return canConvert( - (sourceType != null ? TypeDescriptor.valueOf(sourceType) : null), + (sourceType != null) ? TypeDescriptor.valueOf(sourceType) : null, TypeDescriptor.valueOf(targetType)); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindException.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindException.java index 640c8b2134..2a1b82a59e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindException.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindException.java @@ -77,7 +77,7 @@ public class BindException extends RuntimeException implements OriginProvider { Bindable target) { StringBuilder message = new StringBuilder(); message.append("Failed to bind properties"); - message.append(name != null ? " under '" + name + "'" : ""); + message.append((name != null) ? " under '" + name + "'" : ""); message.append(" to ").append(target.getType()); return message.toString(); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java index 3d369c2a73..f1ff739fa7 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/BindResult.java @@ -29,7 +29,7 @@ import org.springframework.util.ObjectUtils; * A container object to return result of a {@link Binder} bind operation. May contain * either a successfully bound object or an empty result. * - * @param The result type + * @param the result type * @author Phillip Webb * @author Madhura Bhave * @since 2.0.0 @@ -81,7 +81,7 @@ public final class BindResult { /** * Apply the provided mapping function to the bound value, or return an updated * unbound result if no value has been bound. - * @param The type of the result of the mapping function + * @param the type of the result of the mapping function * @param mapper a mapping function to apply to the bound value. The mapper will not * be invoked if no value has been bound. * @return an {@code BindResult} describing the result of applying a mapping function @@ -89,7 +89,7 @@ public final class BindResult { */ public BindResult map(Function mapper) { Assert.notNull(mapper, "Mapper must not be null"); - return of(this.value != null ? mapper.apply(this.value) : null); + return of((this.value != null) ? mapper.apply(this.value) : null); } /** @@ -99,7 +99,7 @@ public final class BindResult { * @return the value, if bound, otherwise {@code other} */ public T orElse(T other) { - return (this.value != null ? this.value : other); + return (this.value != null) ? this.value : other; } /** @@ -110,7 +110,7 @@ public final class BindResult { * @return the value, if bound, otherwise the supplied {@code other} */ public T orElseGet(Supplier other) { - return (this.value != null ? this.value : other.get()); + return (this.value != null) ? this.value : other.get(); } /** @@ -121,14 +121,14 @@ public final class BindResult { */ public T orElseCreate(Class type) { Assert.notNull(type, "Type must not be null"); - return (this.value != null ? this.value : BeanUtils.instantiateClass(type)); + return (this.value != null) ? this.value : BeanUtils.instantiateClass(type); } /** * Return the object that was bound, or throw an exception to be created by the * provided supplier if no value has been bound. - * @param Type of the exception to be thrown - * @param exceptionSupplier The supplier which will return the exception to be thrown + * @param the type of the exception to be thrown + * @param exceptionSupplier the supplier which will return the exception to be thrown * @return the present value * @throws X if there is no value present */ @@ -140,11 +140,6 @@ public final class BindResult { return this.value; } - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.value); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -156,6 +151,11 @@ public final class BindResult { return ObjectUtils.nullSafeEquals(this.value, ((BindResult) obj).value); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.value); + } + @SuppressWarnings("unchecked") static BindResult of(T value) { if (value == null) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java index f66c3d05b8..09ba0a9dc7 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Bindable.java @@ -31,7 +31,7 @@ import org.springframework.util.ObjectUtils; /** * Source that can be bound by a {@link Binder}. * - * @param The source type + * @param the source type * @author Phillip Webb * @author Madhura Bhave * @since 2.0.0 @@ -106,24 +106,6 @@ public final class Bindable { return null; } - @Override - public String toString() { - ToStringCreator creator = new ToStringCreator(this); - creator.append("type", this.type); - creator.append("value", (this.value != null ? "provided" : "none")); - creator.append("annotations", this.annotations); - return creator.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ObjectUtils.nullSafeHashCode(this.type); - result = prime * result + ObjectUtils.nullSafeHashCode(this.annotations); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -139,6 +121,24 @@ public final class Bindable { return result; } + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ObjectUtils.nullSafeHashCode(this.type); + result = prime * result + ObjectUtils.nullSafeHashCode(this.annotations); + return result; + } + + @Override + public String toString() { + ToStringCreator creator = new ToStringCreator(this); + creator.append("type", this.type); + creator.append("value", (this.value != null) ? "provided" : "none"); + creator.append("annotations", this.annotations); + return creator.toString(); + } + private boolean nullSafeEquals(Object o1, Object o2) { return ObjectUtils.nullSafeEquals(o1, o2); } @@ -150,7 +150,7 @@ public final class Bindable { */ public Bindable withAnnotations(Annotation... annotations) { return new Bindable<>(this.type, this.boxedType, this.value, - (annotations != null ? annotations : NO_ANNOTATIONS)); + (annotations != null) ? annotations : NO_ANNOTATIONS); } /** @@ -163,7 +163,7 @@ public final class Bindable { existingValue == null || this.type.isArray() || this.boxedType.resolve().isInstance(existingValue), () -> "ExistingValue must be an instance of " + this.type); - Supplier value = (existingValue != null ? () -> existingValue : null); + Supplier value = (existingValue != null) ? () -> existingValue : null; return new Bindable<>(this.type, this.boxedType, value, NO_ANNOTATIONS); } @@ -179,7 +179,7 @@ public final class Bindable { /** * Create a new {@link Bindable} of the type of the specified instance with an * existing value equal to the instance. - * @param The source type + * @param the source type * @param instance the instance (must not be {@code null}) * @return a {@link Bindable} instance * @see #of(ResolvableType) @@ -194,7 +194,7 @@ public final class Bindable { /** * Create a new {@link Bindable} of the specified type. - * @param The source type + * @param the source type * @param type the type (must not be {@code null}) * @return a {@link Bindable} instance * @see #of(ResolvableType) @@ -238,7 +238,7 @@ public final class Bindable { /** * Create a new {@link Bindable} of the specified type. - * @param The source type + * @param the source type * @param type the type (must not be {@code null}) * @return a {@link Bindable} instance * @see #of(Class) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java index 12295d5cfa..65009bf5f1 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/Binder.java @@ -132,10 +132,10 @@ public class Binder { Consumer propertyEditorInitializer) { Assert.notNull(sources, "Sources must not be null"); this.sources = sources; - this.placeholdersResolver = (placeholdersResolver != null ? placeholdersResolver - : PlaceholdersResolver.NONE); - this.conversionService = (conversionService != null ? conversionService - : ApplicationConversionService.getSharedInstance()); + this.placeholdersResolver = (placeholdersResolver != null) ? placeholdersResolver + : PlaceholdersResolver.NONE; + this.conversionService = (conversionService != null) ? conversionService + : ApplicationConversionService.getSharedInstance(); this.propertyEditorInitializer = propertyEditorInitializer; } @@ -204,7 +204,7 @@ public class Binder { BindHandler handler) { Assert.notNull(name, "Name must not be null"); Assert.notNull(target, "Target must not be null"); - handler = (handler != null ? handler : BindHandler.DEFAULT); + handler = (handler != null) ? handler : BindHandler.DEFAULT; Context context = new Context(); T bound = bind(name, target, handler, context, false); return BindResult.of(bound); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java index 81f76c2b77..4213abd7da 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/CollectionBinder.java @@ -40,8 +40,8 @@ class CollectionBinder extends IndexedElementsBinder> { @Override protected Object bindAggregate(ConfigurationPropertyName name, Bindable target, AggregateElementBinder elementBinder) { - Class collectionType = (target.getValue() != null ? List.class - : target.getType().resolve(Object.class)); + Class collectionType = (target.getValue() != null) ? List.class + : target.getType().resolve(Object.class); ResolvableType aggregateType = ResolvableType.forClassWithGenerics(List.class, target.getType().asCollection().getGenerics()); ResolvableType elementType = target.getType().asCollection().getGeneric(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java index 2ed0022c18..ffe5d33df8 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/IndexedElementsBinder.java @@ -57,7 +57,7 @@ abstract class IndexedElementsBinder extends AggregateBinder { /** * Bind indexed elements to the supplied collection. - * @param name The name of the property to bind + * @param name the name of the property to bind * @param target the target bindable * @param elementBinder the binder to use for elements * @param aggregateType the aggregate type, may be a collection or an array @@ -109,7 +109,7 @@ abstract class IndexedElementsBinder extends AggregateBinder { source, root); for (int i = 0; i < Integer.MAX_VALUE; i++) { ConfigurationPropertyName name = root - .append(i != 0 ? "[" + i + "]" : INDEX_ZERO); + .append((i != 0) ? "[" + i + "]" : INDEX_ZERO); Object value = elementBinder.bind(name, Bindable.of(elementType), source); if (value == null) { break; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java index 6f99796f2d..89e54038e9 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/JavaBeanBinder.java @@ -184,7 +184,7 @@ class JavaBeanBinder implements BeanBinder { T instance = null; if (canCallGetValue && value != null) { instance = value.get(); - type = (instance != null ? instance.getClass() : type); + type = (instance != null) ? instance.getClass() : type; } if (instance == null && !isInstantiable(type)) { return null; @@ -287,7 +287,7 @@ class JavaBeanBinder implements BeanBinder { public Annotation[] getAnnotations() { try { - return (this.field != null ? this.field.getDeclaredAnnotations() : null); + return (this.field != null) ? this.field.getDeclaredAnnotations() : null; } catch (Exception ex) { return null; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java index 07717364fc..35d45153de 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/MapBinder.java @@ -54,8 +54,8 @@ class MapBinder extends AggregateBinder> { @Override protected Object bindAggregate(ConfigurationPropertyName name, Bindable target, AggregateElementBinder elementBinder) { - Map map = CollectionFactory.createMap((target.getValue() != null - ? Map.class : target.getType().resolve(Object.class)), 0); + Map map = CollectionFactory.createMap((target.getValue() != null) + ? Map.class : target.getType().resolve(Object.class), 0); Bindable resolvedTarget = resolveTarget(target); boolean hasDescendants = getContext().streamSources().anyMatch((source) -> source .containsDescendantOf(name) == ConfigurationPropertyState.PRESENT); @@ -214,7 +214,7 @@ class MapBinder extends AggregateBinder> { StringBuilder result = new StringBuilder(); for (int i = this.root.getNumberOfElements(); i < name .getNumberOfElements(); i++) { - result.append(result.length() != 0 ? "." : ""); + result.append((result.length() != 0) ? "." : ""); result.append(name.getElement(i, Form.ORIGINAL)); } return result.toString(); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java index 6c2794b49f..41d044a476 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/PropertySourcesPlaceholdersResolver.java @@ -48,10 +48,10 @@ public class PropertySourcesPlaceholdersResolver implements PlaceholdersResolver public PropertySourcesPlaceholdersResolver(Iterable> sources, PropertyPlaceholderHelper helper) { this.sources = sources; - this.helper = (helper != null ? helper + this.helper = (helper != null) ? helper : new PropertyPlaceholderHelper(SystemPropertyUtils.PLACEHOLDER_PREFIX, SystemPropertyUtils.PLACEHOLDER_SUFFIX, - SystemPropertyUtils.VALUE_SEPARATOR, true)); + SystemPropertyUtils.VALUE_SEPARATOR, true); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/IgnoreErrorsBindHandler.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/IgnoreErrorsBindHandler.java index d9a3f7fdbb..c0fa273a35 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/IgnoreErrorsBindHandler.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/bind/handler/IgnoreErrorsBindHandler.java @@ -41,7 +41,7 @@ public class IgnoreErrorsBindHandler extends AbstractBindHandler { @Override public Object onFailure(ConfigurationPropertyName name, Bindable target, BindContext context, Exception error) throws Exception { - return (target.getValue() != null ? target.getValue().get() : null); + return (target.getValue() != null) ? target.getValue().get() : null; } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java index 30ded56ab3..d8b359c194 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationProperty.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. @@ -63,13 +63,6 @@ public final class ConfigurationProperty return this.origin; } - @Override - public int hashCode() { - int result = ObjectUtils.nullSafeHashCode(this.name); - result = 31 * result + ObjectUtils.nullSafeHashCode(this.value); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -85,6 +78,13 @@ public final class ConfigurationProperty return result; } + @Override + public int hashCode() { + int result = ObjectUtils.nullSafeHashCode(this.name); + result = 31 * result + ObjectUtils.nullSafeHashCode(this.value); + return result; + } + @Override public String toString() { return new ToStringCreator(this).append("name", this.name) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index c5cb44b45f..34326b6769 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java @@ -131,7 +131,7 @@ public final class ConfigurationPropertyName */ public String getLastElement(Form form) { int size = getNumberOfElements(); - return (size != 0 ? getElement(size - 1, form) : EMPTY_STRING); + return (size != 0) ? getElement(size - 1, form) : EMPTY_STRING; } /** @@ -259,10 +259,10 @@ public final class ConfigurationPropertyName int i1 = 0; int i2 = 0; while (i1 < l1 || i2 < l2) { - boolean indexed1 = (i1 < l1 ? n1.isIndexed(i2) : false); - boolean indexed2 = (i2 < l2 ? n2.isIndexed(i2) : false); - String e1 = (i1 < l1 ? n1.getElement(i1++, Form.UNIFORM) : null); - String e2 = (i2 < l2 ? n2.getElement(i2++, Form.UNIFORM) : null); + boolean indexed1 = (i1 < l1) ? n1.isIndexed(i2) : false; + boolean indexed2 = (i2 < l2) ? n2.isIndexed(i2) : false; + String e1 = (i1 < l1) ? n1.getElement(i1++, Form.UNIFORM) : null; + String e2 = (i2 < l2) ? n2.getElement(i2++, Form.UNIFORM) : null; int result = compare(e1, indexed1, e2, indexed2); if (result != 0) { return result; @@ -295,62 +295,6 @@ public final class ConfigurationPropertyName return e1.compareTo(e2); } - @Override - public String toString() { - if (this.string == null) { - this.string = toString(this.elements); - } - return this.string; - } - - private String toString(CharSequence[] elements) { - StringBuilder result = new StringBuilder(); - for (CharSequence element : elements) { - boolean indexed = isIndexed(element); - if (result.length() > 0 && !indexed) { - result.append("."); - } - if (indexed) { - result.append(element); - } - else { - for (int i = 0; i < element.length(); i++) { - char ch = Character.toLowerCase(element.charAt(i)); - result.append(ch != '_' ? ch : ""); - } - } - } - return result.toString(); - } - - @Override - public int hashCode() { - if (this.elementHashCodes == null) { - this.elementHashCodes = getElementHashCodes(); - } - return ObjectUtils.nullSafeHashCode(this.elementHashCodes); - } - - private int[] getElementHashCodes() { - int[] hashCodes = new int[this.elements.length]; - for (int i = 0; i < this.elements.length; i++) { - hashCodes[i] = getElementHashCode(this.elements[i]); - } - return hashCodes; - } - - private int getElementHashCode(CharSequence element) { - int hash = 0; - boolean indexed = isIndexed(element); - int offset = (indexed ? 1 : 0); - for (int i = 0 + offset; i < element.length() - offset; i++) { - char ch = (indexed ? element.charAt(i) - : Character.toLowerCase(element.charAt(i))); - hash = (ch == '-' || ch == '_' ? hash : 31 * hash + Character.hashCode(ch)); - } - return hash; - } - @Override public boolean equals(Object obj) { if (obj == this) { @@ -409,6 +353,62 @@ public final class ConfigurationPropertyName return true; } + @Override + public int hashCode() { + if (this.elementHashCodes == null) { + this.elementHashCodes = getElementHashCodes(); + } + return ObjectUtils.nullSafeHashCode(this.elementHashCodes); + } + + private int[] getElementHashCodes() { + int[] hashCodes = new int[this.elements.length]; + for (int i = 0; i < this.elements.length; i++) { + hashCodes[i] = getElementHashCode(this.elements[i]); + } + return hashCodes; + } + + private int getElementHashCode(CharSequence element) { + int hash = 0; + boolean indexed = isIndexed(element); + int offset = (indexed ? 1 : 0); + for (int i = 0 + offset; i < element.length() - offset; i++) { + char ch = (indexed ? element.charAt(i) + : Character.toLowerCase(element.charAt(i))); + hash = (ch == '-' || ch == '_') ? hash : 31 * hash + Character.hashCode(ch); + } + return hash; + } + + @Override + public String toString() { + if (this.string == null) { + this.string = toString(this.elements); + } + return this.string; + } + + private String toString(CharSequence[] elements) { + StringBuilder result = new StringBuilder(); + for (CharSequence element : elements) { + boolean indexed = isIndexed(element); + if (result.length() > 0 && !indexed) { + result.append("."); + } + if (indexed) { + result.append(element); + } + else { + for (int i = 0; i < element.length(); i++) { + char ch = Character.toLowerCase(element.charAt(i)); + result.append((ch != '_') ? ch : ""); + } + } + } + return result.toString(); + } + private static boolean isIndexed(CharSequence element) { return element.charAt(0) == '[' && element.charAt(element.length() - 1) == ']'; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertySource.java index 772c662b55..e2212a8bdd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertySourcesPropertySource.java @@ -42,7 +42,7 @@ class ConfigurationPropertySourcesPropertySource @Override public Object getProperty(String name) { ConfigurationProperty configurationProperty = findConfigurationProperty(name); - return (configurationProperty != null ? configurationProperty.getValue() : null); + return (configurationProperty != null) ? configurationProperty.getValue() : null; } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java index 904274de25..dadefaef0f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySource.java @@ -75,7 +75,7 @@ public class MapConfigurationPropertySource * @param value the value */ public void put(Object name, Object value) { - this.source.put((name != null ? name.toString() : null), value); + this.source.put((name != null) ? name.toString() : null, value); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySource.java index 9b1a120632..e19a9a68c0 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringConfigurationPropertySource.java @@ -77,10 +77,10 @@ class SpringConfigurationPropertySource implements ConfigurationPropertySource { Assert.notNull(propertySource, "PropertySource must not be null"); Assert.notNull(mapper, "Mapper must not be null"); this.propertySource = propertySource; - this.mapper = (mapper instanceof DelegatingPropertyMapper ? mapper - : new DelegatingPropertyMapper(mapper)); - this.containsDescendantOf = (containsDescendantOf != null ? containsDescendantOf - : (n) -> ConfigurationPropertyState.UNKNOWN); + this.mapper = (mapper instanceof DelegatingPropertyMapper) ? mapper + : new DelegatingPropertyMapper(mapper); + this.containsDescendantOf = (containsDescendantOf != null) ? containsDescendantOf + : (n) -> ConfigurationPropertyState.UNKNOWN; } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java index 173e86c63d..8fff79f065 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/SpringIterableConfigurationPropertySource.java @@ -95,7 +95,7 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope private List getConfigurationPropertyNames() { Cache cache = getCache(); - List names = (cache != null ? cache.getNames() : null); + List names = (cache != null) ? cache.getNames() : null; if (names != null) { return names; } @@ -112,7 +112,7 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope } private PropertyMapping[] getPropertyMappings(Cache cache) { - PropertyMapping[] result = (cache != null ? cache.getMappings() : null); + PropertyMapping[] result = (cache != null) ? cache.getMappings() : null; if (result != null) { return result; } @@ -191,11 +191,6 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope return ((String[]) key).clone(); } - @Override - public int hashCode() { - return this.key.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -207,6 +202,11 @@ class SpringIterableConfigurationPropertySource extends SpringConfigurationPrope return ObjectUtils.nullSafeEquals(this.key, ((CacheKey) obj).key); } + @Override + public int hashCode() { + return this.key.hashCode(); + } + public static CacheKey get(EnumerablePropertySource source) { if (source instanceof MapPropertySource) { return new CacheKey(((MapPropertySource) source).getSource().keySet()); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CollectionToDelimitedStringConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CollectionToDelimitedStringConverter.java index 42a02bfcc1..dc016b760c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CollectionToDelimitedStringConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/CollectionToDelimitedStringConverter.java @@ -71,10 +71,14 @@ final class CollectionToDelimitedStringConverter implements ConditionalGenericCo if (source.isEmpty()) { return ""; } - Delimiter delimiter = sourceType.getAnnotation(Delimiter.class); return source.stream() .map((element) -> convertElement(element, sourceType, targetType)) - .collect(Collectors.joining(delimiter != null ? delimiter.value() : ",")); + .collect(Collectors.joining(getDelimter(sourceType))); + } + + private CharSequence getDelimter(TypeDescriptor sourceType) { + Delimiter annotation = sourceType.getAnnotation(Delimiter.class); + return (annotation != null) ? annotation.value() : ","; } private String convertElement(Object element, TypeDescriptor sourceType, diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToArrayConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToArrayConverter.java index 1cf45f1d53..581946fa54 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToArrayConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToArrayConverter.java @@ -66,7 +66,7 @@ final class DelimitedStringToArrayConverter implements ConditionalGenericConvert TypeDescriptor targetType) { Delimiter delimiter = targetType.getAnnotation(Delimiter.class); String[] elements = getElements(source, - (delimiter != null ? delimiter.value() : ",")); + (delimiter != null) ? delimiter.value() : ","); TypeDescriptor elementDescriptor = targetType.getElementTypeDescriptor(); Object target = Array.newInstance(elementDescriptor.getType(), elements.length); for (int i = 0; i < elements.length; i++) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToCollectionConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToCollectionConverter.java index 45a32d9c66..0b7670f519 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToCollectionConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DelimitedStringToCollectionConverter.java @@ -69,7 +69,7 @@ final class DelimitedStringToCollectionConverter implements ConditionalGenericCo TypeDescriptor targetType) { Delimiter delimiter = targetType.getAnnotation(Delimiter.class); String[] elements = getElements(source, - (delimiter != null ? delimiter.value() : ",")); + (delimiter != null) ? delimiter.value() : ","); TypeDescriptor elementDescriptor = targetType.getElementTypeDescriptor(); Collection target = createCollection(targetType, elementDescriptor, elements.length); @@ -85,7 +85,7 @@ final class DelimitedStringToCollectionConverter implements ConditionalGenericCo private Collection createCollection(TypeDescriptor targetType, TypeDescriptor elementDescriptor, int length) { return CollectionFactory.createCollection(targetType.getType(), - (elementDescriptor != null ? elementDescriptor.getType() : null), length); + (elementDescriptor != null) ? elementDescriptor.getType() : null, length); } private String[] getElements(String source, String delimiter) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToNumberConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToNumberConverter.java index b57057929d..9235ab1187 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToNumberConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToNumberConverter.java @@ -46,11 +46,15 @@ final class DurationToNumberConverter implements GenericConverter { if (source == null) { return null; } - DurationUnit unit = sourceType.getAnnotation(DurationUnit.class); - return convert((Duration) source, (unit != null ? unit.value() : null), + return convert((Duration) source, getDurationUnit(sourceType), targetType.getObjectType()); } + private ChronoUnit getDurationUnit(TypeDescriptor sourceType) { + DurationUnit annotation = sourceType.getAnnotation(DurationUnit.class); + return (annotation != null) ? annotation.value() : null; + } + private Object convert(Duration source, ChronoUnit unit, Class type) { try { return type.getConstructor(String.class).newInstance(String diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToStringConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToStringConverter.java index 89878ab06c..1cc80dc457 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToStringConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/DurationToStringConverter.java @@ -45,14 +45,22 @@ final class DurationToStringConverter implements GenericConverter { if (source == null) { return null; } - DurationFormat format = sourceType.getAnnotation(DurationFormat.class); - DurationUnit unit = sourceType.getAnnotation(DurationUnit.class); - return convert((Duration) source, (format != null ? format.value() : null), - (unit != null ? unit.value() : null)); + return convert((Duration) source, getDurationStyle(sourceType), + getDurationUnit(sourceType)); + } + + private ChronoUnit getDurationUnit(TypeDescriptor sourceType) { + DurationUnit annotation = sourceType.getAnnotation(DurationUnit.class); + return (annotation != null) ? annotation.value() : null; + } + + private DurationStyle getDurationStyle(TypeDescriptor sourceType) { + DurationFormat annotation = sourceType.getAnnotation(DurationFormat.class); + return (annotation != null) ? annotation.value() : null; } private String convert(Duration source, DurationStyle style, ChronoUnit unit) { - style = (style != null ? style : DurationStyle.ISO8601); + style = (style != null) ? style : DurationStyle.ISO8601; return style.print(source, unit); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/NumberToDurationConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/NumberToDurationConverter.java index 9890e9d6f9..4307c095a4 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/NumberToDurationConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/NumberToDurationConverter.java @@ -44,7 +44,7 @@ final class NumberToDurationConverter implements GenericConverter { @Override public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { - return this.delegate.convert(source != null ? source.toString() : null, + return this.delegate.convert((source != null) ? source.toString() : null, TypeDescriptor.valueOf(String.class), targetType); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java index 265c003e16..354d964007 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/convert/StringToDurationConverter.java @@ -47,14 +47,22 @@ final class StringToDurationConverter implements GenericConverter { if (ObjectUtils.isEmpty(source)) { return null; } - DurationFormat format = targetType.getAnnotation(DurationFormat.class); - DurationUnit unit = targetType.getAnnotation(DurationUnit.class); - return convert(source.toString(), (format != null ? format.value() : null), - (unit != null ? unit.value() : null)); + return convert(source.toString(), getStyle(targetType), + getDurationUnit(targetType)); + } + + private DurationStyle getStyle(TypeDescriptor targetType) { + DurationFormat annotation = targetType.getAnnotation(DurationFormat.class); + return (annotation != null) ? annotation.value() : null; + } + + private ChronoUnit getDurationUnit(TypeDescriptor targetType) { + DurationUnit annotation = targetType.getAnnotation(DurationUnit.class); + return (annotation != null) ? annotation.value() : null; } private Duration convert(String source, DurationStyle style, ChronoUnit unit) { - style = (style != null ? style : DurationStyle.detect(source)); + style = (style != null) ? style : DurationStyle.detect(source); return style.parse(source, unit); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java index bbdad56c6f..f3b4bb8781 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/FailureAnalyzers.java @@ -61,7 +61,7 @@ final class FailureAnalyzers implements SpringBootExceptionReporter { 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-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java index 424d1300f1..588251ef54 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.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,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-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java index ade8e65ff9..1438450fe3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/InvalidConfigurationPropertyValueFailureAnalyzer.java @@ -109,7 +109,7 @@ class InvalidConfigurationPropertyValueFailureAnalyzer message.append(String.format( "%n%nAdditionally, this property is also set in the following " + "property %s:%n%n", - others.size() > 1 ? "sources" : "source")); + (others.size() > 1) ? "sources" : "source")); for (Descriptor other : others) { message.append("\t- In '" + other.getPropertySource() + "'"); message.append(" with the value '" + other.getValue() + "'"); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java index 7976529373..9132e0e19d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/OriginTrackedYamlLoader.java @@ -105,7 +105,7 @@ class OriginTrackedYamlLoader extends YamlProcessor { } private Object getValue(Object value) { - return (value != null ? value : ""); + return (value != null) ? value : ""; } private Origin getOrigin(Node node) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java index 7f412ebba9..3570a42026 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/SpringApplicationJsonEnvironmentPostProcessor.java @@ -113,7 +113,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) { @@ -124,7 +124,7 @@ public class SpringApplicationJsonEnvironmentPostProcessor private void flatten(String prefix, Map result, Map map) { - String namePrefix = (prefix != null ? prefix + "." : ""); + String namePrefix = (prefix != null) ? prefix + "." : ""; map.forEach((key, value) -> extract(namePrefix + key, result, value)); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java index 336d5dbd6b..2b5aeca24b 100755 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/env/YamlPropertySourceLoader.java @@ -53,8 +53,8 @@ public class YamlPropertySourceLoader implements PropertySourceLoader { } List> propertySources = new ArrayList<>(loaded.size()); for (int i = 0; i < loaded.size(); i++) { - propertySources.add(new OriginTrackedMapPropertySource( - name + (loaded.size() != 1 ? " (document #" + i + ")" : ""), + String documentNumber = (loaded.size() != 1) ? " (document #" + i + ")" : ""; + propertySources.add(new OriginTrackedMapPropertySource(name + documentNumber, loaded.get(i))); } return propertySources; diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/GitProperties.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/GitProperties.java index ffb7eb1a58..43632501fc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/GitProperties.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/info/GitProperties.java @@ -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-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonComponentModule.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonComponentModule.java index e35641de20..4022026e7f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jackson/JsonComponentModule.java +++ b/spring-boot-project/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-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java index 9a7d36fea4..32770c45fc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DataSourceBuilder.java @@ -138,8 +138,8 @@ public final class DataSourceBuilder { } private Class getType() { - Class type = (this.type != null ? this.type - : findType(this.classLoader)); + Class type = (this.type != null) ? this.type + : findType(this.classLoader); if (type != null) { return type; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java index 669983370e..367f0dcd30 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/DatabaseDriver.java +++ b/spring-boot-project/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-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java index 15b8743480..a26f861cb3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/EmbeddedDatabaseConnection.java @@ -97,7 +97,7 @@ public enum EmbeddedDatabaseConnection { */ public String getUrl(String databaseName) { Assert.hasText(databaseName, "DatabaseName must not be empty"); - 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-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java index 6bd415c194..d794886fbc 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/CompositeDataSourcePoolMetadataProvider.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. @@ -42,9 +42,9 @@ public class CompositeDataSourcePoolMetadataProvider */ public CompositeDataSourcePoolMetadataProvider( Collection providers) { - this.providers = (providers != null + this.providers = (providers != null) ? Collections.unmodifiableList(new ArrayList<>(providers)) - : Collections.emptyList()); + : Collections.emptyList(); } @Override diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/TomcatDataSourcePoolMetadata.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/TomcatDataSourcePoolMetadata.java index 65257b96b9..61a5777762 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/TomcatDataSourcePoolMetadata.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jdbc/metadata/TomcatDataSourcePoolMetadata.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. @@ -35,7 +35,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-project/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java index c8b1dc8064..4a5cc4fb0a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/json/AbstractJsonParser.java @@ -44,7 +44,7 @@ public abstract class AbstractJsonParser implements JsonParser { protected final T trimParse(String json, String prefix, Function parser) { - String trimmed = (json != null ? json.trim() : ""); + String trimmed = (json != null) ? json.trim() : ""; if (trimmed.startsWith(prefix)) { return parser.apply(trimmed); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java index 7903d91706..c0fa1768e0 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/jta/atomikos/AtomikosDependsOnBeanFactoryPostProcessor.java @@ -99,7 +99,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-project/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java index 422baab6ac..decfa56b29 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/AbstractLoggingSystem.java @@ -186,7 +186,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-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java index 5e9bbe26b0..73df6b6012 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggerConfiguration.java +++ b/spring-boot-project/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-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java index 69bedccc46..b7c5e4352f 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/LoggingSystem.java @@ -146,7 +146,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-project/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java index 28fae9b136..91752494fe 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/java/SimpleFormatter.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,7 +65,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-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java index 6bb5d71643..35c591cc91 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/log4j2/ColorConverter.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. @@ -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-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java index 31fc33ec8a..be7ebb2f80 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/ColorConverter.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. @@ -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-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index 2c333c132a..edb78c4142 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -160,7 +160,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-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginLookup.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginLookup.java index 95fff46bd1..07d4e03f10 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginLookup.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginLookup.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. @@ -20,7 +20,7 @@ package org.springframework.boot.origin; * An interface that may be implemented by an object that can lookup {@link Origin} * information from a given key. Can be used to add origin support to existing classes. * - * @param The lookup key type + * @param the lookup key type * @author Phillip Webb * @since 2.0.0 */ diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java index 60f1cc71ee..2270692595 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java @@ -52,8 +52,11 @@ public class OriginTrackedValue implements OriginProvider { } @Override - public String toString() { - return (this.value != null ? this.value.toString() : null); + public boolean equals(Object obj) { + if (obj == null || obj.getClass() != getClass()) { + return false; + } + return ObjectUtils.nullSafeEquals(this.value, ((OriginTrackedValue) obj).value); } @Override @@ -62,11 +65,8 @@ public class OriginTrackedValue implements OriginProvider { } @Override - public boolean equals(Object obj) { - if (obj == null || obj.getClass() != getClass()) { - return false; - } - return ObjectUtils.nullSafeEquals(this.value, ((OriginTrackedValue) obj).value); + public String toString() { + return (this.value != null) ? this.value.toString() : null; } public static OriginTrackedValue of(Object value) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/PropertySourceOrigin.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/PropertySourceOrigin.java index f40ced0215..d86e0dd8ce 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/PropertySourceOrigin.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/PropertySourceOrigin.java @@ -76,7 +76,7 @@ public class PropertySourceOrigin implements Origin { */ public static Origin get(PropertySource propertySource, String name) { Origin origin = OriginLookup.getOrigin(propertySource, name); - return (origin != null ? origin : new PropertySourceOrigin(propertySource, name)); + return (origin != null) ? origin : new PropertySourceOrigin(propertySource, name); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/SystemEnvironmentOrigin.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/SystemEnvironmentOrigin.java index f939ad1821..77688fc68e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/SystemEnvironmentOrigin.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/SystemEnvironmentOrigin.java @@ -40,16 +40,6 @@ public class SystemEnvironmentOrigin implements Origin { return this.property; } - @Override - public String toString() { - return "System Environment Property \"" + this.property + "\""; - } - - @Override - public int hashCode() { - return ObjectUtils.nullSafeHashCode(this.property); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -62,4 +52,14 @@ public class SystemEnvironmentOrigin implements Origin { return ObjectUtils.nullSafeEquals(this.property, other.property); } + @Override + public int hashCode() { + return ObjectUtils.nullSafeHashCode(this.property); + } + + @Override + public String toString() { + return "System Environment Property \"" + this.property + "\""; + } + } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java index 0a2e189eb8..d8c965f971 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java @@ -54,14 +54,6 @@ public class TextResourceOrigin implements Origin { return this.location; } - @Override - public int hashCode() { - int result = 1; - result = 31 * result + ObjectUtils.nullSafeHashCode(this.resource); - result = 31 * result + ObjectUtils.nullSafeHashCode(this.location); - return result; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -80,10 +72,18 @@ public class TextResourceOrigin implements Origin { return super.equals(obj); } + @Override + public int hashCode() { + int result = 1; + result = 31 * result + ObjectUtils.nullSafeHashCode(this.resource); + result = 31 * result + ObjectUtils.nullSafeHashCode(this.location); + return result; + } + @Override public String toString() { StringBuilder result = new StringBuilder(); - result.append(this.resource != null ? this.resource.getDescription() + result.append((this.resource != null) ? this.resource.getDescription() : "unknown resource [?]"); if (this.location != null) { result.append(":").append(this.location); @@ -126,11 +126,6 @@ public class TextResourceOrigin implements Origin { return this.column; } - @Override - public int hashCode() { - return (31 * this.line) + this.column; - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -146,6 +141,11 @@ public class TextResourceOrigin implements Origin { return result; } + @Override + public int hashCode() { + return (31 * this.line) + this.column; + } + @Override public String toString() { return (this.line + 1) + ":" + (this.column + 1); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java index 09a0d58957..e4fbf821ec 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/orm/jpa/EntityManagerFactoryBuilder.java @@ -61,7 +61,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) */ @@ -74,7 +74,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-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java index 6f58df0332..cdf0854aeb 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/reactive/ApplicationContextServerWebExchangeMatcher.java @@ -32,7 +32,7 @@ import org.springframework.web.server.ServerWebExchange; * {@link AutowireCapableBeanFactory#createBean(Class, int, boolean) create a new bean} * that is autowired in the usual way. * - * @param The type of the context that the match method actually needs to use. Can be + * @param the type of the context that the match method actually needs to use. Can be * an {@link ApplicationContext} or a class of an {@link ApplicationContext#getBean(Class) * existing bean}. * @author Madhura Bhave diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/servlet/ApplicationContextRequestMatcher.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/servlet/ApplicationContextRequestMatcher.java index 11d29b1d25..21fbb64e95 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/servlet/ApplicationContextRequestMatcher.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/security/servlet/ApplicationContextRequestMatcher.java @@ -33,7 +33,7 @@ import org.springframework.web.context.support.WebApplicationContextUtils; * {@link AutowireCapableBeanFactory#createBean(Class, int, boolean) create a new bean} * that is autowired in the usual way. * - * @param The type of the context that the match method actually needs to use. Can be + * @param the type of the context that the match method actually needs to use. Can be * an {@link ApplicationContext} or a class of an {@link ApplicationContext#getBean(Class) * existing bean}. * @author Phillip Webb diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java index 241cf6d0b0..95848c3813 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationHome.java @@ -57,7 +57,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); } @@ -88,11 +88,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(); } @@ -136,7 +136,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-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java index 048ecc1512..cd07e1eacb 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/ApplicationPid.java @@ -60,16 +60,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) { @@ -81,6 +71,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-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java index 3ae58829cc..52c97e6b16 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/system/SystemProperties.java @@ -31,7 +31,7 @@ public 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-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java index 81945422ec..d8476c2f9b 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/util/LambdaSafe.java @@ -49,9 +49,9 @@ public final class LambdaSafe { static { CLASS_GET_MODULE = ReflectionUtils.findMethod(Class.class, "getModule"); - MODULE_GET_NAME = (CLASS_GET_MODULE != null + MODULE_GET_NAME = (CLASS_GET_MODULE != null) ? ReflectionUtils.findMethod(CLASS_GET_MODULE.getReturnType(), "getName") - : null); + : null; } private LambdaSafe() { @@ -206,10 +206,10 @@ public final class LambdaSafe { if (this.logger.isDebugEnabled()) { Class expectedType = ResolvableType.forClass(this.callbackType) .resolveGeneric(); - String message = "Non-matching " + (expectedType != null - ? ClassUtils.getShortName(expectedType) + " type" : "type") - + " for callback " + ClassUtils.getShortName(this.callbackType) - + ": " + callback; + String expectedTypeName = (expectedType != null) + ? ClassUtils.getShortName(expectedType) + " type" : "type"; + String message = "Non-matching " + expectedTypeName + " for callback " + + ClassUtils.getShortName(this.callbackType) + ": " + callback; this.logger.debug(message, ex); } } @@ -368,7 +368,7 @@ public final class LambdaSafe { * the callback wasn't suitable. Similar in design to {@link Optional} but allows for * {@code null} as a valid value. * - * @param The result type + * @param the result type */ public static final class InvocationResult { @@ -404,7 +404,7 @@ public final class LambdaSafe { * @return the result of the invocation or the fallback */ public R get(R fallback) { - return (this != NONE ? this.value : fallback); + return (this != NONE) ? this.value : fallback; } /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java index 8a4d2eb6cc..631dd5c072 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/client/RestTemplateBuilder.java @@ -581,7 +581,7 @@ public class RestTemplateBuilder { } private Set append(Set set, Collection additions) { - Set result = new LinkedHashSet<>(set != null ? set : Collections.emptySet()); + Set result = new LinkedHashSet<>((set != null) ? set : Collections.emptySet()); result.addAll(additions); return Collections.unmodifiableSet(result); } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyReactiveWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyReactiveWebServerFactory.java index 22c6446d0c..ea62d5cafa 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyReactiveWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyReactiveWebServerFactory.java @@ -135,7 +135,7 @@ public class JettyReactiveWebServerFactory extends AbstractReactiveWebServerFact } protected Server createJettyServer(JettyHttpHandlerAdapter servlet) { - int port = (getPort() >= 0 ? getPort() : 0); + int port = (getPort() >= 0) ? getPort() : 0; InetSocketAddress address = new InetSocketAddress(getAddress(), port); Server server = new Server(getThreadPool()); server.addConnector(createConnector(address, server)); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java index 6e1730d147..f75501317d 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactory.java @@ -135,7 +135,7 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor @Override public WebServer getWebServer(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); @@ -253,19 +253,19 @@ public class JettyServletWebServerFactory extends AbstractServletWebServerFactor 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(); - File docBase = (root != null ? root : createTempDir("jetty-docbase")); + File docBase = (root != null) ? root : createTempDir("jetty-docbase"); try { List resources = new ArrayList<>(); Resource rootResource = (docBase.isDirectory() ? Resource.newResource(docBase.getCanonicalFile()) : JarResource.newJarResource(Resource.newResource(docBase))); - resources.add( - root != null ? new LoaderHidingResource(rootResource) : rootResource); + resources.add((root != null) ? new LoaderHidingResource(rootResource) + : rootResource); for (URL resourceJarUrl : this.getUrlsOfJarsWithMetaInfResources()) { Resource resource = createResource(resourceJarUrl); if (resource.exists() && resource.isDirectory()) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java index e4dfe79798..a6ac57881c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/JettyWebServer.java @@ -172,7 +172,7 @@ public class JettyWebServer implements WebServer { 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-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java index e3b800b539..d7d29a9234 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java @@ -94,8 +94,8 @@ public class SslServerCustomizer implements NettyServerCustomizer { KeyStore keyStore = getKeyStore(ssl, sslStoreProvider); KeyManagerFactory keyManagerFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); - 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(); } @@ -141,13 +141,13 @@ public class SslServerCustomizer implements NettyServerCustomizer { 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; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java index 85827cad09..e9fd3f02e2 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedWebappClassLoader.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatEmbeddedWebappClassLoader.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,7 +65,7 @@ public class TomcatEmbeddedWebappClassLoader extends ParallelWebappClassLoader { throws ClassNotFoundException { synchronized (getClassLoadingLock(name)) { Class result = findExistingLoadedClass(name); - result = (result != null ? result : doLoadClass(name)); + result = (result != null) ? result : doLoadClass(name); if (result == null) { throw new ClassNotFoundException(name); } @@ -75,7 +75,7 @@ public class TomcatEmbeddedWebappClassLoader extends ParallelWebappClassLoader { private Class findExistingLoadedClass(String name) { Class resultClass = findLoadedClass0(name); - resultClass = (resultClass != null ? resultClass : findLoadedClass(name)); + resultClass = (resultClass != null) ? resultClass : findLoadedClass(name); return resultClass; } @@ -83,10 +83,10 @@ public class TomcatEmbeddedWebappClassLoader extends ParallelWebappClassLoader { 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-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactory.java index 51f29dc3e2..b76f1f37bd 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatReactiveWebServerFactory.java @@ -98,8 +98,8 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac @Override public WebServer getWebServer(HttpHandler httpHandler) { 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); @@ -154,7 +154,7 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac } 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-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java index d69fbab7cc..646b756f8a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactory.java @@ -158,8 +158,8 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto @Override public WebServer getWebServer(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); @@ -190,12 +190,12 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto context.setName(getContextPath()); context.setDisplayName(getDisplayName()); context.setPath(getContextPath()); - File docBase = (documentRoot != null ? documentRoot - : createTempDir("tomcat-docbase")); + File docBase = (documentRoot != null) ? documentRoot + : createTempDir("tomcat-docbase"); 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); @@ -283,7 +283,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto // 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-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java index e3e824d109..c95ab77010 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/tomcat/TomcatWebServer.java @@ -319,7 +319,7 @@ public class TomcatWebServer implements WebServer { 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-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java index eb0cbdbdad..64d314bf85 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java @@ -114,8 +114,8 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer { KeyStore keyStore = getKeyStore(ssl, sslStoreProvider); KeyManagerFactory keyManagerFactory = KeyManagerFactory .getInstance(KeyManagerFactory.getDefaultAlgorithm()); - 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(); } @@ -175,13 +175,13 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer { 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; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java index 80f0763d84..8f9302561c 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java @@ -149,8 +149,8 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF try { createAccessLogDirectoryIfNecessary(); XnioWorker worker = createWorker(); - String prefix = (this.accessLogPrefix != null ? this.accessLogPrefix - : "access_log."); + String prefix = (this.accessLogPrefix != null) ? this.accessLogPrefix + : "access_log."; DefaultAccessLogReceiver accessLogReceiver = new DefaultAccessLogReceiver( worker, this.accessLogDirectory, prefix, this.accessLogSuffix, this.accessLogRotate); diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java index 6aaffccf10..53a3f97833 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServer.java @@ -256,7 +256,7 @@ public class UndertowServletWebServer implements WebServer { SocketAddress socketAddress = channel.getLocalAddress(); if (socketAddress instanceof InetSocketAddress) { String protocol = (ReflectionUtils.findField(channel.getClass(), - "ssl") != null ? "https" : "http"); + "ssl") != null) ? "https" : "http"; return new Port(((InetSocketAddress) socketAddress).getPort(), protocol); } return null; @@ -340,16 +340,6 @@ public class UndertowServletWebServer implements WebServer { 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) { @@ -368,6 +358,16 @@ public class UndertowServletWebServer implements WebServer { return true; } + @Override + public int hashCode() { + return this.number; + } + + @Override + public String toString() { + return this.number + " (" + this.protocol + ")"; + } + } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java index 53420263be..25d97d5e60 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactory.java @@ -299,8 +299,8 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac try { createAccessLogDirectoryIfNecessary(); XnioWorker worker = createWorker(); - String prefix = (this.accessLogPrefix != null ? this.accessLogPrefix - : "access_log."); + String prefix = (this.accessLogPrefix != null) ? this.accessLogPrefix + : "access_log."; DefaultAccessLogReceiver accessLogReceiver = new DefaultAccessLogReceiver( worker, this.accessLogDirectory, prefix, this.accessLogSuffix, this.accessLogRotate); @@ -399,7 +399,7 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac private File getCanonicalDocumentRoot(File docBase) { try { - File root = (docBase != null ? docBase : createTempDir("undertow-docbase")); + File root = (docBase != null) ? docBase : createTempDir("undertow-docbase"); return root.getCanonicalFile(); } catch (IOException ex) { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java index c5f20ed30e..4f56d7847e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowWebServer.java @@ -185,7 +185,7 @@ public class UndertowWebServer implements WebServer { SocketAddress socketAddress = channel.getLocalAddress(); if (socketAddress instanceof InetSocketAddress) { Field sslField = ReflectionUtils.findField(channel.getClass(), "ssl"); - String protocol = (sslField != null ? "https" : "http"); + String protocol = (sslField != null) ? "https" : "http"; return new UndertowWebServer.Port( ((InetSocketAddress) socketAddress).getPort(), protocol); } @@ -268,16 +268,6 @@ public class UndertowWebServer implements WebServer { 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) { @@ -296,6 +286,16 @@ public class UndertowWebServer implements WebServer { return true; } + @Override + public int hashCode() { + return this.number; + } + + @Override + public String toString() { + return this.number + " (" + this.protocol + ")"; + } + } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java index b33934ca29..577586d06e 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/error/DefaultErrorAttributes.java @@ -106,7 +106,7 @@ public class DefaultErrorAttributes implements ErrorAttributes { private Throwable determineException(Throwable error) { if (error instanceof ResponseStatusException) { - return (error.getCause() != null ? error.getCause() : error); + return (error.getCause() != null) ? error.getCause() : error; } return error; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java index 05e1feb35d..ac8f455f27 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/reactive/result/view/MustacheView.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. @@ -115,7 +115,7 @@ public class MustacheView extends AbstractUrlBasedView { } private Optional getCharset(MediaType mediaType) { - return Optional.ofNullable(mediaType != null ? mediaType.getCharset() : null); + return Optional.ofNullable((mediaType != null) ? mediaType.getCharset() : null); } } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/AbstractConfigurableWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/AbstractConfigurableWebServerFactory.java index 2b5a32a54d..5e4392e9d3 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/AbstractConfigurableWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/AbstractConfigurableWebServerFactory.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. @@ -166,7 +166,7 @@ public abstract class AbstractConfigurableWebServerFactory /** * Return the absolute temp dir for given web server. * @param prefix server name - * @return The temp dir for given server. + * @return the temp dir for given server. */ protected final File createTempDir(String prefix) { try { diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java index 9096fd36b9..a6ca4a6c29 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.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. @@ -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-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java index cf6a778b38..da21639313 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/MimeMappings.java @@ -279,7 +279,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; } /** @@ -289,7 +289,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; } /** @@ -299,12 +299,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 @@ -322,6 +317,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. @@ -356,11 +356,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) { @@ -377,6 +372,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-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerFactoryCustomizer.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerFactoryCustomizer.java index bcdc81b446..2be966ce86 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/WebServerFactoryCustomizer.java @@ -29,7 +29,7 @@ import org.springframework.beans.factory.config.BeanPostProcessor; * It might be safer to lookup dependencies lazily in the enclosing BeanFactory rather * than injecting them with {@code @Autowired}. * - * @param The configurable web server factory + * @param the configurable web server factory * @author Phillip Webb * @author Dave Syer * @author Brian Clozel diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/DynamicRegistrationBean.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/DynamicRegistrationBean.java index af5d4e4632..7d67220035 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/DynamicRegistrationBean.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/DynamicRegistrationBean.java @@ -33,7 +33,7 @@ import org.springframework.util.StringUtils; * Base class for Servlet 3.0+ {@link javax.servlet.Registration.Dynamic dynamic} based * registration beans. * - * @param The dynamic registration result + * @param the dynamic registration result * @author Phillip Webb * @since 2.0.0 */ @@ -132,7 +132,7 @@ public abstract class DynamicRegistrationBean * @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-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java index ef032ed2ac..a08fc0bac4 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/ServletContextInitializerBeans.java @@ -282,7 +282,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-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/WebApplicationContextServletContextAwareProcessor.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/WebApplicationContextServletContextAwareProcessor.java index 2acc7be9bb..e09411e1b6 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/WebApplicationContextServletContextAwareProcessor.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/context/WebApplicationContextServletContextAwareProcessor.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,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-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/DocumentRoot.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/DocumentRoot.java index f79dc58dee..bb2e6c2e1a 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/DocumentRoot.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/server/DocumentRoot.java @@ -60,9 +60,9 @@ class DocumentRoot { */ public final File getValidDirectory() { File file = this.directory; - file = (file != null ? file : getWarFileDocumentRoot()); - file = (file != null ? file : getExplodedWarFileDocumentRoot()); - file = (file != null ? file : getCommonDocumentRoot()); + file = (file != null) ? file : getWarFileDocumentRoot(); + file = (file != null) ? file : getExplodedWarFileDocumentRoot(); + file = (file != null) ? file : getCommonDocumentRoot(); if (file == null && this.logger.isDebugEnabled()) { logNoDocumentRoots(); } @@ -98,7 +98,7 @@ class DocumentRoot { File getCodeSourceArchive(CodeSource codeSource) { try { - URL location = (codeSource != null ? codeSource.getLocation() : null); + URL location = (codeSource != null) ? codeSource.getLocation() : null; if (location == null) { return null; } diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java index 4792a045f6..3dc89a6373 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/support/ErrorPageFilter.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/servlet/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-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java index 0d575bc765..0c7bbb1a1f 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java @@ -1509,7 +1509,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-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java index 6799bc51da..61b77d7353 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java @@ -487,7 +487,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-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/AliasedConfigurationPropertySourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/AliasedConfigurationPropertySourceTests.java index 2a52bfbe83..ca9e4e34e5 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/AliasedConfigurationPropertySourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/AliasedConfigurationPropertySourceTests.java @@ -114,7 +114,7 @@ public class AliasedConfigurationPropertySourceTests { private Object getValue(ConfigurationPropertySource source, String name) { ConfigurationProperty property = source .getConfigurationProperty(ConfigurationPropertyName.of(name)); - return (property != null ? property.getValue() : null); + return (property != null) ? property.getValue() : null; } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java index 46c0cc377a..7f171f5f7b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/source/MapConfigurationPropertySourceTests.java @@ -112,7 +112,7 @@ public class MapConfigurationPropertySourceTests { private Object getValue(ConfigurationPropertySource source, String name) { ConfigurationProperty property = source .getConfigurationProperty(ConfigurationPropertyName.of(name)); - return (property != null ? property.getValue() : null); + return (property != null) ? property.getValue() : null; } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzerTests.java index a022935095..d7927ffd07 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindFailureAnalyzerTests.java @@ -120,8 +120,8 @@ public class BindFailureAnalyzerTests { Map map = new HashMap<>(); for (String pair : environment) { int index = pair.indexOf("="); - String key = (index > 0 ? pair.substring(0, index) : pair); - String value = (index > 0 ? pair.substring(index + 1) : ""); + String key = (index > 0) ? pair.substring(0, index) : pair; + String value = (index > 0) ? pair.substring(index + 1) : ""; map.put(key.trim(), value.trim()); } sources.addFirst(new MapPropertySource("test", map)); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzerTests.java index a79f5e7b0e..e7cf6b4f32 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BindValidationFailureAnalyzerTests.java @@ -135,8 +135,8 @@ public class BindValidationFailureAnalyzerTests { Map map = new HashMap<>(); for (String pair : environment) { int index = pair.indexOf("="); - String key = (index > 0 ? pair.substring(0, index) : pair); - String value = (index > 0 ? pair.substring(index + 1) : ""); + String key = (index > 0) ? pair.substring(0, index) : pair; + String value = (index > 0) ? pair.substring(index + 1) : ""; map.put(key.trim(), value.trim()); } sources.addFirst(new MapPropertySource("test", map)); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/UnboundConfigurationPropertyFailureAnalyzerTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/UnboundConfigurationPropertyFailureAnalyzerTests.java index 1ad6e29343..69029d2afb 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/UnboundConfigurationPropertyFailureAnalyzerTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/UnboundConfigurationPropertyFailureAnalyzerTests.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,8 +98,8 @@ public class UnboundConfigurationPropertyFailureAnalyzerTests { Map map = new HashMap<>(); for (String pair : environment) { int index = pair.indexOf("="); - String key = (index > 0 ? pair.substring(0, index) : pair); - String value = (index > 0 ? pair.substring(index + 1) : ""); + String key = (index > 0) ? pair.substring(0, index) : pair; + String value = (index > 0) ? pair.substring(index + 1) : ""; map.put(key.trim(), value.trim()); } sources.addFirst(new MapPropertySource("test", map)); diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java index 5e0e2e5beb..74dadf8761 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/env/OriginTrackedPropertiesLoaderTests.java @@ -255,7 +255,7 @@ public class OriginTrackedPropertiesLoaderTests { } private Object getValue(OriginTrackedValue value) { - return (value != null ? value.getValue() : null); + return (value != null) ? value.getValue() : null; } private String getLocation(OriginTrackedValue value) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java index e628d60c2f..d5b93e57a7 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/origin/MockOrigin.java @@ -32,11 +32,6 @@ public final class MockOrigin implements Origin { this.value = value; } - @Override - public int hashCode() { - return this.value.hashCode(); - } - @Override public boolean equals(Object obj) { if (this == obj) { @@ -48,13 +43,18 @@ public final class MockOrigin implements Origin { return this.value.equals(((MockOrigin) obj).value); } + @Override + public int hashCode() { + return this.value.hashCode(); + } + @Override public String toString() { return this.value; } public static Origin of(String value) { - return (value != null ? new MockOrigin(value) : null); + return (value != null) ? new MockOrigin(value) : null; } } diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java index 69bb99fc6e..fc8f04f60b 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/JettyServletWebServerFactoryTests.java @@ -362,7 +362,7 @@ public class JettyServletWebServerFactoryTests WebAppContext context = (WebAppContext) ((JettyWebServer) this.webServer) .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-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java index c4a5d92627..21aab60678 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java @@ -455,7 +455,7 @@ public class TomcatServletWebServerFactoryTests .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(TomcatServletWebServerFactory factory, int expected) { diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java index 6a8fdd357f..6f10cc9118 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java @@ -291,7 +291,7 @@ public class UndertowServletWebServerFactoryTests DeploymentInfo info = ((DeploymentManager) ReflectionTestUtils .getField(this.webServer, "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 diff --git a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java index 0afb90d27f..f7aff7a4d6 100644 --- a/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/MockServletWebServerFactory.java @@ -50,17 +50,17 @@ public class MockServletWebServerFactory extends AbstractServletWebServerFactory } public ServletContext getServletContext() { - return (getWebServer() != null ? getWebServer().getServletContext() : null); + return (getWebServer() != null) ? getWebServer().getServletContext() : null; } public RegisteredServlet getRegisteredServlet(int index) { - return (getWebServer() != null ? getWebServer().getRegisteredServlet(index) - : null); + return (getWebServer() != null) ? getWebServer().getRegisteredServlet(index) + : null; } public RegisteredFilter getRegisteredFilter(int index) { - return (getWebServer() != null ? getWebServer().getRegisteredFilters(index) - : null); + return (getWebServer() != null) ? getWebServer().getRegisteredFilters(index) + : null; } public static class MockServletWebServer diff --git a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java index 0d7274bc24..2fc61a0e1f 100644 --- a/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java +++ b/spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/AbstractApplicationLauncher.java @@ -70,9 +70,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<>();