Polish ternary expressions

Consistently format ternary expressions and always favor `!=` as the
the check.
This commit is contained in:
Phillip Webb 2018-05-02 12:41:51 -07:00
parent 690f946b6d
commit 3ee777e142
199 changed files with 419 additions and 412 deletions

View File

@ -114,12 +114,12 @@ public class EndpointAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public HealthEndpoint healthEndpoint() {
return new HealthEndpoint(
this.healthAggregator == null ? new OrderedHealthAggregator()
: this.healthAggregator,
this.healthIndicators == null
? Collections.<String, HealthIndicator>emptyMap()
: this.healthIndicators);
HealthAggregator healthAggregator = (this.healthAggregator != null
? this.healthAggregator : new OrderedHealthAggregator());
Map<String, HealthIndicator> healthIndicators = (this.healthIndicators != null
? this.healthIndicators
: Collections.<String, HealthIndicator>emptyMap());
return new HealthEndpoint(healthAggregator, healthIndicators);
}
@Bean
@ -131,8 +131,8 @@ public class EndpointAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public InfoEndpoint infoEndpoint() throws Exception {
return new InfoEndpoint(this.infoContributors == null
? Collections.<InfoContributor>emptyList() : this.infoContributors);
return new InfoEndpoint(this.infoContributors != null ? this.infoContributors
: Collections.<InfoContributor>emptyList());
}
@Bean
@ -156,8 +156,8 @@ public class EndpointAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public TraceEndpoint traceEndpoint() {
return new TraceEndpoint(this.traceRepository == null
? new InMemoryTraceRepository() : this.traceRepository);
return new TraceEndpoint(this.traceRepository != null ? this.traceRepository
: new InMemoryTraceRepository());
}
@Bean

View File

