Polish empty string checks

See gh-23550
pull/23590/head
Santhoshkumar. P 4 years ago committed by Stephane Nicoll
parent 294af45bb3
commit 5cb07e292d

@ -290,7 +290,7 @@ public class RabbitProperties {
}
public void setVirtualHost(String virtualHost) {
this.virtualHost = "".equals(virtualHost) ? "/" : virtualHost;
this.virtualHost = StringUtils.hasLength(virtualHost) ? virtualHost : "/";
}
public AddressShuffleMode getAddressShuffleMode() {

@ -33,6 +33,7 @@ import jline.console.completer.StringsCompleter;
import org.springframework.boot.cli.command.Command;
import org.springframework.boot.cli.command.options.OptionHelp;
import org.springframework.boot.cli.util.Log;
import org.springframework.util.StringUtils;
/**
* JLine {@link Completer} for Spring Boot {@link Command}s.
@ -74,7 +75,7 @@ public class CommandCompleter extends StringsCompleter {
int completionIndex = super.complete(buffer, cursor, candidates);
int spaceIndex = buffer.indexOf(' ');
String commandName = ((spaceIndex != -1) ? buffer.substring(0, spaceIndex) : "");
if (!"".equals(commandName.trim())) {
if (StringUtils.hasText(commandName)) {
for (Command command : this.commands) {
if (command.getName().equals(commandName)) {
if (cursor == buffer.length() && buffer.endsWith(" ")) {

@ -298,7 +298,7 @@ public class ConfigurationMetadataAnnotationProcessor extends AbstractProcessor
private void processEndpoint(AnnotationMirror annotation, TypeElement element) {
Map<String, Object> elementValues = this.metadataEnv.getAnnotationElementValues(annotation);
String endpointId = (String) elementValues.get("id");
if (endpointId == null || "".equals(endpointId)) {
if (endpointId == null || endpointId.isEmpty()) {
return; // Can't process that endpoint
}
String endpointKey = ItemMetadata.newItemMetadataPrefix("management.endpoint.", endpointId);

@ -180,8 +180,8 @@ class MetadataGenerationEnvironment {
reason = (String) elementValues.get("reason");
replacement = (String) elementValues.get("replacement");
}
reason = "".equals(reason) ? null : reason;
replacement = "".equals(replacement) ? null : replacement;
reason = (reason == null || reason.isEmpty()) ? null : reason;
replacement = (replacement == null || replacement.isEmpty()) ? null : replacement;
return new ItemDeprecation(reason, replacement);
}

@ -180,7 +180,7 @@ class TypeUtils {
if (javadoc != null) {
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 {
public static String nestedPrefix(String prefix, String name) {
String nestedPrefix = (prefix != null) ? prefix : "";
String dashedName = toDashedCase(name);
nestedPrefix += "".equals(nestedPrefix) ? dashedName : "." + dashedName;
nestedPrefix += (nestedPrefix == null || nestedPrefix.isEmpty()) ? dashedName : "." + dashedName;
return nestedPrefix;
}

@ -316,7 +316,7 @@ public class PropertiesLauncher extends Launcher {
for (String path : commaSeparatedPaths.split(",")) {
path = cleanupPath(path);
// "" means the user wants root of archive but not current directory
path = "".equals(path) ? "/" : path;
path = (path == null || path.isEmpty()) ? "/" : path;
paths.add(path);
}
if (paths.isEmpty()) {
@ -631,7 +631,7 @@ public class PropertiesLauncher extends Launcher {
}
EntryFilter filter = new PrefixMatchingArchiveFilter(root);
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) {
// 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.

@ -413,7 +413,7 @@ public class JarFile extends AbstractJarFile implements Iterable<java.util.jar.J
public static void registerUrlProtocolHandler() {
String handlers = System.getProperty(PROTOCOL_HANDLER, "");
System.setProperty(PROTOCOL_HANDLER,
("".equals(handlers) ? HANDLERS_PACKAGE : handlers + "|" + HANDLERS_PACKAGE));
((handlers == null || handlers.isEmpty()) ? HANDLERS_PACKAGE : handlers + "|" + HANDLERS_PACKAGE));
resetCachedUrlHandlers();
}

Loading…
Cancel
Save