Use isEmpty() where possible

See gh-20370
This commit is contained in:
dreis2211 2020-03-02 20:36:46 +01:00 committed by Stephane Nicoll
parent 4598680692
commit 9588188800
7 changed files with 13 additions and 13 deletions

View File

@ -60,7 +60,7 @@ class PluginXmlParser {
private String textAt(String path, Node source) throws XPathExpressionException { private String textAt(String path, Node source) throws XPathExpressionException {
String text = this.xpath.evaluate(path + "/text()", source); String text = this.xpath.evaluate(path + "/text()", source);
return (text.length() == 0) ? null : text; return text.isEmpty() ? null : text;
} }
private List<Mojo> parseMojos(Node plugin) throws XPathExpressionException { private List<Mojo> parseMojos(Node plugin) throws XPathExpressionException {
@ -81,12 +81,12 @@ class PluginXmlParser {
Map<String, String> userProperties = new HashMap<>(); Map<String, String> userProperties = new HashMap<>();
for (Node parameterConfigurationNode : nodesAt("configuration/*", mojoNode)) { for (Node parameterConfigurationNode : nodesAt("configuration/*", mojoNode)) {
String userProperty = parameterConfigurationNode.getTextContent(); String userProperty = parameterConfigurationNode.getTextContent();
if (userProperty != null && userProperty.length() > 0) { if (userProperty != null && !userProperty.isEmpty()) {
userProperties.put(parameterConfigurationNode.getNodeName(), userProperties.put(parameterConfigurationNode.getNodeName(),
userProperty.replace("${", "`").replace("}", "`")); userProperty.replace("${", "`").replace("}", "`"));
} }
Node defaultValueAttribute = parameterConfigurationNode.getAttributes().getNamedItem("default-value"); Node defaultValueAttribute = parameterConfigurationNode.getAttributes().getNamedItem("default-value");
if (defaultValueAttribute != null && defaultValueAttribute.getTextContent().length() > 0) { if (defaultValueAttribute != null && !defaultValueAttribute.getTextContent().isEmpty()) {
defaultValues.put(parameterConfigurationNode.getNodeName(), defaultValueAttribute.getTextContent()); defaultValues.put(parameterConfigurationNode.getNodeName(), defaultValueAttribute.getTextContent());
} }
} }

View File

@ -63,7 +63,7 @@ public class TotalProgressBar implements Consumer<TotalProgressEvent> {
public TotalProgressBar(String prefix, char progressChar, boolean bookend, PrintStream out) { public TotalProgressBar(String prefix, char progressChar, boolean bookend, PrintStream out) {
this.progressChar = progressChar; this.progressChar = progressChar;
this.bookend = bookend; this.bookend = bookend;
if (prefix != null && prefix.length() > 0) { if (prefix != null && !prefix.isEmpty()) {
out.print(prefix); out.print(prefix);
out.print(" "); out.print(" ");
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -154,7 +154,7 @@ class TypeUtils {
if (((TypeElement) this.types.asElement(type)).getQualifiedName().contentEquals(Collection.class.getName())) { if (((TypeElement) this.types.asElement(type)).getQualifiedName().contentEquals(Collection.class.getName())) {
DeclaredType declaredType = (DeclaredType) type; DeclaredType declaredType = (DeclaredType) type;
// raw type, just "Collection" // raw type, just "Collection"
if (declaredType.getTypeArguments().size() == 0) { if (declaredType.getTypeArguments().isEmpty()) {
return this.types.getDeclaredType(this.env.getElementUtils().getTypeElement(Object.class.getName())); return this.types.getDeclaredType(this.env.getElementUtils().getTypeElement(Object.class.getName()));
} }
// return type argument to Collection<...> // return type argument to Collection<...>

View File

@ -62,7 +62,7 @@ class Context {
return null; return null;
} }
String relativePath = sourcePath.substring(workingPath.length() + 1); String relativePath = sourcePath.substring(workingPath.length() + 1);
return (relativePath.length() > 0) ? relativePath : null; return !relativePath.isEmpty() ? relativePath : null;
} }
/** /**

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -162,7 +162,7 @@ public class AnsiPropertySource extends PropertySource<AnsiElement> {
return false; return false;
} }
} }
return postfix.length() > 0; return !postfix.isEmpty();
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -40,7 +40,7 @@ public class ProducerApplication implements ApplicationRunner {
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
this.serviceProperties.getInputDir().mkdirs(); this.serviceProperties.getInputDir().mkdirs();
if (args.getNonOptionArgs().size() > 0) { if (!args.getNonOptionArgs().isEmpty()) {
FileOutputStream stream = new FileOutputStream( FileOutputStream stream = new FileOutputStream(
new File(this.serviceProperties.getInputDir(), "data" + System.currentTimeMillis() + ".txt")); new File(this.serviceProperties.getInputDir(), "data" + System.currentTimeMillis() + ".txt"));
for (String arg : args.getNonOptionArgs()) { for (String arg : args.getNonOptionArgs()) {

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2012-2019 the original author or authors. * Copyright 2012-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -40,7 +40,7 @@ public class ProducerApplication implements ApplicationRunner {
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
this.serviceProperties.getInputDir().mkdirs(); this.serviceProperties.getInputDir().mkdirs();
if (args.getNonOptionArgs().size() > 0) { if (!args.getNonOptionArgs().isEmpty()) {
FileOutputStream stream = new FileOutputStream( FileOutputStream stream = new FileOutputStream(
new File(this.serviceProperties.getInputDir(), "data" + System.currentTimeMillis() + ".txt")); new File(this.serviceProperties.getInputDir(), "data" + System.currentTimeMillis() + ".txt"));
for (String arg : args.getNonOptionArgs()) { for (String arg : args.getNonOptionArgs()) {