Polish empty string checks

See gh-23550
This commit is contained in:
Santhoshkumar. P
2020-10-01 08:21:49 +05:30
committed by Stephane Nicoll
parent 294af45bb3
commit 5cb07e292d
8 changed files with 11 additions and 10 deletions

View File

@@ -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(" ")) {