Polish ternary expressions
This commit is contained in:
@@ -200,7 +200,7 @@ public class ImageBanner implements Banner {
|
||||
|
||||
private void printBanner(BufferedImage image, int margin, boolean invert,
|
||||
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(background));
|
||||
out.println();
|
||||
|
||||
@@ -119,7 +119,7 @@ public class ResourceBanner implements Banner {
|
||||
if (version == null) {
|
||||
return "";
|
||||
}
|
||||
return (format ? " (v" + version + ")" : version);
|
||||
return format ? " (v" + version + ")" : version;
|
||||
}
|
||||
|
||||
private PropertyResolver getAnsiResolver() {
|
||||
|
||||
@@ -99,7 +99,7 @@ class SpringApplicationBannerPrinter {
|
||||
String location = environment.getProperty(BANNER_IMAGE_LOCATION_PROPERTY);
|
||||
if (StringUtils.hasLength(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) {
|
||||
Resource resource = this.resourceLoader.getResource("banner." + ext);
|
||||
|
||||
@@ -66,7 +66,7 @@ public class ContextIdApplicationContextInitializer implements
|
||||
|
||||
private String getApplicationId(ConfigurableEnvironment environment) {
|
||||
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
|
||||
DocumentConsumer consumer) {
|
||||
getSearchLocations().forEach((location) -> {
|
||||
boolean isFolder = location.endsWith("/");
|
||||
Set<String> names = (isFolder ? getSearchNames() : NO_SEARCH_NAMES);
|
||||
Set<String> names = isFolder ? getSearchNames() : NO_SEARCH_NAMES;
|
||||
names.forEach(
|
||||
(name) -> load(location, name, profile, filterFactory, consumer));
|
||||
});
|
||||
|
||||
@@ -310,7 +310,7 @@ public class LoggingApplicationListener implements GenericApplicationListener {
|
||||
|
||||
private void setLogLevel(LoggingSystem system, String name, String level) {
|
||||
try {
|
||||
name = (name.equalsIgnoreCase(LoggingSystem.ROOT_LOGGER_NAME) ? null : name);
|
||||
name = name.equalsIgnoreCase(LoggingSystem.ROOT_LOGGER_NAME) ? null : name;
|
||||
system.setLogLevel(name, coerceLogLevel(level));
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
|
||||
@@ -71,7 +71,7 @@ class MapBinder extends AggregateBinder<Map<Object, Object>> {
|
||||
}
|
||||
new EntryBinder(name, resolvedTarget, elementBinder).bindEntries(source, map);
|
||||
}
|
||||
return (map.isEmpty() ? null : map);
|
||||
return map.isEmpty() ? null : map;
|
||||
}
|
||||
|
||||
private Bindable<?> resolveTarget(Bindable<?> target) {
|
||||
|
||||
@@ -319,17 +319,17 @@ public final class ConfigurationPropertyName
|
||||
int l1 = e1.length();
|
||||
int l2 = e2.length();
|
||||
boolean indexed1 = isIndexed(e1);
|
||||
int offset1 = (indexed1 ? 1 : 0);
|
||||
int offset1 = indexed1 ? 1 : 0;
|
||||
boolean indexed2 = isIndexed(e2);
|
||||
int offset2 = (indexed2 ? 1 : 0);
|
||||
int offset2 = indexed2 ? 1 : 0;
|
||||
int i1 = offset1;
|
||||
int i2 = offset2;
|
||||
while (i1 < l1 - offset1) {
|
||||
if (i2 >= l2 - offset2) {
|
||||
return false;
|
||||
}
|
||||
char ch1 = (indexed1 ? e1.charAt(i1) : Character.toLowerCase(e1.charAt(i1)));
|
||||
char ch2 = (indexed2 ? e2.charAt(i2) : Character.toLowerCase(e2.charAt(i2)));
|
||||
char ch1 = indexed1 ? e1.charAt(i1) : Character.toLowerCase(e1.charAt(i1));
|
||||
char ch2 = indexed2 ? e2.charAt(i2) : Character.toLowerCase(e2.charAt(i2));
|
||||
if (ch1 == '-' || ch1 == '_') {
|
||||
i1++;
|
||||
}
|
||||
@@ -372,7 +372,7 @@ public final class ConfigurationPropertyName
|
||||
private int getElementHashCode(CharSequence element) {
|
||||
int hash = 0;
|
||||
boolean indexed = isIndexed(element);
|
||||
int offset = (indexed ? 1 : 0);
|
||||
int offset = indexed ? 1 : 0;
|
||||
for (int i = 0 + offset; i < element.length() - offset; i++) {
|
||||
char ch = (indexed ? element.charAt(i)
|
||||
: Character.toLowerCase(element.charAt(i)));
|
||||
|
||||
@@ -44,7 +44,7 @@ class FilteredConfigurationPropertiesSource implements ConfigurationPropertySour
|
||||
public ConfigurationProperty getConfigurationProperty(
|
||||
ConfigurationPropertyName name) {
|
||||
boolean filtered = getFilter().test(name);
|
||||
return (filtered ? getSource().getConfigurationProperty(name) : null);
|
||||
return filtered ? getSource().getConfigurationProperty(name) : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -100,7 +100,7 @@ final class SystemEnvironmentPropertyMapper implements PropertyMapper {
|
||||
|
||||
private CharSequence processElementValue(CharSequence value) {
|
||||
String result = value.toString().toLowerCase(Locale.ENGLISH);
|
||||
return (isNumber(result) ? "[" + result + "]" : result);
|
||||
return isNumber(result) ? "[" + result + "]" : result;
|
||||
}
|
||||
|
||||
private static boolean isNumber(String string) {
|
||||
|
||||
@@ -140,7 +140,7 @@ public class ApplicationHome {
|
||||
if (homeDir.isFile()) {
|
||||
homeDir = homeDir.getParentFile();
|
||||
}
|
||||
homeDir = (homeDir.exists() ? homeDir : new File("."));
|
||||
homeDir = homeDir.exists() ? homeDir : new File(".");
|
||||
return homeDir.getAbsoluteFile();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class ServerPortInfoApplicationContextInitializer
|
||||
|
||||
private String getName(WebServerApplicationContext context) {
|
||||
String name = context.getServerNamespace();
|
||||
return (StringUtils.hasText(name) ? name : "server");
|
||||
return StringUtils.hasText(name) ? name : "server";
|
||||
}
|
||||
|
||||
private void setPortProperty(ApplicationContext context, String propertyName,
|
||||
|
||||
@@ -320,7 +320,7 @@ public class TomcatWebServer implements WebServer {
|
||||
StringBuilder ports = new StringBuilder();
|
||||
for (Connector connector : this.tomcat.getService().findConnectors()) {
|
||||
ports.append((ports.length() != 0) ? " " : "");
|
||||
int port = (localPort ? connector.getLocalPort() : connector.getPort());
|
||||
int port = localPort ? connector.getLocalPort() : connector.getPort();
|
||||
ports.append(port + " (" + connector.getScheme() + ")");
|
||||
}
|
||||
return ports.toString();
|
||||
|
||||
@@ -169,7 +169,7 @@ public class ServletContextInitializerBeans
|
||||
private MultipartConfigElement getMultipartConfig(ListableBeanFactory beanFactory) {
|
||||
List<Entry<String, MultipartConfigElement>> beans = getOrderedBeansOfType(
|
||||
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,
|
||||
|
||||
@@ -712,7 +712,7 @@ public abstract class AbstractServletWebServerFactoryTests {
|
||||
}
|
||||
|
||||
private String getStoreType(String keyStore) {
|
||||
return (keyStore.endsWith(".p12") ? "pkcs12" : null);
|
||||
return keyStore.endsWith(".p12") ? "pkcs12" : null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user