Commit 5cb07e29 authored by Santhoshkumar. P's avatar Santhoshkumar. P Committed by Stephane Nicoll

Polish empty string checks

See gh-23550
parent 294af45b
...@@ -290,7 +290,7 @@ public class RabbitProperties { ...@@ -290,7 +290,7 @@ public class RabbitProperties {
} }
public void setVirtualHost(String virtualHost) { public void setVirtualHost(String virtualHost) {
this.virtualHost = "".equals(virtualHost) ? "/" : virtualHost; this.virtualHost = StringUtils.hasLength(virtualHost) ? virtualHost : "/";
} }
public AddressShuffleMode getAddressShuffleMode() { public AddressShuffleMode getAddressShuffleMode() {
......
...@@ -33,6 +33,7 @@ import jline.console.completer.StringsCompleter; ...@@ -33,6 +33,7 @@ import jline.console.completer.StringsCompleter;
import org.springframework.boot.cli.command.Command; import org.springframework.boot.cli.command.Command;
import org.springframework.boot.cli.command.options.OptionHelp; import org.springframework.boot.cli.command.options.OptionHelp;
import org.springframework.boot.cli.util.Log; import org.springframework.boot.cli.util.Log;
import org.springframework.util.StringUtils;
/** /**
* JLine {@link Completer} for Spring Boot {@link Command}s. * JLine {@link Completer} for Spring Boot {@link Command}s.
...@@ -74,7 +75,7 @@ public class CommandCompleter extends StringsCompleter { ...@@ -74,7 +75,7 @@ public class CommandCompleter extends StringsCompleter {
int completionIndex = super.complete(buffer, cursor, candidates); int completionIndex = super.complete(buffer, cursor, candidates);
int spaceIndex = buffer.indexOf(' '); int spaceIndex = buffer.indexOf(' ');
String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : ""); String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : "");
if (!"".equals(commandName.trim())) { if (StringUtils.hasText(commandName)) {
for (Command command : this.commands) { for (Command command : this.commands) {
if (command.getName().equals(commandName)) { if (command.getName().equals(commandName)) {
if (cursor == buffer.length() && buffer.endsWith(" ")) { if (cursor == buffer.length() && buffer.endsWith(" ")) {
......
...@@ -298,7 +298,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor ...@@ -298,7 +298,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private void processEndpoint(AnnotationMirror annotation, TypeElement element) { private void processEndpoint(AnnotationMirror annotation, TypeElement element) {
Map<String, Object> elementValues = this.metadataEnv.getAnnotationElementValues(annotation); Map<String, Object> elementValues = this.metadataEnv.getAnnotationElementValues(annotation);
String endpointId = (String) elementValues.get("id"); String endpointId = (String) elementValues.get("id");
if (endpointId == null || "".equals(endpointId)) { if (endpointId == null || endpointId.isEmpty()) {
return; // Can't process that endpoint return; // Can't process that endpoint
} }
String endpointKey = ItemMetadata.newItemMetadataPrefix("management.endpoint.", endpointId); String endpointKey = ItemMetadata.newItemMetadataPrefix("management.endpoint.", endpointId);
......
...@@ -180,8 +180,8 @@ class MetadataGenerationEnvironment { ...@@ -180,8 +180,8 @@ class MetadataGenerationEnvironment {
reason = (String) elementValues.get("reason"); reason = (String) elementValues.get("reason");
replacement = (String) elementValues.get("replacement"); replacement = (String) elementValues.get("replacement");
} }
reason = "".equals(reason) ? null : reason; reason = (reason == null || reason.isEmpty()) ? null : reason;
replacement = "".equals(replacement) ? null : replacement; replacement = (replacement == null || replacement.isEmpty()) ? null : replacement;
return new ItemDeprecation(reason, replacement); return new ItemDeprecation(reason, replacement);
} }
......
...@@ -180,7 +180,7 @@ class TypeUtils { ...@@ -180,7 +180,7 @@ class TypeUtils {
if (javadoc != null) { if (javadoc != null) {
javadoc = NEW_LINE_PATTERN.matcher(javadoc).replaceAll("").trim(); javadoc = NEW_LINE_PATTERN.matcher(javadoc).replaceAll("").trim();
} }
return "".equals(javadoc) ? null : javadoc; return (javadoc == null || javadoc.isEmpty()) ? null : javadoc;
} }
/** /**
......
...@@ -171,7 +171,7 @@ public class ConfigurationMetadata { ...@@ -171,7 +171,7 @@ public class ConfigurationMetadata {
public static String nestedPrefix(String prefix, String name) { public static String nestedPrefix(String prefix, String name) {
String nestedPrefix = (prefix != null) ? prefix : ""; String nestedPrefix = (prefix != null) ? prefix : "";
String dashedName = toDashedCase(name); String dashedName = toDashedCase(name);
nestedPrefix += "".equals(nestedPrefix) ? dashedName : "." + dashedName; nestedPrefix += (nestedPrefix == null || nestedPrefix.isEmpty()) ? dashedName : "." + dashedName;
return nestedPrefix; return nestedPrefix;
} }
......
...@@ -316,7 +316,7 @@ public class PropertiesLauncher extends Launcher { ...@@ -316,7 +316,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 = (path == null || path.isEmpty()) ? "/" : path;
paths.add(path); paths.add(path);
} }
if (paths.isEmpty()) { if (paths.isEmpty()) {
...@@ -631,7 +631,7 @@ public class PropertiesLauncher extends Launcher { ...@@ -631,7 +631,7 @@ public class PropertiesLauncher extends Launcher {
} }
EntryFilter filter = new PrefixMatchingArchiveFilter(root); EntryFilter filter = new PrefixMatchingArchiveFilter(root);
List<Archive> archives = asList(parent.getNestedArchives(null, filter)); List<Archive> archives = asList(parent.getNestedArchives(null, filter));
if (("".equals(root) || ".".equals(root)) && !path.endsWith(".jar") if ((root == null || root.isEmpty() || ".".equals(root)) && !path.endsWith(".jar")
&& parent != PropertiesLauncher.this.parent) { && parent != PropertiesLauncher.this.parent) {
// You can't find the root with an entry filter so it has to be added // You can't find the root with an entry filter so it has to be added
// explicitly. But don't add the root of the parent archive. // explicitly. But don't add the root of the parent archive.
......
...@@ -413,7 +413,7 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J ...@@ -413,7 +413,7 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J
public static void registerUrlProtocolHandler() { public static void registerUrlProtocolHandler() {
String handlers = System.getProperty(PROTOCOL_HANDLER, ""); String handlers = System.getProperty(PROTOCOL_HANDLER, "");
System.setProperty(PROTOCOL_HANDLER, System.setProperty(PROTOCOL_HANDLER,
("".equals(handlers) ? HANDLERS_PACKAGE : handlers + "|" + HANDLERS_PACKAGE)); ((handlers == null || handlers.isEmpty()) ? HANDLERS_PACKAGE : handlers + "|" + HANDLERS_PACKAGE));
resetCachedUrlHandlers(); resetCachedUrlHandlers();
} }
......
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