@ -340,7 +340,7 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
private String getPath(ServletServerHttpRequest request) {
String path = (String) request.getServletRequest()
.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
return (path == null ? "" : path);
return (path != null ? path : "");
}
}
@ -355,8 +355,8 @@ public class EndpointWebMvcHypermediaManagementContextConfiguration {
@SuppressWarnings("unchecked")
EndpointResource(Object content, String path) {
this.content = content instanceof Map ? null : content;
this.embedded = (Map<String, Object>) (this.content == null ? content : null);
this.content = (content instanceof Map ? null : content);
this.embedded = (Map<String, Object>) (this.content != null ? null : content);
add(linkTo(Object.class).slash(path).withSelfRel());
}

View File

@ -89,9 +89,8 @@ public class EndpointWebMvcManagementContextConfiguration {
this.corsProperties = corsProperties;
List<EndpointHandlerMappingCustomizer> providedCustomizers = mappingCustomizers
.getIfAvailable();
this.mappingCustomizers = providedCustomizers == null
? Collections.<EndpointHandlerMappingCustomizer>emptyList()
: providedCustomizers;
this.mappingCustomizers = (providedCustomizers != null ? providedCustomizers
: Collections.<EndpointHandlerMappingCustomizer>emptyList());
}
@Bean

View File

@ -231,7 +231,7 @@ public class HealthIndicatorAutoConfiguration {
private String getValidationQuery(DataSource source) {
DataSourcePoolMetadata poolMetadata = this.poolMetadataProvider
.getDataSourcePoolMetadata(source);
return (poolMetadata == null ? null : poolMetadata.getValidationQuery());
return (poolMetadata != null ? poolMetadata.getValidationQuery() : null);
}
}

View File

@ -74,7 +74,7 @@ class LinksEnhancer {
private void addEndpointLink(ResourceSupport resource, MvcEndpoint endpoint,
String rel) {
Class<?> type = endpoint.getEndpointType();
type = (type == null ? Object.class : type);
type = (type != null ? type : Object.class);
if (StringUtils.hasText(rel)) {
String href = this.rootPath + endpoint.getPath();
resource.add(linkTo(type).slash(href).withRel(rel));

View File

@ -111,9 +111,9 @@ class ManagementContextConfigurationsImportSelector
private int readOrder(AnnotationMetadata annotationMetadata) {
Map<String, Object> attributes = annotationMetadata
.getAnnotationAttributes(Order.class.getName());
Integer order = (attributes == null ? null
: (Integer) attributes.get("value"));
return (order == null ? Ordered.LOWEST_PRECEDENCE : order);
Integer order = (attributes != null ? (Integer) attributes.get("value")
: null);
return (order != null ? order : Ordered.LOWEST_PRECEDENCE);
}
public String getClassName() {

View File

@ -95,8 +95,8 @@ public class MetricExportAutoConfiguration {
exporters.setReader(reader);
exporters.setWriters(writers);
}
exporters.setExporters(this.exporters == null
? Collections.<String, Exporter>emptyMap() : this.exporters);
exporters.setExporters(this.exporters != null ? this.exporters
: Collections.<String, Exporter>emptyMap());
return exporters;
}

View File

@ -89,9 +89,10 @@ public class PublicMetricsAutoConfiguration {
@Bean
public MetricReaderPublicMetrics metricReaderPublicMetrics() {
return new MetricReaderPublicMetrics(new CompositeMetricReader(
this.metricReaders == null ? new MetricReader[0] : this.metricReaders
.toArray(new MetricReader[this.metricReaders.size()])));
MetricReader[] readers = (this.metricReaders != null
? this.metricReaders.toArray(new MetricReader[this.metricReaders.size()])
: new MetricReader[0]);
return new MetricReaderPublicMetrics(new CompositeMetricReader(readers));
}
@Bean

View File

@ -56,7 +56,7 @@ public abstract class AbstractJmxCacheStatisticsProvider<C extends Cache>
public CacheStatistics getCacheStatistics(CacheManager cacheManager, C cache) {
try {
ObjectName objectName = internalGetObjectName(cache);
return (objectName == null ? null : getCacheStatistics(objectName));
return (objectName != null ? getCacheStatistics(objectName) : null);
}
catch (MalformedObjectNameException ex) {
throw new IllegalStateException(ex);

View File

@ -89,8 +89,8 @@ public class CloudFoundryActuatorAutoConfiguration {
String cloudControllerUrl = environment.getProperty("vcap.application.cf_api");
boolean skipSslValidation = cloudFoundryProperties
.getProperty("skip-ssl-validation", Boolean.class, false);
return cloudControllerUrl == null ? null : new CloudFoundrySecurityService(
restTemplateBuilder, cloudControllerUrl, skipSslValidation);
return (cloudControllerUrl != null ? new CloudFoundrySecurityService(
restTemplateBuilder, cloudControllerUrl, skipSslValidation) : null);
}
private CorsConfiguration getCorsConfiguration() {

View File

@ -137,8 +137,8 @@ public class AutoConfigurationReportEndpoint extends AbstractEndpoint<Report> {
public MessageAndConditions(ConditionAndOutcomes conditionAndOutcomes) {
for (ConditionAndOutcome conditionAndOutcome : conditionAndOutcomes) {
List<MessageAndCondition> target = conditionAndOutcome.getOutcome()
.isMatch() ? this.matched : this.notMatched;
List<MessageAndCondition> target = (conditionAndOutcome.getOutcome()
.isMatch() ? this.matched : this.notMatched);
target.add(new MessageAndCondition(conditionAndOutcome));
}
}

View File

@ -123,7 +123,7 @@ public class FlywayEndpoint extends AbstractEndpoint<List<FlywayReport>> {
}
private String nullSafeToString(Object obj) {
return (obj == null ? null : obj.toString());
return (obj != null ? obj.toString() : null);
}
public MigrationType getType() {

View File

@ -84,7 +84,7 @@ public class LoggersEndpoint extends AbstractEndpoint<Map<String, Object>> {
Assert.notNull(name, "Name must not be null");
LoggerConfiguration configuration = this.loggingSystem
.getLoggerConfiguration(name);
return (configuration == null ? null : new LoggerLevels(configuration));
return (configuration != null ? new LoggerLevels(configuration) : null);
}
public void setLogLevel(String name, LogLevel level) {
@ -107,7 +107,7 @@ public class LoggersEndpoint extends AbstractEndpoint<Map<String, Object>> {
}
private String getName(LogLevel level) {
return (level == null ? null : level.name());
return (level != null ? level.name() : null);
}
public String getConfiguredLevel() {

View File

@ -38,7 +38,7 @@ class DataConverter {
private final JavaType mapStringObject;
DataConverter(ObjectMapper objectMapper) {
this.objectMapper = (objectMapper == null ? new ObjectMapper() : objectMapper);
this.objectMapper = (objectMapper != null ? objectMapper : new ObjectMapper());
this.listObject = this.objectMapper.getTypeFactory()
.constructParametricType(List.class, Object.class);
this.mapStringObject = this.objectMapper.getTypeFactory()

View File

@ -115,7 +115,7 @@ public class EndpointMBeanExporter extends MBeanExporter
* @param objectMapper the object mapper
*/
public EndpointMBeanExporter(ObjectMapper objectMapper) {
this.objectMapper = (objectMapper == null ? new ObjectMapper() : objectMapper);
this.objectMapper = (objectMapper != null ? objectMapper : new ObjectMapper());
setAutodetect(false);
setNamingStrategy(this.defaultNamingStrategy);
setAssembler(this.assembler);

View File

@ -150,7 +150,7 @@ public abstract class AbstractEndpointHandlerMapping<E extends MvcEndpoint>
}
Assert.state(handler instanceof MvcEndpoint, "Only MvcEndpoints are supported");
String path = getPath((MvcEndpoint) handler);
return (path == null ? null : getEndpointPatterns(path, mapping));
return (path != null ? getEndpointPatterns(path, mapping) : null);
}
/**
@ -163,8 +163,8 @@ public abstract class AbstractEndpointHandlerMapping<E extends MvcEndpoint>
}
private String[] getEndpointPatterns(String path, RequestMappingInfo mapping) {
String patternPrefix = StringUtils.hasText(this.prefix) ? this.prefix + path
: path;
String patternPrefix = (StringUtils.hasText(this.prefix) ? this.prefix + path
: path);
Set<String> defaultPatterns = mapping.getPatternsCondition().getPatterns();
if (defaultPatterns.isEmpty()) {
return new String[] { patternPrefix, patternPrefix + ".json" };

View File

@ -58,7 +58,7 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter {
return getDisabledResponse();
}
LoggerLevels levels = this.delegate.invoke(name);
return (levels == null ? ResponseEntity.notFound().build() : levels);
return (levels != null ? levels : ResponseEntity.notFound().build());
}
@ActuatorPostMapping("/{name:.*}")
@ -79,8 +79,8 @@ public class LoggersMvcEndpoint extends EndpointMvcAdapter {
private LogLevel getLogLevel(Map<String, String> configuration) {
String level = configuration.get("configuredLevel");
try {
return (level == null ? null
: LogLevel.valueOf(level.toUpperCase(Locale.ENGLISH)));
return (level != null ? LogLevel.valueOf(level.toUpperCase(Locale.ENGLISH))
: null);
}
catch (IllegalArgumentException ex) {
throw new InvalidLogLevelException(level);

View File

@ -99,7 +99,7 @@ public class OrderedHealthAggregator extends AbstractHealthAggregator {
public int compare(Status s1, Status s2) {
int i1 = this.statusOrder.indexOf(s1.getCode());
int i2 = this.statusOrder.indexOf(s2.getCode());
return (i1 < i2 ? -1 : (i1 == i2 ? s1.getCode().compareTo(s2.getCode()) : 1));
return (i1 < i2 ? -1 : (i1 != i2 ? 1 : s1.getCode().compareTo(s2.getCode())));
}
}

View File

@ -42,9 +42,9 @@ public class SolrHealthIndicator extends AbstractHealthIndicator {
request.setAction(CoreAdminParams.CoreAdminAction.STATUS);
CoreAdminResponse response = request.process(this.solrClient);
int statusCode = response.getStatus();
Status status = (statusCode == 0 ? Status.UP : Status.DOWN);
Status status = (statusCode != 0 ? Status.DOWN : Status.UP);
builder.status(status).withDetail("solrStatus",
(statusCode == 0 ? "OK" : statusCode));
(statusCode != 0 ? statusCode : "OK"));
}
}

View File

@ -55,7 +55,7 @@ public class BufferMetricReader implements MetricReader, PrefixMetricReader {
if (buffer == null) {
buffer = this.gaugeBuffers.find(name);
}
return (buffer == null ? null : asMetric(name, buffer));
return (buffer != null ? asMetric(name, buffer) : null);
}
@Override

View File

@ -80,8 +80,8 @@ public class DropwizardMetricServices implements CounterService, GaugeService {
public DropwizardMetricServices(MetricRegistry registry,
ReservoirFactory reservoirFactory) {
this.registry = registry;
this.reservoirFactory = (reservoirFactory == null ? ReservoirFactory.NONE
: reservoirFactory);
this.reservoirFactory = (reservoirFactory != null ? reservoirFactory
: ReservoirFactory.NONE);
}
@Override

View File

@ -78,7 +78,7 @@ public class StatsdMetricWriter implements MetricWriter, Closeable {
}
private static String trimPrefix(String prefix) {
String trimmedPrefix = StringUtils.hasText(prefix) ? prefix : null;
String trimmedPrefix = (StringUtils.hasText(prefix) ? prefix : null);
while (trimmedPrefix != null && trimmedPrefix.endsWith(".")) {
trimmedPrefix = trimmedPrefix.substring(0, trimmedPrefix.length() - 1);
}

View File

@ -62,7 +62,7 @@ public final class MetricWriterMessageHandler implements MessageHandler {
else {
if (logger.isWarnEnabled()) {
logger.warn("Unsupported metric payload "
+ (payload == null ? "null" : payload.getClass().getName()));
+ (payload != null ? payload.getClass().getName() : "null"));
}
}
}

View File

@ -114,8 +114,8 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
finally {
addTimeTaken(trace, startTime);
addSessionIdIfNecessary(request, trace);
enhanceTrace(trace, status == response.getStatus() ? response
: new CustomStatusResponseWrapper(response, status));
enhanceTrace(trace, status != response.getStatus()
? new CustomStatusResponseWrapper(response, status) : response);
this.repository.add(trace);
}
}
@ -124,7 +124,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
Map<String, Object> trace) {
HttpSession session = request.getSession(false);
add(trace, Include.SESSION_ID, "sessionId",
(session == null ? null : session.getId()));
(session != null ? session.getId() : null));
}
protected Map<String, Object> getTrace(HttpServletRequest request) {
@ -144,7 +144,7 @@ public class WebRequestTraceFilter extends OncePerRequestFilter implements Order
request.getPathTranslated());
add(trace, Include.CONTEXT_PATH, "contextPath", request.getContextPath());
add(trace, Include.USER_PRINCIPAL, "userPrincipal",
(userPrincipal == null ? null : userPrincipal.getName()));
(userPrincipal != null ? userPrincipal.getName() : null));
if (isIncluded(Include.PARAMETERS)) {
trace.put("parameters", getParameterMapCopy(request));
}

View File

@ -128,8 +128,8 @@ public class EndpointMvcIntegrationTests {
@Bean
@ConditionalOnMissingBean
public HttpMessageConverters messageConverters() {
return new HttpMessageConverters(this.converters == null
? Collections.<HttpMessageConverter<?>>emptyList() : this.converters);
return new HttpMessageConverters(this.converters != null ? this.converters
: Collections.<HttpMessageConverter<?>>emptyList());
}
@Bean

View File

@ -298,7 +298,7 @@ public class ConfigurationPropertiesReportEndpointTests
}
public boolean isMixedBoolean() {
return (this.mixedBoolean == null ? false : this.mixedBoolean);
return (this.mixedBoolean != null ? this.mixedBoolean : false);
}
public void setMixedBoolean(Boolean mixedBoolean) {

View File

@ -86,7 +86,7 @@ public class HalBrowserMvcEndpointDisabledIntegrationTests {
if ("/actuator".equals(path) || endpoint instanceof HeapdumpMvcEndpoint) {
continue;
}
path = path.length() > 0 ? path : "/";
path = (path.length() > 0 ? path : "/");
MockHttpServletRequestBuilder requestBuilder = get(path);
if (endpoint instanceof AuditEventsMvcEndpoint) {
requestBuilder.param("after", "2016-01-01T12:00:00+00:00");

View File

@ -111,8 +111,8 @@ public class HalBrowserMvcEndpointManagementContextPathIntegrationTests {
if ("/actuator".equals(path)) {
continue;
}
path = path.startsWith("/") ? path.substring(1) : path;
path = path.length() > 0 ? path : "self";
path = (path.startsWith("/") ? path.substring(1) : path);
path = (path.length() > 0 ? path : "self");
this.mockMvc.perform(get("/admin").accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andExpect(jsonPath("$._links.%s.href", path)

View File

@ -69,8 +69,8 @@ public class BufferGaugeServiceSpeedTests {
private static int threadCount = 2;
private static final int number = Boolean.getBoolean("performance.test") ? 10000000
: 1000000;
private static final int number = (Boolean.getBoolean("performance.test") ? 10000000
: 1000000);
private static StopWatch watch = new StopWatch("count");

View File

@ -68,8 +68,8 @@ public class CounterServiceSpeedTests {
private static int threadCount = 2;
private static final int number = Boolean.getBoolean("performance.test") ? 10000000
: 1000000;
private static final int number = (Boolean.getBoolean("performance.test") ? 10000000
: 1000000);
private static StopWatch watch = new StopWatch("count");

View File

@ -67,8 +67,8 @@ public class DefaultCounterServiceSpeedTests {
private static int threadCount = 2;
private static final int number = Boolean.getBoolean("performance.test") ? 2000000
: 1000000;
private static final int number = (Boolean.getBoolean("performance.test") ? 2000000
: 1000000);
private static int count;

View File

@ -67,8 +67,8 @@ public class DefaultGaugeServiceSpeedTests {
private static int threadCount = 2;
private static final int number = Boolean.getBoolean("performance.test") ? 5000000
: 1000000;
private static final int number = (Boolean.getBoolean("performance.test") ? 5000000
: 1000000);
private static int count;

View File

@ -69,8 +69,8 @@ public class DropwizardCounterServiceSpeedTests {
private static int threadCount = 2;
private static final int number = Boolean.getBoolean("performance.test") ? 10000000
: 1000000;
private static final int number = (Boolean.getBoolean("performance.test") ? 10000000
: 1000000);
private static int count;

View File

@ -232,7 +232,7 @@ public class AutoConfigurationImportSelector
RelaxedPropertyResolver resolver = new RelaxedPropertyResolver(getEnvironment(),
"spring.autoconfigure.");
String[] exclude = resolver.getProperty("exclude", String[].class);
return (Arrays.asList(exclude == null ? new String[0] : exclude));
return (Arrays.asList(exclude != null ? exclude : new String[0]));
}
private List<String> sort(List<String> configurations,
@ -298,7 +298,7 @@ public class AutoConfigurationImportSelector
protected final List<String> asList(AnnotationAttributes attributes, String name) {
String[] value = attributes.getStringArray(name);
return Arrays.asList(value == null ? new String[0] : value);
return Arrays.asList(value != null ? value : new String[0]);
}
private void fireAutoConfigurationImportEvents(List<String> configurations,

View File

@ -66,7 +66,7 @@ class AutoConfigurationSorter {
public int compare(String o1, String o2) {
int i1 = classes.get(o1).getOrder();
int i2 = classes.get(o2).getOrder();
return (i1 < i2) ? -1 : (i1 > i2) ? 1 : 0;
return (i1 < i2 ? -1 : (i1 > i2 ? 1 : 0));
}
});
@ -174,8 +174,8 @@ class AutoConfigurationSorter {
}
Map<String, Object> attributes = getAnnotationMetadata()
.getAnnotationAttributes(AutoConfigureOrder.class.getName());
return (attributes == null ? Ordered.LOWEST_PRECEDENCE
: (Integer) attributes.get("value"));
return (attributes != null ? (Integer) attributes.get("value")
: Ordered.LOWEST_PRECEDENCE);
}
private Set<String> readBefore() {

View File

@ -111,8 +111,8 @@ class ImportAutoConfigurationImportSelector extends AutoConfigurationImportSelec
for (String annotationName : ANNOTATION_NAMES) {
AnnotationAttributes merged = AnnotatedElementUtils
.getMergedAnnotationAttributes(source, annotationName);
Class<?>[] exclude = (merged == null ? null
: merged.getClassArray("exclude"));
Class<?>[] exclude = (merged != null ? merged.getClassArray("exclude")
: null);
if (exclude != null) {
for (Class<?> excludeClass : exclude) {
exclusions.add(excludeClass.getName());

View File

@ -203,7 +203,7 @@ public class RabbitProperties {
return this.username;
}
Address address = this.parsedAddresses.get(0);
return address.username == null ? this.username : address.username;
return (address.username != null ? address.username : this.username);
}
public void setUsername(String username) {
@ -226,7 +226,7 @@ public class RabbitProperties {
return getPassword();
}
Address address = this.parsedAddresses.get(0);
return address.password == null ? getPassword() : address.password;
return (address.password != null ? address.password : getPassword());
}
public void setPassword(String password) {
@ -253,7 +253,7 @@ public class RabbitProperties {
return getVirtualHost();
}
Address address = this.parsedAddresses.get(0);
return address.virtualHost == null ? getVirtualHost() : address.virtualHost;
return (address.virtualHost != null ? address.virtualHost : getVirtualHost());
}
public void setVirtualHost(String virtualHost) {

View File

@ -124,7 +124,7 @@ public class CacheAutoConfiguration {
}
private String[] append(String[] array, String value) {
String[] result = new String[array == null ? 1 : array.length + 1];
String[] result = new String[array != null ? array.length + 1 : 1];
if (array != null) {
System.arraycopy(array, 0, result, 0, array.length);
}

View File

@ -289,9 +289,9 @@ final class BeanTypeRegistry implements SmartInitializingSingleton {
private Method[] getCandidateFactoryMethods(BeanDefinition definition,
Class<?> factoryClass) {
return shouldConsiderNonPublicMethods(definition)
return (shouldConsiderNonPublicMethods(definition)
? ReflectionUtils.getAllDeclaredMethods(factoryClass)
: factoryClass.getMethods();
: factoryClass.getMethods());
}
private boolean shouldConsiderNonPublicMethods(BeanDefinition definition) {

View File

@ -61,7 +61,7 @@ public final class ConditionMessage {
@Override
public String toString() {
return (this.message == null ? "" : this.message);
return (this.message != null ? this.message : "");
}
@Override
@ -359,7 +359,7 @@ public final class ConditionMessage {
*/
public ConditionMessage items(Style style, Object... items) {
return items(style,
items == null ? (Collection<?>) null : Arrays.asList(items));
items != null ? Arrays.asList(items) : (Collection<?>) null);
}
/**
@ -416,7 +416,7 @@ public final class ConditionMessage {
QUOTE {
@Override
protected String applyToItem(Object item) {
return (item == null ? null : "'" + item + "'");
return (item != null ? "'" + item + "'" : null);
}
};

View File

@ -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() : "");
}
/**

View File

@ -44,10 +44,10 @@ class OnExpressionCondition extends SpringBootCondition {
String rawExpression = expression;
expression = context.getEnvironment().resolvePlaceholders(expression);
ConfigurableListableBeanFactory beanFactory = context.getBeanFactory();
BeanExpressionResolver resolver = (beanFactory != null)
? beanFactory.getBeanExpressionResolver() : null;
BeanExpressionContext expressionContext = (beanFactory != null)
? new BeanExpressionContext(beanFactory, null) : null;
BeanExpressionResolver resolver = (beanFactory != null
? beanFactory.getBeanExpressionResolver() : null);
BeanExpressionContext expressionContext = (beanFactory != null
? new BeanExpressionContext(beanFactory, null) : null);
if (resolver == null) {
resolver = new StandardBeanExpressionResolver();
}

View File

@ -53,7 +53,7 @@ class OnJavaCondition extends SpringBootCondition {
JavaVersion version) {
boolean match = runningVersion.isWithin(range, version);
String expected = String.format(
range == Range.EQUAL_OR_NEWER ? "(%s or newer)" : "(older than %s)",
range != Range.EQUAL_OR_NEWER ? "(older than %s)" : "(%s or newer)",
version);
ConditionMessage message = ConditionMessage
.forCondition(ConditionalOnJava.class, expected)

View File

@ -46,8 +46,8 @@ class OnResourceCondition extends SpringBootCondition {
AnnotatedTypeMetadata metadata) {
MultiValueMap<String, Object> attributes = metadata
.getAllAnnotationAttributes(ConditionalOnResource.class.getName(), true);
ResourceLoader loader = context.getResourceLoader() == null
? this.defaultResourceLoader : context.getResourceLoader();
ResourceLoader loader = (context.getResourceLoader() != null
? context.getResourceLoader() : this.defaultResourceLoader);
List<String> locations = new ArrayList<String>();
collectValues(locations, attributes.get("resources"));
Assert.isTrue(!locations.isEmpty(),

View File

@ -195,8 +195,8 @@ public class RedisAutoConfiguration {
}
private JedisConnectionFactory createJedisConnectionFactory() {
JedisPoolConfig poolConfig = this.properties.getPool() != null
? jedisPoolConfig() : new JedisPoolConfig();
JedisPoolConfig poolConfig = (this.properties.getPool() != null
? jedisPoolConfig() : new JedisPoolConfig());
if (getSentinelConfig() != null) {
return new JedisConnectionFactory(getSentinelConfig(), poolConfig);

View File

@ -80,7 +80,7 @@ class NoSuchBeanDefinitionFailureAnalyzer
cause);
StringBuilder message = new StringBuilder();
message.append(String.format("%s required %s that could not be found.%n",
description == null ? "A component" : description,
(description != null ? description : "A component"),
getBeanDescription(cause)));
if (!autoConfigurationResults.isEmpty()) {
for (AutoConfigurationResult provider : autoConfigurationResults) {
@ -165,7 +165,7 @@ class NoSuchBeanDefinitionFailureAnalyzer
Source(String source) {
String[] tokens = source.split("#");
this.className = (tokens.length > 1 ? tokens[0] : source);
this.methodName = (tokens.length == 2 ? tokens[1] : null);
this.methodName = (tokens.length != 2 ? null : tokens[1]);
}
public String getClassName() {
@ -225,8 +225,8 @@ class NoSuchBeanDefinitionFailureAnalyzer
private boolean hasName(MethodMetadata methodMetadata, String name) {
Map<String, Object> attributes = methodMetadata
.getAnnotationAttributes(Bean.class.getName());
String[] candidates = (attributes == null ? null
: (String[]) attributes.get("name"));
String[] candidates = (attributes != null ? (String[]) attributes.get("name")
: null);
if (candidates != null) {
for (String candidate : candidates) {
if (candidate.equals(name)) {

View File

@ -108,7 +108,7 @@ public class FlywayProperties {
}
public String getPassword() {
return (this.password == null ? "" : this.password);
return (this.password != null ? this.password : "");
}
public void setPassword(String password) {

View File

@ -72,7 +72,7 @@ public class ProjectInfoAutoConfiguration {
}
protected Properties loadFrom(Resource location, String prefix) throws IOException {
String p = prefix.endsWith(".") ? prefix : prefix + ".";
String p = (prefix.endsWith(".") ? prefix : prefix + ".");
Properties source = PropertiesLoaderUtils.loadProperties(location);
Properties target = new Properties();
for (String key : source.stringPropertyNames()) {

View File

@ -184,7 +184,7 @@ public class DataSourceAutoConfiguration {
private ClassLoader getDataSourceClassLoader(ConditionContext context) {
Class<?> dataSourceClass = new DataSourceBuilder(context.getClassLoader())
.findType();
return (dataSourceClass == null ? null : dataSourceClass.getClassLoader());
return (dataSourceClass != null ? dataSourceClass.getClassLoader() : null);
}
}

View File

@ -41,9 +41,9 @@ public class DataSourcePoolMetadataProviders implements DataSourcePoolMetadataPr
*/
public DataSourcePoolMetadataProviders(
Collection<? extends DataSourcePoolMetadataProvider> providers) {
this.providers = (providers == null
? Collections.<DataSourcePoolMetadataProvider>emptyList()
: new ArrayList<DataSourcePoolMetadataProvider>(providers));
this.providers = (providers != null
? new ArrayList<DataSourcePoolMetadataProvider>(providers)
: Collections.<DataSourcePoolMetadataProvider>emptyList());
}
@Override

View File

@ -34,7 +34,7 @@ public class TomcatDataSourcePoolMetadata
@Override
public Integer getActive() {
ConnectionPool pool = getDataSource().getPool();
return (pool == null ? 0 : pool.getActive());
return (pool != null ? pool.getActive() : 0);
}
@Override

View File

@ -198,7 +198,7 @@ public class JerseyAutoConfiguration implements ServletContextAware {
if (!applicationPath.startsWith("/")) {
applicationPath = "/" + applicationPath;
}
return applicationPath.equals("/") ? "/*" : applicationPath + "/*";
return (applicationPath.equals("/") ? "/*" : applicationPath + "/*");
}
@Override

View File

@ -226,7 +226,7 @@ public class MongoProperties {
if (options == null) {
options = MongoClientOptions.builder().build();
}
String host = this.host == null ? "localhost" : this.host;
String host = (this.host != null ? this.host : "localhost");
return new MongoClient(Collections.singletonList(new ServerAddress(host, port)),
Collections.<MongoCredential>emptyList(), options);
}
@ -242,13 +242,13 @@ public class MongoProperties {
}
List<MongoCredential> credentials = new ArrayList<MongoCredential>();
if (hasCustomCredentials()) {
String database = this.authenticationDatabase == null
? getMongoClientDatabase() : this.authenticationDatabase;
String database = (this.authenticationDatabase != null
? this.authenticationDatabase : getMongoClientDatabase());
credentials.add(MongoCredential.createCredential(this.username, database,
this.password));
}
String host = this.host == null ? "localhost" : this.host;
int port = this.port != null ? this.port : DEFAULT_PORT;
String host = (this.host != null ? this.host : "localhost");
int port = (this.port != null ? this.port : DEFAULT_PORT);
return new MongoClient(
Collections.singletonList(new ServerAddress(host, port)), credentials,
options);

View File

@ -239,8 +239,8 @@ public class EmbeddedMongoAutoConfiguration {
Set<Feature> features) {
Assert.notNull(version, "version must not be null");
this.version = version;
this.features = (features == null ? Collections.<Feature>emptySet()
: features);
this.features = (features != null ? features
: Collections.<Feature>emptySet());
}
@Override

View File

@ -283,7 +283,7 @@ public class SpringBootWebSecurityConfiguration {
private String[] getSecureApplicationPaths() {
List<String> list = new ArrayList<String>();
for (String path : this.security.getBasic().getPath()) {
path = (path == null ? "" : path.trim());
path = (path != null ? path.trim() : "");
if (path.equals("/**")) {
return new String[] { path };
}

View File

@ -70,7 +70,7 @@ public class DefaultUserInfoRestTemplateFactory implements UserInfoRestTemplateF
public OAuth2RestTemplate getUserInfoRestTemplate() {
if (this.oauth2RestTemplate == null) {
this.oauth2RestTemplate = createOAuth2RestTemplate(
this.details == null ? DEFAULT_RESOURCE_DETAILS : this.details);
this.details != null ? this.details : DEFAULT_RESOURCE_DETAILS);
this.oauth2RestTemplate.getInterceptors()
.add(new AcceptJsonRequestInterceptor());
AuthorizationCodeAccessTokenProvider accessTokenProvider = new AuthorizationCodeAccessTokenProvider();

View File

@ -115,7 +115,7 @@ public class UserInfoTokenServices implements ResourceServerTokenServices {
*/
protected Object getPrincipal(Map<String, Object> map) {
Object principal = this.principalExtractor.extractPrincipal(map);
return (principal == null ? "unknown" : principal);
return (principal != null ? principal : "unknown");
}
@Override

View File

@ -70,7 +70,7 @@ public class FacebookAutoConfiguration {
public Facebook facebook(ConnectionRepository repository) {
Connection<Facebook> connection = repository
.findPrimaryConnection(Facebook.class);
return connection != null ? connection.getApi() : null;
return (connection != null ? connection.getApi() : null);
}
@Bean(name = { "connect/facebookConnect", "connect/facebookConnected" })

View File

@ -70,7 +70,7 @@ public class LinkedInAutoConfiguration {
public LinkedIn linkedin(ConnectionRepository repository) {
Connection<LinkedIn> connection = repository
.findPrimaryConnection(LinkedIn.class);
return connection != null ? connection.getApi() : null;
return (connection != null ? connection.getApi() : null);
}
@Bean(name = { "connect/linkedinConnect", "connect/linkedinConnected" })

View File

@ -76,7 +76,7 @@ public class TemplateAvailabilityProviders {
* @param applicationContext the source application context
*/
public TemplateAvailabilityProviders(ApplicationContext applicationContext) {
this(applicationContext == null ? null : applicationContext.getClassLoader());
this(applicationContext != null ? applicationContext.getClassLoader() : null);
}
/**
@ -144,12 +144,12 @@ public class TemplateAvailabilityProviders {
if (provider == null) {
synchronized (this.cache) {
provider = findProvider(view, environment, classLoader, resourceLoader);
provider = (provider == null ? NONE : provider);
provider = (provider != null ? provider : NONE);
this.resolved.put(view, provider);
this.cache.put(view, provider);
}
}
return (provider == NONE ? null : provider);
return (provider != NONE ? provider : null);
}
private TemplateAvailabilityProvider findProvider(String view,

View File

@ -41,8 +41,9 @@ public class TransactionManagerCustomizers {
public TransactionManagerCustomizers(
Collection<? extends PlatformTransactionManagerCustomizer<?>> customizers) {
this.customizers = (customizers == null ? null
: new ArrayList<PlatformTransactionManagerCustomizer<?>>(customizers));
this.customizers = (customizers != null
? new ArrayList<PlatformTransactionManagerCustomizer<?>>(customizers)
: null);
}
public void customize(PlatformTransactionManager transactionManager) {

View File

@ -90,7 +90,7 @@ public class BasicErrorController extends AbstractErrorController {
request, isIncludeStackTrace(request, MediaType.TEXT_HTML)));
response.setStatus(status.value());
ModelAndView modelAndView = resolveErrorView(request, response, status, model);
return (modelAndView == null ? new ModelAndView("error", model) : modelAndView);
return (modelAndView != null ? modelAndView : new ModelAndView("error", model));
}
@RequestMapping

View File

@ -283,11 +283,11 @@ public class ErrorMvcAutoConfiguration {
@Override
public String resolvePlaceholder(String placeholderName) {
Expression expression = this.expressions.get(placeholderName);
return escape(expression == null ? null : expression.getValue(this.context));
return escape(expression != null ? expression.getValue(this.context) : null);
}
private String escape(Object value) {
return HtmlUtils.htmlEscape(value == null ? null : value.toString());
return HtmlUtils.htmlEscape(value != null ? value.toString() : null);
}
}

View File

@ -102,7 +102,7 @@ public class HttpEncodingProperties {
}
boolean shouldForce(Type type) {
Boolean force = (type == Type.REQUEST ? this.forceRequest : this.forceResponse);
Boolean force = (type != Type.REQUEST ? this.forceResponse : this.forceRequest);
if (force == null) {
force = this.force;
}

View File

@ -64,8 +64,8 @@ public class HttpMessageConvertersAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public HttpMessageConverters messageConverters() {
return new HttpMessageConverters(this.converters == null
? Collections.<HttpMessageConverter<?>>emptyList() : this.converters);
return new HttpMessageConverters(this.converters != null ? this.converters
: Collections.<HttpMessageConverter<?>>emptyList());
}
@Configuration

View File

@ -382,7 +382,7 @@ public class ServerProperties
return this.useForwardHeaders;
}
CloudPlatform platform = CloudPlatform.getActive(this.environment);
return (platform == null ? false : platform.isUsingForwardHeaders());
return (platform != null ? platform.isUsingForwardHeaders() : false);
}
public Integer getConnectionTimeout() {

View File

@ -381,8 +381,8 @@ public class WebMvcAutoConfiguration {
@Override
public RequestMappingHandlerAdapter requestMappingHandlerAdapter() {
RequestMappingHandlerAdapter adapter = super.requestMappingHandlerAdapter();
adapter.setIgnoreDefaultModelOnRedirect(this.mvcProperties == null ? true
: this.mvcProperties.isIgnoreDefaultModelOnRedirect());
adapter.setIgnoreDefaultModelOnRedirect(this.mvcProperties != null
? this.mvcProperties.isIgnoreDefaultModelOnRedirect() : true);
return adapter;
}

View File

@ -96,8 +96,8 @@ public class HazelcastJpaDependencyAutoConfigurationTests {
private List<String> getEntityManagerFactoryDependencies() {
String[] dependsOn = this.context.getBeanDefinition("entityManagerFactory")
.getDependsOn();
return dependsOn != null ? Arrays.asList(dependsOn)
: Collections.<String>emptyList();
return (dependsOn != null ? Arrays.asList(dependsOn)
: Collections.<String>emptyList());
}
public void load(Class<?> config) {

View File

@ -64,7 +64,7 @@ public class SpringApplicationWebApplicationInitializer
private Manifest getManifest(ServletContext servletContext) throws IOException {
InputStream stream = servletContext.getResourceAsStream("/META-INF/MANIFEST.MF");
Manifest manifest = (stream == null ? null : new Manifest(stream));
Manifest manifest = (stream != null ? new Manifest(stream) : null);
return manifest;
}

View File

@ -260,7 +260,7 @@ public class CommandRunner implements Iterable<Command> {
}
protected boolean errorMessage(String message) {
Log.error(message == null ? "Unexpected error" : message);
Log.error(message != null ? message : "Unexpected error");
return message != null;
}
@ -280,8 +280,8 @@ public class CommandRunner implements Iterable<Command> {
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("");

View File

@ -238,7 +238,7 @@ abstract class ArchiveCommand extends OptionParsingCommand {
private String commaDelimitedClassNames(Class<?>[] classes) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < classes.length; i++) {
builder.append(i == 0 ? "" : ",");
builder.append(i != 0 ? "," : "");
builder.append(classes[i].getName());
}
return builder.toString();

View File

@ -107,7 +107,7 @@ public class HelpCommand extends AbstractCommand {
}
Collection<HelpExample> examples = command.getExamples();
if (examples != null) {
Log.info(examples.size() == 1 ? "example:" : "examples:");
Log.info(examples.size() != 1 ? "examples:" : "example:");
Log.info("");
for (HelpExample example : examples) {
Log.info(" " + example.getDescription() + ":");

View File

@ -45,7 +45,7 @@ public class HintCommand extends AbstractCommand {
@Override
public ExitStatus run(String... args) throws Exception {
try {
int index = (args.length == 0 ? 0 : Integer.valueOf(args[0]) - 1);
int index = (args.length != 0 ? Integer.valueOf(args[0]) - 1 : 0);
List<String> arguments = new ArrayList<String>(args.length);
for (int i = 2; i < args.length; i++) {
arguments.add(args[i]);

View File

@ -149,8 +149,8 @@ class InitializrServiceMetadata {
}
JSONObject type = root.getJSONObject(TYPE_EL);
JSONArray array = type.getJSONArray(VALUES_EL);
String defaultType = type.has(DEFAULT_ATTRIBUTE)
? type.getString(DEFAULT_ATTRIBUTE) : null;
String defaultType = (type.has(DEFAULT_ATTRIBUTE)
? type.getString(DEFAULT_ATTRIBUTE) : null);
for (int i = 0; i < array.length(); i++) {
JSONObject typeJson = array.getJSONObject(i);
ProjectType projectType = parseType(typeJson, defaultType);
@ -212,7 +212,7 @@ class InitializrServiceMetadata {
private String getStringValue(JSONObject object, String name, String defaultValue)
throws JSONException {
return object.has(name) ? object.getString(name) : defaultValue;
return (object.has(name) ? object.getString(name) : defaultValue);
}
private Map<String, String> parseStringItems(JSONObject json) throws JSONException {

View File

@ -417,7 +417,7 @@ class ProjectGenerationRequest {
}
if (this.output != null) {
int i = this.output.lastIndexOf('.');
return (i == -1 ? this.output : this.output.substring(0, i));
return (i != -1 ? this.output.substring(0, i) : this.output);
}
return null;
}

View File

@ -164,7 +164,7 @@ public class OptionHandler {
OptionHelpAdapter(OptionDescriptor descriptor) {
this.options = new LinkedHashSet<String>();
for (String option : descriptor.options()) {
this.options.add((option.length() == 1 ? "-" : "--") + option);
this.options.add((option.length() != 1 ? "--" : "-") + option);
}
if (this.options.contains("--cp")) {
this.options.remove("--cp");

View File

@ -73,7 +73,7 @@ public class CommandCompleter extends StringsCompleter {
public int complete(String buffer, int cursor, List<CharSequence> candidates) {
int completionIndex = super.complete(buffer, cursor, candidates);
int spaceIndex = buffer.indexOf(' ');
String commandName = (spaceIndex == -1) ? "" : buffer.substring(0, spaceIndex);
String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : "");
if (!"".equals(commandName.trim())) {
for (Command command : this.commands) {
if (command.getName().equals(commandName)) {
@ -129,7 +129,7 @@ public class CommandCompleter extends StringsCompleter {
OptionHelpLine(OptionHelp optionHelp) {
StringBuilder options = new StringBuilder();
for (String option : optionHelp.getOptions()) {
options.append(options.length() == 0 ? "" : ", ");
options.append(options.length() != 0 ? ", " : "");
options.append(option);
}
this.options = options.toString();

View File

@ -145,7 +145,7 @@ public class Shell {
private void printBanner() {
String version = getClass().getPackage().getImplementationVersion();
version = (version == null ? "" : " (v" + version + ")");
version = (version != null ? " (v" + version + ")" : "");
System.out.println(ansi("Spring Boot", Code.BOLD).append(version, Code.FAINT));
System.out.println(ansi("Hit TAB to complete. Type 'help' and hit "
+ "RETURN for help, and 'exit' to quit."));

View File

@ -53,7 +53,7 @@ public class ShellPrompts {
* @return the current prompt
*/
public String getPrompt() {
return this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek();
return (this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek());
}
}

View File

@ -119,7 +119,7 @@ public class ExtendedGroovyClassLoader extends GroovyClassLoader {
InputStream resourceStream = super.getResourceAsStream(name);
if (resourceStream == null) {
byte[] bytes = this.classResources.get(name);
resourceStream = bytes == null ? null : new ByteArrayInputStream(bytes);
resourceStream = (bytes != null ? new ByteArrayInputStream(bytes) : null);
}
return resourceStream;
}

View File

@ -42,13 +42,13 @@ public class DependencyManagementArtifactCoordinatesResolver
@Override
public String getGroupId(String artifactId) {
Dependency dependency = find(artifactId);
return (dependency == null ? null : dependency.getGroupId());
return (dependency != null ? dependency.getGroupId() : null);
}
@Override
public String getArtifactId(String id) {
Dependency dependency = find(id);
return dependency == null ? null : dependency.getArtifactId();
return (dependency != null ? dependency.getArtifactId() : null);
}
private Dependency find(String id) {
@ -69,7 +69,7 @@ public class DependencyManagementArtifactCoordinatesResolver
@Override
public String getVersion(String module) {
Dependency dependency = find(module);
return dependency == null ? null : dependency.getVersion();
return (dependency != null ? dependency.getVersion() : null);
}
}

View File

@ -209,7 +209,7 @@ public class AetherGrapeEngine implements GrapeEngine {
private boolean isTransitive(Map<?, ?> dependencyMap) {
Boolean transitive = (Boolean) dependencyMap.get("transitive");
return (transitive == null ? true : transitive);
return (transitive != null ? transitive : true);
}
private List<Dependency> getDependencies(DependencyResult dependencyResult) {
@ -231,7 +231,7 @@ public class AetherGrapeEngine implements GrapeEngine {
private GroovyClassLoader getClassLoader(Map args) {
GroovyClassLoader classLoader = (GroovyClassLoader) args.get("classLoader");
return (classLoader == null ? this.classLoader : classLoader);
return (classLoader != null ? classLoader : this.classLoader);
}
@Override

View File

@ -51,8 +51,9 @@ public class DefaultRepositorySystemSessionAutoConfiguration
ProxySelector existing = session.getProxySelector();
if (existing == null || !(existing instanceof CompositeProxySelector)) {
JreProxySelector fallback = new JreProxySelector();
ProxySelector selector = existing == null ? fallback
: new CompositeProxySelector(Arrays.asList(existing, fallback));
ProxySelector selector = (existing != null
? new CompositeProxySelector(Arrays.asList(existing, fallback))
: fallback);
session.setProxySelector(selector);
}
}

View File

@ -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<Dependency> getManagedDependencies() {
@ -104,9 +104,10 @@ public class DependencyResolutionContext {
this.managedDependencyByGroupAndArtifact.put(getIdentifier(aetherDependency),
aetherDependency);
}
this.dependencyManagement = this.dependencyManagement == null
? dependencyManagement : new CompositeDependencyManagement(
dependencyManagement, this.dependencyManagement);
this.dependencyManagement = (this.dependencyManagement != null
? new CompositeDependencyManagement(dependencyManagement,
this.dependencyManagement)
: dependencyManagement);
this.artifactCoordinatesResolver = new DependencyManagementArtifactCoordinatesResolver(
this.dependencyManagement);
}

View File

@ -120,8 +120,8 @@ public abstract class AbstractHttpClientMockTests {
try {
HttpEntity entity = mock(HttpEntity.class);
given(entity.getContent()).willReturn(new ByteArrayInputStream(content));
Header contentTypeHeader = contentType != null
? new BasicHeader("Content-Type", contentType) : null;
Header contentTypeHeader = (contentType != null
? new BasicHeader("Content-Type", contentType) : null);
given(entity.getContentType()).willReturn(contentTypeHeader);
given(response.getEntity()).willReturn(entity);
return entity;
@ -139,7 +139,7 @@ public abstract class AbstractHttpClientMockTests {
protected void mockHttpHeader(CloseableHttpResponse response, String headerName,
String value) {
Header header = value != null ? new BasicHeader(headerName, value) : null;
Header header = (value != null ? new BasicHeader(headerName, value) : null);
given(response.getFirstHeader(headerName)).willReturn(header);
}

View File

@ -95,8 +95,8 @@ public class RemoteDevToolsAutoConfiguration {
@Bean
public HandlerMapper remoteDevToolsHealthCheckHandlerMapper() {
Handler handler = new HttpStatusHandler();
return new UrlHandlerMapper((this.serverProperties.getContextPath() == null ? ""
: this.serverProperties.getContextPath())
return new UrlHandlerMapper((this.serverProperties.getContextPath() != null
? this.serverProperties.getContextPath() : "")
+ this.properties.getRemote().getContextPath(), handler);
}
@ -136,8 +136,8 @@ public class RemoteDevToolsAutoConfiguration {
@Bean
@ConditionalOnMissingBean(name = "remoteRestartHandlerMapper")
public UrlHandlerMapper remoteRestartHandlerMapper(HttpRestartServer server) {
String url = (this.serverProperties.getContextPath() == null ? ""
: this.serverProperties.getContextPath())
String url = (this.serverProperties.getContextPath() != null
? this.serverProperties.getContextPath() : "")
+ this.properties.getRemote().getContextPath() + "/restart";
logger.warn("Listening for remote restart updates on " + url);
Handler handler = new HttpRestartServerHandler(server);
@ -162,8 +162,8 @@ public class RemoteDevToolsAutoConfiguration {
@ConditionalOnMissingBean(name = "remoteDebugHandlerMapper")
public UrlHandlerMapper remoteDebugHandlerMapper(
@Qualifier("remoteDebugHttpTunnelServer") HttpTunnelServer server) {
String url = (this.serverProperties.getContextPath() == null ? ""
: this.serverProperties.getContextPath())
String url = (this.serverProperties.getContextPath() != null
? this.serverProperties.getContextPath() : "")
+ this.properties.getRemote().getContextPath() + "/debug";
logger.warn("Listening for remote debug traffic on " + url);
Handler handler = new HttpTunnelServerHandler(server);

View File

@ -44,7 +44,7 @@ public class DevToolsHomePropertiesPostProcessor implements EnvironmentPostProce
public void postProcessEnvironment(ConfigurableEnvironment environment,
SpringApplication application) {
File home = getHomeFolder();
File propertyFile = (home == null ? null : new File(home, FILE_NAME));
File propertyFile = (home != null ? new File(home, FILE_NAME) : null);
if (propertyFile != null && propertyFile.exists() && propertyFile.isFile()) {
FileSystemResource resource = new FileSystemResource(propertyFile);
Properties properties;

View File

@ -135,7 +135,7 @@ public class ClassPathChangeUploader
private void logUpload(ClassLoaderFiles classLoaderFiles) {
int size = classLoaderFiles.size();
logger.info(
"Uploaded " + size + " class " + (size == 1 ? "resource" : "resources"));
"Uploaded " + size + " class " + (size != 1 ? "resources" : "resource"));
}
private byte[] serialize(ClassLoaderFiles classLoaderFiles) throws IOException {
@ -162,10 +162,10 @@ public class ClassPathChangeUploader
private ClassLoaderFile asClassLoaderFile(ChangedFile changedFile)
throws IOException {
ClassLoaderFile.Kind kind = TYPE_MAPPINGS.get(changedFile.getType());
byte[] bytes = (kind == Kind.DELETED ? null
: FileCopyUtils.copyToByteArray(changedFile.getFile()));
long lastModified = (kind == Kind.DELETED ? System.currentTimeMillis()
: changedFile.getFile().lastModified());
byte[] bytes = (kind != Kind.DELETED
? FileCopyUtils.copyToByteArray(changedFile.getFile()) : null);
long lastModified = (kind != Kind.DELETED ? changedFile.getFile().lastModified()
: System.currentTimeMillis());
return new ClassLoaderFile(kind, lastModified, bytes);
}

View File

@ -55,8 +55,8 @@ public class ClassLoaderFile implements Serializable {
*/
public ClassLoaderFile(Kind kind, long lastModified, byte[] contents) {
Assert.notNull(kind, "Kind must not be null");
Assert.isTrue(kind == Kind.DELETED ? contents == null : contents != null,
"Contents must " + (kind == Kind.DELETED ? "" : "not ") + "be null");
Assert.isTrue(kind != Kind.DELETED ? contents != null : contents == null,
"Contents must " + (kind != Kind.DELETED ? "not " : "") + "be null");
this.kind = kind;
this.lastModified = lastModified;
this.contents = contents;

View File

@ -91,8 +91,8 @@ public class HttpTunnelConnection implements TunnelConnection {
throw new IllegalArgumentException("Malformed URL '" + url + "'");
}
this.requestFactory = requestFactory;
this.executor = (executor == null
? Executors.newCachedThreadPool(new TunnelThreadFactory()) : executor);
this.executor = (executor != null ? executor
: Executors.newCachedThreadPool(new TunnelThreadFactory()));
}
@Override

View File

@ -139,7 +139,7 @@ public class ClassPathChangeUploaderTests {
private void assertClassFile(ClassLoaderFile file, String content, Kind kind) {
assertThat(file.getContents())
.isEqualTo(content == null ? null : content.getBytes());
.isEqualTo(content != null ? content.getBytes() : null);
assertThat(file.getKind()).isEqualTo(kind);
}

View File

@ -45,8 +45,8 @@ public class SpockTestRestTemplateExample {
ObjectProvider<RestTemplateBuilder> builderProvider,
Environment environment) {
RestTemplateBuilder builder = builderProvider.getIfAvailable();
TestRestTemplate template = builder == null ? new TestRestTemplate()
: new TestRestTemplate(builder.build());
TestRestTemplate template = (builder != null
? new TestRestTemplate(builder.build()) : new TestRestTemplate());
template.setUriTemplateHandler(new LocalHostUriTemplateHandler(environment));
return template;
}

View File

@ -66,8 +66,9 @@ abstract class AbstractApplicationLauncher extends ExternalResource {
private Process startApplication() throws Exception {
File workingDirectory = getWorkingDirectory();
File serverPortFile = workingDirectory == null ? new File("target/server.port")
: new File(workingDirectory, "target/server.port");
File serverPortFile = (workingDirectory != null
? new File(workingDirectory, "target/server.port")
: new File("target/server.port"));
serverPortFile.delete();
File archive = this.applicationBuilder.buildApplication();
List<String> arguments = new ArrayList<String>();

View File

@ -107,14 +107,14 @@ class BootRunApplicationLauncher extends AbstractApplicationLauncher {
}
private String getClassesPath(File archive) {
return archive.getName().endsWith(".jar") ? "BOOT-INF/classes"
: "WEB-INF/classes";
return (archive.getName().endsWith(".jar") ? "BOOT-INF/classes"
: "WEB-INF/classes");
}
private List<String> getLibPaths(File archive) {
return archive.getName().endsWith(".jar")
return (archive.getName().endsWith(".jar")
? Collections.singletonList("BOOT-INF/lib")
: Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided");
: Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided"));
}
private void explodeArchive(File archive) throws IOException {

View File

@ -54,9 +54,9 @@ class ExplodedApplicationLauncher extends AbstractApplicationLauncher {
@Override
protected List<String> getArguments(File archive) {
String mainClass = archive.getName().endsWith(".war")
String mainClass = (archive.getName().endsWith(".war")
? "org.springframework.boot.loader.WarLauncher"
: "org.springframework.boot.loader.JarLauncher";
: "org.springframework.boot.loader.JarLauncher");
try {
explodeArchive(archive);
return Arrays.asList("-cp", this.exploded.getAbsolutePath(), mainClass);

View File

@ -128,14 +128,14 @@ class IdeApplicationLauncher extends AbstractApplicationLauncher {
}
private String getClassesPath(File archive) {
return archive.getName().endsWith(".jar") ? "BOOT-INF/classes"
: "WEB-INF/classes";
return (archive.getName().endsWith(".jar") ? "BOOT-INF/classes"
: "WEB-INF/classes");
}
private List<String> getLibPaths(File archive) {
return archive.getName().endsWith(".jar")
return (archive.getName().endsWith(".jar")
? Collections.singletonList("BOOT-INF/lib")
: Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided");
: Arrays.asList("WEB-INF/lib", "WEB-INF/lib-provided"));
}
private void explodeArchive(File archive, File destination) throws IOException {

View File

@ -25,7 +25,7 @@ public interface HotelSummary {
Double getAverageRating();
default Integer getAverageRatingRounded() {
return getAverageRating() == null ? null : (int) Math.round(getAverageRating());
return (getAverageRating() != null ? (int) Math.round(getAverageRating()) : null);
}
}

View File

@ -25,7 +25,7 @@ public interface HotelSummary {
Double getAverageRating();
default Integer getAverageRatingRounded() {
return getAverageRating() == null ? null : (int) Math.round(getAverageRating());
return (getAverageRating() != null ? (int) Math.round(getAverageRating()) : null);
}
}

View File

@ -25,7 +25,7 @@ public interface HotelSummary {
Double getAverageRating();
default Integer getAverageRatingRounded() {
return getAverageRating() == null ? null : (int) Math.round(getAverageRating());
return (getAverageRating() != null ? (int) Math.round(getAverageRating()) : null);
}
}

View File

@ -105,8 +105,8 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
}
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<Class<?>
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());
}

Some files were not shown because too many files have changed in this diff Show More