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/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/PropertiesMeterFilter.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/metrics/PropertiesMeterFilter.java index 7edd6caa97..757fd2b7e9 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 @@ -67,10 +67,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) { @@ -84,7 +84,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..7e6a0c4a1b 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 @@ -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/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..c8edb8eca2 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 @@ -86,7 +86,7 @@ public class AuditEvent implements Serializable { 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/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/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 36879f0692..9648e7d808 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 @@ -57,8 +57,8 @@ public class CompositeReactiveHealthIndicator implements ReactiveHealthIndicator Assert.notNull(indicators, "Indicators must not be null"); this.indicators = new LinkedHashMap<>(indicators); 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; } /** @@ -85,8 +85,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/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/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, @@ -273,7 +273,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/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 8475293207..1afd2ee46c 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 @@ -110,8 +110,8 @@ public abstract class AbstractRabbitListenerContainerFactoryConfigurer> 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..736b6fac37 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 @@ -61,7 +61,7 @@ public final class ConditionMessage { @Override public String toString() { - return (this.message != null ? this.message : ""); + return (this.message != null) ? this.message : ""; } @Override @@ -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..03b0834b69 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. @@ -146,7 +146,7 @@ public class ConditionOutcome { @Override public String toString() { - return (this.message != null ? this.message.toString() : ""); + return (this.message != null) ? this.message.toString() : ""; } /** diff --git a/spring-boot-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/CouchbaseAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java index 45107c1ac7..545039a669 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/couchbase/CouchbaseAutoConfiguration.java @@ -158,7 +158,7 @@ public class CouchbaseAutoConfiguration { return factory.apply(service.getMinEndpoints(), service.getMaxEndpoints()); } - int endpoints = (fallback != null ? fallback : 1); + int endpoints = (fallback != null) ? fallback : 1; return factory.apply(endpoints, endpoints); } 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 62c0b5c605..456f0e2f6e 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 @@ -227,8 +227,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 83aa6e9866..0d08f1ee1a 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); } @@ -201,8 +200,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() { @@ -262,8 +261,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 6d1bea6aa8..2c4b05a047 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 @@ -160,7 +160,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 be584dc575..e3a0ecb9d5 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 @@ -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. @@ -126,9 +126,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 554010b7a5..f80689244f 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 @@ -170,7 +170,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 2702081611..d39c023807 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 @@ -131,13 +131,12 @@ public class EmbeddedMongoAutoConfiguration { this.embeddedProperties.getFeatures()); MongodConfigBuilder builder = new MongodConfigBuilder() .version(featureAwareVersion); - if (this.embeddedProperties.getStorage() != null) { - builder.replication( - new Storage(this.embeddedProperties.getStorage().getDatabaseDir(), - this.embeddedProperties.getStorage().getReplSetName(), - this.embeddedProperties.getStorage().getOplogSize() != null - ? this.embeddedProperties.getStorage().getOplogSize() - : 0)); + 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) { @@ -257,7 +256,7 @@ public class EmbeddedMongoAutoConfiguration { Set features) { Assert.notNull(version, "version must not be null"); this.version = version; - this.features = (features != null ? features : Collections.emptySet()); + this.features = (features != null) ? features : Collections.emptySet(); } @Override 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 b880a816a2..6fe81d5060 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 @@ -83,8 +83,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 8b21be88db..ff710111ea 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 @@ -50,7 +50,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/orm/jpa/JpaProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java index 3587f9b055..d93a1eca4e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/orm/jpa/JpaProperties.java @@ -244,7 +244,7 @@ public class JpaProperties { if (ddlAuto != null) { return ddlAuto; } - return (this.ddlAuto != null ? this.ddlAuto : defaultDdlAuto.get()); + return (this.ddlAuto != null) ? this.ddlAuto : defaultDdlAuto.get(); } } 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 3e9d06f180..59de80ab1d 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 @@ -147,7 +147,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 fea068fcf9..056c1a0336 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 @@ -71,15 +71,15 @@ 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)); } @@ -88,7 +88,7 @@ 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/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 30f0aff919..a6546d8ed2 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 b1e2c0272b..c9765c4747 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 b970716163..2b64db4cff 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 7f282437a6..e4612f72ab 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 @@ -91,7 +91,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 25431fd514..ee7e7a2cd9 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 @@ -316,11 +316,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/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/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/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/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/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/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/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/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/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/properties/AnnotationsPropertySource.java b/spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/properties/AnnotationsPropertySource.java index 81f45d838b..3ea3c774ec 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()); } 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..36d2db0978 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 @@ -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/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/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..fa78ed9108 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 @@ -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, diff --git a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java index 54f07aaa49..954a626b07 100644 --- a/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java +++ b/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/context/SpringBootConfigurationFinder.java @@ -79,7 +79,7 @@ final class SpringBootConfigurationFinder { private String getParentPackage(String sourcePackage) { int lastDot = sourcePackage.lastIndexOf('.'); - return (lastDot != -1 ? sourcePackage.substring(0, lastDot) : ""); + return (lastDot != -1) ? sourcePackage.substring(0, lastDot) : ""; } /** diff --git a/spring-boot-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 3ee521bed7..a80d533789 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..f1fc790205 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 @@ -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/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/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 map = getOrAdd(sources, name); for (String pair : pairs) { int index = getSeparatorIndex(pair); - 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()); } } 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-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/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..64d509e22b 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. @@ -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..b1da40a98c 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(); } @@ -196,7 +196,7 @@ public final class ItemMetadata implements Comparable { } private int nullSafeHashCode(Object o) { - return (o != null ? o.hashCode() : 0); + return (o != null) ? o.hashCode() : 0; } @Override diff --git a/spring-boot-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/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 e63e83dd25..46d68c8a6c 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 e6be12492f..f884e41e6a 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 ea4b10259e..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 @@ -283,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-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..767bdc0607 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 @@ -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..85d9f122f3 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()) { 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..9b3fd7aeca 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 @@ -141,7 +141,7 @@ final class AsciiBytes { 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; @@ -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/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..67beac47b8 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) { 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 b46b0ef344..feae5487c0 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 @@ -332,7 +332,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())); } getLog().debug("Classpath for forked process: " + classpath); @@ -450,7 +450,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); } @@ -480,7 +480,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 f0cb6c65b3..997236b53d 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 @@ -226,7 +226,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; } @@ -287,7 +287,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/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 b6cfabb6ac..add3f25064 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 @@ -556,8 +556,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) { @@ -1307,7 +1307,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/SpringApplicationBuilder.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/builder/SpringApplicationBuilder.java index add5881052..151e6e2fde 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 @@ -397,8 +397,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; @@ -409,7 +409,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 5a7afea4aa..c1ae0f2716 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 @@ -223,7 +223,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 a290eb874c..15af937b0b 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 @@ -316,8 +316,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()); } @@ -590,8 +590,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) { @@ -667,7 +667,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); 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/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..0bb018fcba 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 @@ -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,7 +121,7 @@ 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); } /** 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..667d2fdd46 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 @@ -110,7 +110,7 @@ public final class Bindable { public String toString() { ToStringCreator creator = new ToStringCreator(this); creator.append("type", this.type); - creator.append("value", (this.value != null ? "provided" : "none")); + creator.append("value", (this.value != null) ? "provided" : "none"); creator.append("annotations", this.annotations); return creator.toString(); } @@ -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); } 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 f0d34b345e..b458beef5b 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 @@ -133,10 +133,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; } @@ -205,7 +205,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 8c2d283e60..641574493e 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..b37fadb050 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 @@ -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 724ad529fe..807a9b4b14 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 @@ -55,8 +55,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); @@ -216,7 +216,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/ConfigurationPropertyName.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/context/properties/source/ConfigurationPropertyName.java index c5cb44b45f..0be25c053d 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; @@ -316,7 +316,7 @@ public final class ConfigurationPropertyName else { for (int i = 0; i < element.length(); i++) { char ch = Character.toLowerCase(element.charAt(i)); - result.append(ch != '_' ? ch : ""); + result.append((ch != '_') ? ch : ""); } } } @@ -346,7 +346,7 @@ public final class ConfigurationPropertyName 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)); + hash = (ch == '-' || ch == '_') ? hash : 31 * hash + Character.hashCode(ch); } return hash; } 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..0ccbb61d61 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; } 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..3c9765d6dd 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")); 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 b58b1aeee1..b1b7ecf74a 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 @@ -74,8 +74,8 @@ class InvalidConfigurationPropertyValueFailureAnalyzer } private Stream> getPropertySources() { - Iterable> sources = (this.environment != null - ? this.environment.getPropertySources() : Collections.emptyList()); + Iterable> sources = (this.environment != null) + ? this.environment.getPropertySources() : Collections.emptyList(); return StreamSupport.stream(sources.spliterator(), false) .filter((source) -> !ConfigurationPropertySources .isAttachedConfigurationPropertySource(source)); @@ -110,7 +110,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 afff3dc634..5c0fa9be9d 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 @@ -126,7 +126,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 1c868f4919..330cf29257 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/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/OriginTrackedValue.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/OriginTrackedValue.java index 60f1cc71ee..1a9bcc6fab 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 @@ -53,7 +53,7 @@ public class OriginTrackedValue implements OriginProvider { @Override public String toString() { - return (this.value != null ? this.value.toString() : null); + return (this.value != null) ? this.value.toString() : null; } @Override 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/TextResourceOrigin.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/origin/TextResourceOrigin.java index 0a2e189eb8..cd7fd5eb67 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 @@ -83,7 +83,7 @@ public class TextResourceOrigin implements Origin { @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); 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..fad8b0fea3 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 @@ -62,7 +62,7 @@ public class ApplicationPid { @Override public String toString() { - return (this.pid != null ? this.pid : "???"); + return (this.pid != null) ? this.pid : "???"; } @Override diff --git a/spring-boot-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..eb9357e832 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); } } @@ -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 58d464deb4..1626ddbcfb 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 @@ -605,13 +605,13 @@ public class RestTemplateBuilder { } private Set append(Set set, T addition) { - Set result = new LinkedHashSet<>(set != null ? set : Collections.emptySet()); + Set result = new LinkedHashSet<>((set != null) ? set : Collections.emptySet()); result.add(addition); return Collections.unmodifiableSet(result); } private Set append(Set set, Collection additions) { - Set result = new LinkedHashSet<>(set != null ? set : Collections.emptySet()); + Set 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 abe648b156..5695c61bbf 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 @@ -79,8 +79,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(); } @@ -126,13 +126,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..fdc2e33ba1 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; 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 f166463919..1097a98584 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..1a643dcd4c 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); } 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/ErrorPage.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/server/ErrorPage.java index 9096fd36b9..180fbcc400 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; } /** 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..f3fa83b026 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,7 +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); + return (previous != null) ? previous.getMimeType() : null; } @Override 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..b604311b2a 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 @@ -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 c3663de2ef..559dc9baa6 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 @@ -271,7 +271,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 7740fb0c33..96636bf6b2 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 @@ -1477,7 +1477,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 34428de8bf..228782a427 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 @@ -486,7 +486,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..b209eb9db0 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 @@ -54,7 +54,7 @@ public final class MockOrigin implements Origin { } 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 6ab1dfd773..4f23db2264 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 @@ -458,7 +458,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<>();