Commit aeb88519 authored by Phillip Webb's avatar Phillip Webb

Polish ternary expressions

parent b24bb688
...@@ -209,7 +209,7 @@ public class ConditionsReportEndpoint { ...@@ -209,7 +209,7 @@ public class ConditionsReportEndpoint {
this.message = outcome.getMessage(); this.message = outcome.getMessage();
} }
else { else {
this.message = (outcome.isMatch() ? "matched" : "did not match"); this.message = outcome.isMatch() ? "matched" : "did not match";
} }
} }
......
...@@ -51,7 +51,7 @@ public class PropertiesMeterFilter implements MeterFilter { ...@@ -51,7 +51,7 @@ public class PropertiesMeterFilter implements MeterFilter {
@Override @Override
public MeterFilterReply accept(Meter.Id id) { public MeterFilterReply accept(Meter.Id id) {
boolean enabled = lookup(this.properties.getEnable(), id, true); boolean enabled = lookup(this.properties.getEnable(), id, true);
return (enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY); return enabled ? MeterFilterReply.NEUTRAL : MeterFilterReply.DENY;
} }
@Override @Override
......
...@@ -224,7 +224,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten ...@@ -224,7 +224,7 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
} }
private <T> T getLast(List<T> list) { private <T> T getLast(List<T> list) {
return (CollectionUtils.isEmpty(list) ? null : list.get(list.size() - 1)); return CollectionUtils.isEmpty(list) ? null : list.get(list.size() - 1);
} }
private void assertNoDuplicateOperations(EndpointBean endpointBean, private void assertNoDuplicateOperations(EndpointBean endpointBean,
......
...@@ -61,7 +61,7 @@ public class ServletEndpointRegistrar implements ServletContextInitializer { ...@@ -61,7 +61,7 @@ public class ServletEndpointRegistrar implements ServletContextInitializer {
ExposableServletEndpoint endpoint) { ExposableServletEndpoint endpoint) {
String name = endpoint.getId() + "-actuator-endpoint"; String name = endpoint.getId() + "-actuator-endpoint";
String path = this.basePath + "/" + endpoint.getRootPath(); String path = this.basePath + "/" + endpoint.getRootPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); String urlMapping = path.endsWith("/") ? path + "*" : path + "/*";
EndpointServlet endpointServlet = endpoint.getEndpointServlet(); EndpointServlet endpointServlet = endpoint.getEndpointServlet();
Dynamic registration = servletContext.addServlet(name, Dynamic registration = servletContext.addServlet(name,
endpointServlet.getServlet()); endpointServlet.getServlet());
......
...@@ -188,7 +188,7 @@ public class JerseyEndpointResourceFactory { ...@@ -188,7 +188,7 @@ public class JerseyEndpointResourceFactory {
private Response convertToJaxRsResponse(Object response, String httpMethod) { private Response convertToJaxRsResponse(Object response, String httpMethod) {
if (response == null) { if (response == null) {
boolean isGet = HttpMethod.GET.equals(httpMethod); boolean isGet = HttpMethod.GET.equals(httpMethod);
Status status = (isGet ? Status.NOT_FOUND : Status.NO_CONTENT); Status status = isGet ? Status.NOT_FOUND : Status.NO_CONTENT;
return Response.status(status).build(); return Response.status(status).build();
} }
try { try {
......
...@@ -132,7 +132,7 @@ public class MetricsEndpoint { ...@@ -132,7 +132,7 @@ public class MetricsEndpoint {
} }
private BiFunction<Double, Double, Double> mergeFunction(Statistic statistic) { private BiFunction<Double, Double, Double> mergeFunction(Statistic statistic) {
return (Statistic.MAX.equals(statistic) ? Double::max : Double::sum); return Statistic.MAX.equals(statistic) ? Double::max : Double::sum;
} }
private Map<String, Set<String>> getAvailableTags(List<Meter> meters) { private Map<String, Set<String>> getAvailableTags(List<Meter> meters) {
......
...@@ -123,7 +123,7 @@ public final class WebMvcTags { ...@@ -123,7 +123,7 @@ public final class WebMvcTags {
private static String getPathInfo(HttpServletRequest request) { private static String getPathInfo(HttpServletRequest request) {
String pathInfo = request.getPathInfo(); String pathInfo = request.getPathInfo();
String uri = (StringUtils.hasText(pathInfo) ? pathInfo : "/"); String uri = StringUtils.hasText(pathInfo) ? pathInfo : "/";
return uri.replaceAll("//+", "/").replaceAll("/$", ""); return uri.replaceAll("//+", "/").replaceAll("/$", "");
} }
......
...@@ -86,7 +86,7 @@ public class HttpExchangeTracer { ...@@ -86,7 +86,7 @@ public class HttpExchangeTracer {
} }
private <T> T getIfIncluded(Include include, Supplier<T> valueSupplier) { private <T> T getIfIncluded(Include include, Supplier<T> valueSupplier) {
return (this.includes.contains(include) ? valueSupplier.get() : null); return this.includes.contains(include) ? valueSupplier.get() : null;
} }
private <T> void setIfIncluded(Include include, Supplier<T> supplier, private <T> void setIfIncluded(Include include, Supplier<T> supplier,
......
...@@ -260,7 +260,7 @@ public class RabbitProperties { ...@@ -260,7 +260,7 @@ public class RabbitProperties {
} }
public void setVirtualHost(String virtualHost) { public void setVirtualHost(String virtualHost) {
this.virtualHost = ("".equals(virtualHost) ? "/" : virtualHost); this.virtualHost = "".equals(virtualHost) ? "/" : virtualHost;
} }
public Duration getRequestedHeartbeat() { public Duration getRequestedHeartbeat() {
......
...@@ -48,7 +48,7 @@ public final class ConditionMessage { ...@@ -48,7 +48,7 @@ public final class ConditionMessage {
} }
private ConditionMessage(ConditionMessage prior, String message) { private ConditionMessage(ConditionMessage prior, String message) {
this.message = (prior.isEmpty() ? message : prior + "; " + message); this.message = prior.isEmpty() ? message : prior + "; " + message;
} }
/** /**
......
...@@ -111,7 +111,7 @@ public class ConditionOutcome { ...@@ -111,7 +111,7 @@ public class ConditionOutcome {
* @return the message or {@code null} * @return the message or {@code null}
*/ */
public String getMessage() { public String getMessage() {
return (this.message.isEmpty() ? null : this.message.toString()); return this.message.isEmpty() ? null : this.message.toString();
} }
/** /**
......
...@@ -52,7 +52,7 @@ public class H2ConsoleAutoConfiguration { ...@@ -52,7 +52,7 @@ public class H2ConsoleAutoConfiguration {
@Bean @Bean
public ServletRegistrationBean<WebServlet> h2Console() { public ServletRegistrationBean<WebServlet> h2Console() {
String path = this.properties.getPath(); String path = this.properties.getPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); String urlMapping = path.endsWith("/") ? path + "*" : path + "/*";
ServletRegistrationBean<WebServlet> registration = new ServletRegistrationBean<>( ServletRegistrationBean<WebServlet> registration = new ServletRegistrationBean<>(
new WebServlet(), urlMapping); new WebServlet(), urlMapping);
H2ConsoleProperties.Settings settings = this.properties.getSettings(); H2ConsoleProperties.Settings settings = this.properties.getSettings();
......
...@@ -72,7 +72,7 @@ public class ProjectInfoAutoConfiguration { ...@@ -72,7 +72,7 @@ public class ProjectInfoAutoConfiguration {
} }
protected Properties loadFrom(Resource location, String prefix) throws IOException { 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 source = PropertiesLoaderUtils.loadProperties(location);
Properties target = new Properties(); Properties target = new Properties();
for (String key : source.stringPropertyNames()) { for (String key : source.stringPropertyNames()) {
......
...@@ -195,7 +195,7 @@ public class JerseyAutoConfiguration implements ServletContextAware { ...@@ -195,7 +195,7 @@ public class JerseyAutoConfiguration implements ServletContextAware {
if (!applicationPath.startsWith("/")) { if (!applicationPath.startsWith("/")) {
applicationPath = "/" + applicationPath; applicationPath = "/" + applicationPath;
} }
return (applicationPath.equals("/") ? "/*" : applicationPath + "/*"); return applicationPath.equals("/") ? "/*" : applicationPath + "/*";
} }
@Override @Override
......
...@@ -69,7 +69,7 @@ public class ResourceProperties { ...@@ -69,7 +69,7 @@ public class ResourceProperties {
String[] normalized = new String[staticLocations.length]; String[] normalized = new String[staticLocations.length];
for (int i = 0; i < staticLocations.length; i++) { for (int i = 0; i < staticLocations.length; i++) {
String location = staticLocations[i]; String location = staticLocations[i];
normalized[i] = (location.endsWith("/") ? location : location + "/"); normalized[i] = location.endsWith("/") ? location : location + "/";
} }
return normalized; return normalized;
} }
......
...@@ -61,7 +61,7 @@ public class WebConversionService extends DefaultFormattingConversionService { ...@@ -61,7 +61,7 @@ public class WebConversionService extends DefaultFormattingConversionService {
*/ */
public WebConversionService(String dateFormat) { public WebConversionService(String dateFormat) {
super(false); super(false);
this.dateFormat = (StringUtils.hasText(dateFormat) ? dateFormat : null); this.dateFormat = StringUtils.hasText(dateFormat) ? dateFormat : null;
if (this.dateFormat != null) { if (this.dateFormat != null) {
addFormatters(); addFormatters();
} }
......
...@@ -77,7 +77,7 @@ public class WebServicesAutoConfiguration { ...@@ -77,7 +77,7 @@ public class WebServicesAutoConfiguration {
MessageDispatcherServlet servlet = new MessageDispatcherServlet(); MessageDispatcherServlet servlet = new MessageDispatcherServlet();
servlet.setApplicationContext(applicationContext); servlet.setApplicationContext(applicationContext);
String path = this.properties.getPath(); String path = this.properties.getPath();
String urlMapping = (path.endsWith("/") ? path + "*" : path + "/*"); String urlMapping = path.endsWith("/") ? path + "*" : path + "/*";
ServletRegistrationBean<MessageDispatcherServlet> registration = new ServletRegistrationBean<>( ServletRegistrationBean<MessageDispatcherServlet> registration = new ServletRegistrationBean<>(
servlet, urlMapping); servlet, urlMapping);
WebServicesProperties.Servlet servletProperties = this.properties.getServlet(); WebServicesProperties.Servlet servletProperties = this.properties.getServlet();
...@@ -152,7 +152,7 @@ public class WebServicesAutoConfiguration { ...@@ -152,7 +152,7 @@ public class WebServicesAutoConfiguration {
} }
private String ensureTrailingSlash(String path) { private String ensureTrailingSlash(String path) {
return (path.endsWith("/") ? path : path + "/"); return path.endsWith("/") ? path : path + "/";
} }
} }
......
...@@ -54,7 +54,7 @@ public class CommandRunner implements Iterable<Command> { ...@@ -54,7 +54,7 @@ public class CommandRunner implements Iterable<Command> {
* @param name the name of the runner or {@code null} * @param name the name of the runner or {@code null}
*/ */
public CommandRunner(String name) { public CommandRunner(String name) {
this.name = (StringUtils.hasLength(name) ? name + " " : ""); this.name = StringUtils.hasLength(name) ? name + " " : "";
} }
/** /**
......
...@@ -212,7 +212,7 @@ class InitializrServiceMetadata { ...@@ -212,7 +212,7 @@ class InitializrServiceMetadata {
private String getStringValue(JSONObject object, String name, String defaultValue) private String getStringValue(JSONObject object, String name, String defaultValue)
throws JSONException { 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 { private Map<String, String> parseStringItems(JSONObject json) throws JSONException {
......
...@@ -54,7 +54,7 @@ public class ShellPrompts { ...@@ -54,7 +54,7 @@ public class ShellPrompts {
* @return the current prompt * @return the current prompt
*/ */
public String getPrompt() { public String getPrompt() {
return (this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek()); return this.prompts.isEmpty() ? DEFAULT_PROMPT : this.prompts.peek();
} }
} }
...@@ -322,7 +322,7 @@ public class GroovyCompiler { ...@@ -322,7 +322,7 @@ public class GroovyCompiler {
return node; return node;
} }
} }
return (classes.isEmpty() ? null : classes.get(0)); return classes.isEmpty() ? null : classes.get(0);
} }
} }
......
...@@ -154,7 +154,7 @@ public class CliTester implements TestRule { ...@@ -154,7 +154,7 @@ public class CliTester implements TestRule {
} }
} }
else { else {
sources[i] = (new File(arg).isAbsolute() ? arg : this.prefix + arg); sources[i] = new File(arg).isAbsolute() ? arg : this.prefix + arg;
} }
} }
return sources; return sources;
......
...@@ -101,7 +101,7 @@ public class HttpTunnelConnection implements TunnelConnection { ...@@ -101,7 +101,7 @@ public class HttpTunnelConnection implements TunnelConnection {
protected final ClientHttpRequest createRequest(boolean hasPayload) protected final ClientHttpRequest createRequest(boolean hasPayload)
throws IOException { throws IOException {
HttpMethod method = (hasPayload ? HttpMethod.POST : HttpMethod.GET); HttpMethod method = hasPayload ? HttpMethod.POST : HttpMethod.GET;
return this.requestFactory.createRequest(this.uri, method); return this.requestFactory.createRequest(this.uri, method);
} }
......
...@@ -161,8 +161,7 @@ public class HttpTunnelConnectionTests { ...@@ -161,8 +161,7 @@ public class HttpTunnelConnectionTests {
private TunnelChannel openTunnel(boolean singleThreaded) throws Exception { private TunnelChannel openTunnel(boolean singleThreaded) throws Exception {
HttpTunnelConnection connection = new HttpTunnelConnection(this.url, HttpTunnelConnection connection = new HttpTunnelConnection(this.url,
this.requestFactory, this.requestFactory, singleThreaded ? new CurrentThreadExecutor() : null);
(singleThreaded ? new CurrentThreadExecutor() : null));
return connection.open(this.incomingChannel, this.closeable); return connection.open(this.incomingChannel, this.closeable);
} }
......
...@@ -164,7 +164,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?> ...@@ -164,7 +164,7 @@ public class AnnotationsPropertySource extends EnumerablePropertySource<Class<?>
private String dotAppend(String prefix, String postfix) { private String dotAppend(String prefix, String postfix) {
if (StringUtils.hasText(prefix)) { if (StringUtils.hasText(prefix)) {
return (prefix.endsWith(".") ? prefix + postfix : prefix + "." + postfix); return prefix.endsWith(".") ? prefix + postfix : prefix + "." + postfix;
} }
return postfix; return postfix;
} }
......
...@@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq ...@@ -991,7 +991,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
} }
try { try {
return JSONCompare.compareJSON( return JSONCompare.compareJSON(
((expectedJson != null) ? expectedJson.toString() : null), (expectedJson != null) ? expectedJson.toString() : null,
this.actual.toString(), compareMode); this.actual.toString(), compareMode);
} }
catch (Exception ex) { catch (Exception ex) {
...@@ -1009,7 +1009,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq ...@@ -1009,7 +1009,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
} }
try { try {
return JSONCompare.compareJSON( return JSONCompare.compareJSON(
((expectedJson != null) ? expectedJson.toString() : null), (expectedJson != null) ? expectedJson.toString() : null,
this.actual.toString(), comparator); this.actual.toString(), comparator);
} }
catch (Exception ex) { catch (Exception ex) {
...@@ -1054,7 +1054,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq ...@@ -1054,7 +1054,7 @@ public class JsonContentAssert extends AbstractAssert<JsonContentAssert, CharSeq
JsonPathValue(CharSequence expression, Object... args) { JsonPathValue(CharSequence expression, Object... args) {
org.springframework.util.Assert.hasText( org.springframework.util.Assert.hasText(
((expression != null) ? expression.toString() : null), (expression != null) ? expression.toString() : null,
"expression must not be null or empty"); "expression must not be null or empty");
this.expression = String.format(expression.toString(), args); this.expression = String.format(expression.toString(), args);
this.jsonPath = JsonPath.compile(this.expression); this.jsonPath = JsonPath.compile(this.expression);
......
...@@ -178,7 +178,7 @@ class JsonReader { ...@@ -178,7 +178,7 @@ class JsonReader {
.setReplacement(deprecationJsonObject.optString("replacement", null)); .setReplacement(deprecationJsonObject.optString("replacement", null));
return deprecation; return deprecation;
} }
return (object.optBoolean("deprecated") ? new Deprecation() : null); return object.optBoolean("deprecated") ? new Deprecation() : null;
} }
private Deprecation.Level parseDeprecationLevel(String value) { private Deprecation.Level parseDeprecationLevel(String value) {
......
...@@ -302,7 +302,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor ...@@ -302,7 +302,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
|| isDeprecated(source); || isDeprecated(source);
this.metadataCollector.add(ItemMetadata.newProperty(prefix, name, this.metadataCollector.add(ItemMetadata.newProperty(prefix, name,
dataType, sourceType, null, description, defaultValue, dataType, sourceType, null, description, defaultValue,
(deprecated ? getItemDeprecation(getter) : null))); deprecated ? getItemDeprecation(getter) : null));
} }
}); });
} }
...@@ -344,7 +344,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor ...@@ -344,7 +344,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
boolean deprecated = isDeprecated(field) || isDeprecated(source); boolean deprecated = isDeprecated(field) || isDeprecated(source);
this.metadataCollector.add(ItemMetadata.newProperty(prefix, name, this.metadataCollector.add(ItemMetadata.newProperty(prefix, name,
dataType, sourceType, null, description, defaultValue, dataType, sourceType, null, description, defaultValue,
(deprecated ? new ItemDeprecation() : null))); deprecated ? new ItemDeprecation() : null));
} }
}); });
} }
......
...@@ -111,7 +111,7 @@ public class JsonMarshaller { ...@@ -111,7 +111,7 @@ public class JsonMarshaller {
.setReplacement(deprecationJsonObject.optString("replacement", null)); .setReplacement(deprecationJsonObject.optString("replacement", null));
return deprecation; return deprecation;
} }
return (object.optBoolean("deprecated") ? new ItemDeprecation() : null); return object.optBoolean("deprecated") ? new ItemDeprecation() : null;
} }
private ItemHint toItemHint(JSONObject object) throws Exception { private ItemHint toItemHint(JSONObject object) throws Exception {
......
...@@ -43,7 +43,7 @@ public class JavaExecutable { ...@@ -43,7 +43,7 @@ public class JavaExecutable {
private File findInJavaHome(String javaHome) { private File findInJavaHome(String javaHome) {
File bin = new File(new File(javaHome), "bin"); File bin = new File(new File(javaHome), "bin");
File command = new File(bin, "java.exe"); File command = new File(bin, "java.exe");
command = (command.exists() ? command : new File(bin, "java")); command = command.exists() ? command : new File(bin, "java");
Assert.state(command.exists(), () -> "Unable to find java in " + javaHome); Assert.state(command.exists(), () -> "Unable to find java in " + javaHome);
return command; return command;
} }
......
...@@ -304,7 +304,7 @@ public class PropertiesLauncher extends Launcher { ...@@ -304,7 +304,7 @@ public class PropertiesLauncher extends Launcher {
for (String path : commaSeparatedPaths.split(",")) { for (String path : commaSeparatedPaths.split(",")) {
path = cleanupPath(path); path = cleanupPath(path);
// "" means the user wants root of archive but not current directory // "" means the user wants root of archive but not current directory
path = ("".equals(path) ? "/" : path); path = "".equals(path) ? "/" : path;
paths.add(path); paths.add(path);
} }
if (paths.isEmpty()) { if (paths.isEmpty()) {
......
...@@ -124,8 +124,8 @@ public class Handler extends URLStreamHandler { ...@@ -124,8 +124,8 @@ public class Handler extends URLStreamHandler {
private void log(boolean warning, String message, Exception cause) { private void log(boolean warning, String message, Exception cause) {
try { try {
Logger.getLogger(getClass().getName()) Level level = warning ? Level.WARNING : Level.FINEST;
.log((warning ? Level.WARNING : Level.FINEST), message, cause); Logger.getLogger(getClass().getName()).log(level, message, cause);
} }
catch (Exception ex) { catch (Exception ex) {
if (warning) { if (warning) {
......
...@@ -214,7 +214,7 @@ final class JarURLConnection extends java.net.JarURLConnection { ...@@ -214,7 +214,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
@Override @Override
public Object getContent() throws IOException { public Object getContent() throws IOException {
connect(); connect();
return (this.jarEntryName.isEmpty() ? this.jarFile : super.getContent()); return this.jarEntryName.isEmpty() ? this.jarFile : super.getContent();
} }
@Override @Override
...@@ -386,7 +386,7 @@ final class JarURLConnection extends java.net.JarURLConnection { ...@@ -386,7 +386,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
private String deduceContentType() { private String deduceContentType() {
// Guess the content type, don't bother with streams as mark is not supported // Guess the content type, don't bother with streams as mark is not supported
String type = (isEmpty() ? "x-java/jar" : null); String type = isEmpty() ? "x-java/jar" : null;
type = (type != null) ? type : guessContentTypeFromName(toString()); type = (type != null) ? type : guessContentTypeFromName(toString());
type = (type != null) ? type : "content/unknown"; type = (type != null) ? type : "content/unknown";
return type; return type;
......
...@@ -200,7 +200,7 @@ public class ImageBanner implements Banner { ...@@ -200,7 +200,7 @@ public class ImageBanner implements Banner {
private void printBanner(BufferedImage image, int margin, boolean invert, private void printBanner(BufferedImage image, int margin, boolean invert,
PrintStream out) { PrintStream out) {
AnsiElement background = (invert ? AnsiBackground.BLACK : AnsiBackground.DEFAULT); AnsiElement background = invert ? AnsiBackground.BLACK : AnsiBackground.DEFAULT;
out.print(AnsiOutput.encode(AnsiColor.DEFAULT)); out.print(AnsiOutput.encode(AnsiColor.DEFAULT));
out.print(AnsiOutput.encode(background)); out.print(AnsiOutput.encode(background));
out.println(); out.println();
......
...@@ -119,7 +119,7 @@ public class ResourceBanner implements Banner { ...@@ -119,7 +119,7 @@ public class ResourceBanner implements Banner {
if (version == null) { if (version == null) {
return ""; return "";
} }
return (format ? " (v" + version + ")" : version); return format ? " (v" + version + ")" : version;
} }
private PropertyResolver getAnsiResolver() { private PropertyResolver getAnsiResolver() {
......
...@@ -99,7 +99,7 @@ class SpringApplicationBannerPrinter { ...@@ -99,7 +99,7 @@ class SpringApplicationBannerPrinter {
String location = environment.getProperty(BANNER_IMAGE_LOCATION_PROPERTY); String location = environment.getProperty(BANNER_IMAGE_LOCATION_PROPERTY);
if (StringUtils.hasLength(location)) { if (StringUtils.hasLength(location)) {
Resource resource = this.resourceLoader.getResource(location); Resource resource = this.resourceLoader.getResource(location);
return (resource.exists() ? new ImageBanner(resource) : null); return resource.exists() ? new ImageBanner(resource) : null;
} }
for (String ext : IMAGE_EXTENSION) { for (String ext : IMAGE_EXTENSION) {
Resource resource = this.resourceLoader.getResource("banner." + ext); Resource resource = this.resourceLoader.getResource("banner." + ext);
......
...@@ -66,7 +66,7 @@ public class ContextIdApplicationContextInitializer implements ...@@ -66,7 +66,7 @@ public class ContextIdApplicationContextInitializer implements
private String getApplicationId(ConfigurableEnvironment environment) { private String getApplicationId(ConfigurableEnvironment environment) {
String name = environment.getProperty("spring.application.name"); String name = environment.getProperty("spring.application.name");
return (StringUtils.hasText(name) ? name : "application"); return StringUtils.hasText(name) ? name : "application";
} }
/** /**
......
...@@ -445,7 +445,7 @@ public class ConfigFileApplicationListener ...@@ -445,7 +445,7 @@ public class ConfigFileApplicationListener
DocumentConsumer consumer) { DocumentConsumer consumer) {
getSearchLocations().forEach((location) -> { getSearchLocations().forEach((location) -> {
boolean isFolder = location.endsWith("/"); boolean isFolder = location.endsWith("/");
Set<String> names = (isFolder ? getSearchNames() : NO_SEARCH_NAMES); Set<String> names = isFolder ? getSearchNames() : NO_SEARCH_NAMES;
names.forEach( names.forEach(
(name) -> load(location, name, profile, filterFactory, consumer)); (name) -> load(location, name, profile, filterFactory, consumer));
}); });
......
...@@ -310,7 +310,7 @@ public class LoggingApplicationListener implements GenericApplicationListener { ...@@ -310,7 +310,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
private void setLogLevel(LoggingSystem system, String name, String level) { private void setLogLevel(LoggingSystem system, String name, String level) {
try { try {
name = (name.equalsIgnoreCase(LoggingSystem.ROOT_LOGGER_NAME) ? null : name); name = name.equalsIgnoreCase(LoggingSystem.ROOT_LOGGER_NAME) ? null : name;
system.setLogLevel(name, coerceLogLevel(level)); system.setLogLevel(name, coerceLogLevel(level));
} }
catch (RuntimeException ex) { catch (RuntimeException ex) {
......
...@@ -71,7 +71,7 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> { ...@@ -71,7 +71,7 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
} }
new EntryBinder(name, resolvedTarget, elementBinder).bindEntries(source, map); new EntryBinder(name, resolvedTarget, elementBinder).bindEntries(source, map);
} }
return (map.isEmpty() ? null : map); return map.isEmpty() ? null : map;
} }
private Bindable<?> resolveTarget(Bindable<?> target) { private Bindable<?> resolveTarget(Bindable<?> target) {
......
...@@ -319,17 +319,17 @@ public final class ConfigurationPropertyName ...@@ -319,17 +319,17 @@ public final class ConfigurationPropertyName
int l1 = e1.length(); int l1 = e1.length();
int l2 = e2.length(); int l2 = e2.length();
boolean indexed1 = isIndexed(e1); boolean indexed1 = isIndexed(e1);
int offset1 = (indexed1 ? 1 : 0); int offset1 = indexed1 ? 1 : 0;
boolean indexed2 = isIndexed(e2); boolean indexed2 = isIndexed(e2);
int offset2 = (indexed2 ? 1 : 0); int offset2 = indexed2 ? 1 : 0;
int i1 = offset1; int i1 = offset1;
int i2 = offset2; int i2 = offset2;
while (i1 < l1 - offset1) { while (i1 < l1 - offset1) {
if (i2 >= l2 - offset2) { if (i2 >= l2 - offset2) {
return false; return false;
} }
char ch1 = (indexed1 ? e1.charAt(i1) : Character.toLowerCase(e1.charAt(i1))); char ch1 = indexed1 ? e1.charAt(i1) : Character.toLowerCase(e1.charAt(i1));
char ch2 = (indexed2 ? e2.charAt(i2) : Character.toLowerCase(e2.charAt(i2))); char ch2 = indexed2 ? e2.charAt(i2) : Character.toLowerCase(e2.charAt(i2));
if (ch1 == '-' || ch1 == '_') { if (ch1 == '-' || ch1 == '_') {
i1++; i1++;
} }
...@@ -372,7 +372,7 @@ public final class ConfigurationPropertyName ...@@ -372,7 +372,7 @@ public final class ConfigurationPropertyName
private int getElementHashCode(CharSequence element) { private int getElementHashCode(CharSequence element) {
int hash = 0; int hash = 0;
boolean indexed = isIndexed(element); boolean indexed = isIndexed(element);
int offset = (indexed ? 1 : 0); int offset = indexed ? 1 : 0;
for (int i = 0 + offset; i < element.length() - offset; i++) { for (int i = 0 + offset; i < element.length() - offset; i++) {
char ch = (indexed ? element.charAt(i) char ch = (indexed ? element.charAt(i)
: Character.toLowerCase(element.charAt(i))); : Character.toLowerCase(element.charAt(i)));
......
...@@ -44,7 +44,7 @@ class FilteredConfigurationPropertiesSource implements ConfigurationPropertySour ...@@ -44,7 +44,7 @@ class FilteredConfigurationPropertiesSource implements ConfigurationPropertySour
public ConfigurationProperty getConfigurationProperty( public ConfigurationProperty getConfigurationProperty(
ConfigurationPropertyName name) { ConfigurationPropertyName name) {
boolean filtered = getFilter().test(name); boolean filtered = getFilter().test(name);
return (filtered ? getSource().getConfigurationProperty(name) : null); return filtered ? getSource().getConfigurationProperty(name) : null;
} }
@Override @Override
......
...@@ -100,7 +100,7 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper { ...@@ -100,7 +100,7 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper {
private CharSequence processElementValue(CharSequence value) { private CharSequence processElementValue(CharSequence value) {
String result = value.toString().toLowerCase(Locale.ENGLISH); String result = value.toString().toLowerCase(Locale.ENGLISH);
return (isNumber(result) ? "[" + result + "]" : result); return isNumber(result) ? "[" + result + "]" : result;
} }
private static boolean isNumber(String string) { private static boolean isNumber(String string) {
......
...@@ -140,7 +140,7 @@ public class ApplicationHome { ...@@ -140,7 +140,7 @@ public class ApplicationHome {
if (homeDir.isFile()) { if (homeDir.isFile()) {
homeDir = homeDir.getParentFile(); homeDir = homeDir.getParentFile();
} }
homeDir = (homeDir.exists() ? homeDir : new File(".")); homeDir = homeDir.exists() ? homeDir : new File(".");
return homeDir.getAbsoluteFile(); return homeDir.getAbsoluteFile();
} }
......
...@@ -67,7 +67,7 @@ public class ServerPortInfoApplicationContextInitializer ...@@ -67,7 +67,7 @@ public class ServerPortInfoApplicationContextInitializer
private String getName(WebServerApplicationContext context) { private String getName(WebServerApplicationContext context) {
String name = context.getServerNamespace(); String name = context.getServerNamespace();
return (StringUtils.hasText(name) ? name : "server"); return StringUtils.hasText(name) ? name : "server";
} }
private void setPortProperty(ApplicationContext context, String propertyName, private void setPortProperty(ApplicationContext context, String propertyName,
......
...@@ -320,7 +320,7 @@ public class TomcatWebServer implements WebServer { ...@@ -320,7 +320,7 @@ public class TomcatWebServer implements WebServer {
StringBuilder ports = new StringBuilder(); StringBuilder ports = new StringBuilder();
for (Connector connector : this.tomcat.getService().findConnectors()) { for (Connector connector : this.tomcat.getService().findConnectors()) {
ports.append((ports.length() != 0) ? " " : ""); ports.append((ports.length() != 0) ? " " : "");
int port = (localPort ? connector.getLocalPort() : connector.getPort()); int port = localPort ? connector.getLocalPort() : connector.getPort();
ports.append(port + " (" + connector.getScheme() + ")"); ports.append(port + " (" + connector.getScheme() + ")");
} }
return ports.toString(); return ports.toString();
......
...@@ -169,7 +169,7 @@ public class ServletContextInitializerBeans ...@@ -169,7 +169,7 @@ public class ServletContextInitializerBeans
private MultipartConfigElement getMultipartConfig(ListableBeanFactory beanFactory) { private MultipartConfigElement getMultipartConfig(ListableBeanFactory beanFactory) {
List<Entry<String, MultipartConfigElement>> beans = getOrderedBeansOfType( List<Entry<String, MultipartConfigElement>> beans = getOrderedBeansOfType(
beanFactory, MultipartConfigElement.class); beanFactory, MultipartConfigElement.class);
return (beans.isEmpty() ? null : beans.get(0).getValue()); return beans.isEmpty() ? null : beans.get(0).getValue();
} }
private <T> void addAsRegistrationBean(ListableBeanFactory beanFactory, Class<T> type, private <T> void addAsRegistrationBean(ListableBeanFactory beanFactory, Class<T> type,
......
...@@ -712,7 +712,7 @@ public abstract class AbstractServletWebServerFactoryTests { ...@@ -712,7 +712,7 @@ public abstract class AbstractServletWebServerFactoryTests {
} }
private String getStoreType(String keyStore) { private String getStoreType(String keyStore) {
return (keyStore.endsWith(".p12") ? "pkcs12" : null); return keyStore.endsWith(".p12") ? "pkcs12" : null;
} }
@Test @Test
......
...@@ -42,7 +42,7 @@ public class ChatService { ...@@ -42,7 +42,7 @@ public class ChatService {
@Disconnect @Disconnect
public void onDisconnect(AtmosphereResourceEvent event) { public void onDisconnect(AtmosphereResourceEvent event) {
this.logger.info("Client {} disconnected [{}]", event.getResource().uuid(), this.logger.info("Client {} disconnected [{}]", event.getResource().uuid(),
(event.isCancelled() ? "cancelled" : "closed")); event.isCancelled() ? "cancelled" : "closed");
} }
@org.atmosphere.config.service.Message(encoders = JacksonEncoderDecoder.class, decoders = JacksonEncoderDecoder.class) @org.atmosphere.config.service.Message(encoders = JacksonEncoderDecoder.class, decoders = JacksonEncoderDecoder.class)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment