Merge pull request #10451 from dreis2211:string-is-empty

* pr/10451:
  Replace some String.length() checks with String.isEmpty()
pull/10450/merge
Stephane Nicoll 7 years ago
commit 157db9a4de

@ -66,7 +66,7 @@ class DefaultEndpointObjectNameFactory implements EndpointObjectNameFactory {
private boolean hasMBean(String baseObjectName) throws MalformedObjectNameException {
ObjectName query = new ObjectName(baseObjectName + ",*");
return this.mBeanServer.queryNames(query, null).size() > 0;
return !this.mBeanServer.queryNames(query, null).isEmpty();
}
private String getStaticNames() {

@ -117,7 +117,7 @@ class ResourceMatcher {
value = value.substring(1);
minus.add(value);
}
else if (value.trim().length() > 0) {
else if (!value.trim().isEmpty()) {
result.add(value);
}
}

@ -57,7 +57,7 @@ public class HintCommand extends AbstractCommand {
if (index == 0) {
showCommandHints(starting);
}
else if (!arguments.isEmpty() && (starting.length() > 0)) {
else if (!arguments.isEmpty() && !starting.isEmpty()) {
String command = arguments.remove(0);
showCommandOptionHints(command, Collections.unmodifiableList(arguments),
starting);

@ -113,7 +113,7 @@ public class MockRestServiceServerAutoConfiguration {
private RequestExpectationManager getDelegate() {
Map<RestTemplate, RequestExpectationManager> expectationManagers = this.customizer
.getExpectationManagers();
Assert.state(expectationManagers.size() > 0,
Assert.state(!expectationManagers.isEmpty(),
"Unable to use auto-configured MockRestServiceServer since "
+ "MockServerRestTemplateCustomizer has not been bound to "
+ "a RestTemplate");

@ -63,7 +63,7 @@ final class SpringBootConfigurationFinder {
}
private Class<?> scanPackage(String source) {
while (source.length() > 0) {
while (!source.isEmpty()) {
Set<BeanDefinition> components = this.scanner.findCandidateComponents(source);
if (!components.isEmpty()) {
Assert.state(components.size() == 1,

@ -98,7 +98,7 @@ public class MockServerRestTemplateCustomizer implements RestTemplateCustomizer
}
public MockRestServiceServer getServer() {
Assert.state(this.servers.size() > 0,
Assert.state(!this.servers.isEmpty(),
"Unable to return a single MockRestServiceServer since "
+ "MockServerRestTemplateCustomizer has not been bound to "
+ "a RestTemplate");

@ -88,7 +88,7 @@ class RawConfigurationMetadata {
}
private static boolean hasLength(String string) {
return (string != null && string.length() > 0);
return (string != null && !string.isEmpty());
}
}

@ -63,7 +63,7 @@ class UnresolvedDependenciesAnalyzer {
private boolean hasNoVersion(ModuleVersionSelector selector) {
String version = selector.getVersion();
return version == null || version.trim().length() == 0;
return version == null || version.trim().isEmpty();
}
}

@ -255,7 +255,7 @@ public class JarWriter implements LoaderClassesWriter, AutoCloseable {
}
if (parent.lastIndexOf("/") != -1) {
parent = parent.substring(0, parent.lastIndexOf("/") + 1);
if (parent.length() > 0) {
if (!parent.isEmpty()) {
writeEntry(new JarArchiveEntry(parent), null);
}
}

@ -201,7 +201,7 @@ public abstract class AbstractRunMojo extends AbstractDependencyFilterMojo {
}
private boolean hasJvmArgs() {
return (this.jvmArguments != null && this.jvmArguments.length() > 0);
return (this.jvmArguments != null && !this.jvmArguments.isEmpty());
}
private boolean hasWorkingDirectorySet() {

@ -225,7 +225,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
private File getTargetFile() {
String classifier = (this.classifier == null ? "" : this.classifier.trim());
if (classifier.length() > 0 && !classifier.startsWith("-")) {
if (!classifier.isEmpty() && !classifier.startsWith("-")) {
classifier = "-" + classifier;
}
if (!this.outputDirectory.exists()) {
@ -292,7 +292,7 @@ public class RepackageMojo extends AbstractDependencyFilterMojo {
String... valueCandidates) {
if (!properties.containsKey(key)) {
for (String candidate : valueCandidates) {
if (candidate != null && candidate.length() > 0) {
if (candidate != null && !candidate.isEmpty()) {
properties.put(key, candidate);
return;
}

@ -93,14 +93,14 @@ public class BasicJsonParser implements JsonParser {
}
private static String trimTrailingCharacter(String string, char c) {
if (string.length() > 0 && string.charAt(string.length() - 1) == c) {
if (!string.isEmpty() && string.charAt(string.length() - 1) == c) {
return string.substring(0, string.length() - 1);
}
return string;
}
private static String trimLeadingCharacter(String string, char c) {
if (string.length() > 0 && string.charAt(0) == c) {
if (!string.isEmpty() && string.charAt(0) == c) {
return string.substring(1);
}
return string;

@ -125,7 +125,7 @@ public abstract class AbstractServletWebServerFactory
private void checkContextPath(String contextPath) {
Assert.notNull(contextPath, "ContextPath must not be null");
if (contextPath.length() > 0) {
if (!contextPath.isEmpty()) {
if ("/".equals(contextPath)) {
throw new IllegalArgumentException(
"Root ContextPath must be specified using an empty string");

Loading…
Cancel
Save