This is an automated email from the ASF dual-hosted git repository.

sunlan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git


The following commit(s) were added to refs/heads/master by this push:
     new 06de65fcdf Trivial refactor: replace `size()` and `length()` with 
`isEmpty()`
06de65fcdf is described below

commit 06de65fcdf9d558a1df541da64b67f37fd0ec9ac
Author: Daniel Sun <sun...@apache.org>
AuthorDate: Sun Jun 1 00:18:30 2025 +0900

    Trivial refactor: replace `size()` and `length()` with `isEmpty()`
---
 .../src/main/java/org/codehaus/groovy/ant/Groovy.java    |  6 +++---
 .../src/main/java/org/codehaus/groovy/ant/Groovyc.java   |  2 +-
 .../main/java/org/codehaus/groovy/ant/RootLoaderRef.java |  2 +-
 .../groovy/console/ui/text/FindReplaceUtility.java       |  2 +-
 .../codehaus/groovy/tools/groovydoc/GroovyDocTool.java   |  9 ++++-----
 .../groovy/tools/groovydoc/GroovyRootDocBuilder.java     |  2 +-
 .../groovy/tools/groovydoc/SimpleGroovyClassDoc.java     |  2 +-
 .../tools/groovydoc/antlr4/GroovydocJavaVisitor.java     |  2 +-
 .../src/main/java/groovy/json/JsonSlurperClassic.java    |  4 ++--
 .../src/main/java/groovy/json/StreamingJsonBuilder.java  |  2 +-
 .../org/apache/groovy/json/internal/BaseJsonParser.java  |  2 +-
 .../codehaus/groovy/jsr223/GroovyScriptEngineImpl.java   |  2 +-
 .../groovy-sql/src/main/java/groovy/sql/DataSet.java     | 14 +++++++-------
 .../src/main/java/groovy/sql/ExtractIndexAndSql.java     |  4 ++--
 .../main/java/groovy/sql/ResultSetMetaDataWrapper.java   |  2 +-
 .../src/main/groovy/groovy/text/XmlTemplateEngine.java   |  2 +-
 .../src/main/java/groovy/test/AllTestSuite.java          |  4 ++--
 .../src/main/java/groovy/xml/MarkupBuilder.java          |  2 +-
 .../groovy-xml/src/main/java/groovy/xml/Namespace.java   | 10 +++++-----
 .../src/main/java/groovy/xml/XmlNodePrinter.java         |  4 ++--
 .../groovy-xml/src/main/java/groovy/xml/XmlParser.java   |  8 ++++----
 .../src/main/java/groovy/xml/dom/DOMCategory.java        |  6 +++---
 .../main/java/groovy/xml/slurpersupport/Attributes.java  |  2 +-
 .../main/java/groovy/xml/slurpersupport/GPathResult.java |  2 +-
 .../src/main/java/groovy/xml/slurpersupport/Node.java    |  6 +++---
 .../java/org/apache/groovy/xml/tools/DomToGroovy.java    | 16 ++++++++--------
 26 files changed, 59 insertions(+), 60 deletions(-)

diff --git 
a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java 
b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
index 19850d0686..077fded670 100644
--- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
+++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovy.java
@@ -358,7 +358,7 @@ public class Groovy extends Java {
             }
         }
 
-        if (src == null && command.length() == 0) {
+        if (src == null && command.isEmpty()) {
             throw new BuildException("Source does not exist!", getLocation());
         }
 
@@ -381,7 +381,7 @@ public class Groovy extends Java {
 
                 // if there are no groovy statements between the enclosing 
Groovy tags
                 // then read groovy statements in from a resource using the 
src attribute
-                if (command == null || command.trim().length() == 0) {
+                if (command == null || command.trim().isEmpty()) {
                     Reader reader;
                     if (src instanceof FileResource) {
                         File file = ((FileResource) src).getFile();
@@ -726,7 +726,7 @@ public class Groovy extends Java {
             return fr.getFile().getAbsolutePath();
         } else {
             String name = PREFIX;
-            if (getLocation().getFileName().length() > 0)
+            if (!getLocation().getFileName().isEmpty())
                 name += getLocation().getFileName().replaceAll("[^\\w_\\.]", 
"_").replaceAll("[\\.]", "_dot_");
             else
                 name += SUFFIX;
diff --git 
a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java 
b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
index c891d4db90..af5aaafb14 100644
--- a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
+++ b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/Groovyc.java
@@ -942,7 +942,7 @@ public class Groovyc extends MatchingTask {
         if (src == null) {
             throw new BuildException("srcdir attribute must be set!", 
getLocation());
         }
-        if (src.size() == 0) {
+        if (src.isEmpty()) {
             throw new BuildException("srcdir attribute must be set!", 
getLocation());
         }
 
diff --git 
a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/RootLoaderRef.java
 
b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/RootLoaderRef.java
index 377e4d00d3..c87dbfd0eb 100644
--- 
a/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/RootLoaderRef.java
+++ 
b/subprojects/groovy-ant/src/main/java/org/codehaus/groovy/ant/RootLoaderRef.java
@@ -69,7 +69,7 @@ public class RootLoaderRef extends MatchingTask {
 
     @Override
     public void execute() throws BuildException {
-        if (taskClasspath == null || taskClasspath.size() == 0) {
+        if (taskClasspath == null || taskClasspath.isEmpty()) {
             throw new BuildException("no classpath given");
         }
         Project project = getProject();
diff --git 
a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/text/FindReplaceUtility.java
 
b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/text/FindReplaceUtility.java
index d76406d8a5..b3469098f4 100644
--- 
a/subprojects/groovy-console/src/main/groovy/groovy/console/ui/text/FindReplaceUtility.java
+++ 
b/subprojects/groovy-console/src/main/groovy/groovy/console/ui/text/FindReplaceUtility.java
@@ -258,7 +258,7 @@ public final class FindReplaceUtility {
         backwards = backwards ? !reverse : reverse;
 
         String pattern = (String) FIND_FIELD.getSelectedItem();
-        if (pattern != null && pattern.length() > 0) {
+        if (pattern != null && !pattern.isEmpty()) {
             try {
                 Document doc = textComponent.getDocument();
                 doc.getText(0, doc.getLength(), SEGMENT);
diff --git 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocTool.java
 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocTool.java
index 30848e900d..1574e957e2 100644
--- 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocTool.java
+++ 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyDocTool.java
@@ -30,7 +30,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
 import java.util.Properties;
-import java.util.function.Predicate;
 
 public class GroovyDocTool {
     private final Logger log = Logger.create(GroovyDocTool.class);
@@ -74,11 +73,11 @@ public class GroovyDocTool {
         String fileEncoding = properties.getProperty("fileEncoding");
         String charset = properties.getProperty("charset");
 
-        if (fileEncoding == null || fileEncoding.length() == 0) fileEncoding = 
charset;
-        if (charset == null || charset.length() == 0) charset = fileEncoding;
+        if (fileEncoding == null || fileEncoding.isEmpty()) fileEncoding = 
charset;
+        if (charset == null || charset.isEmpty()) charset = fileEncoding;
 
-        properties.setProperty("fileEncoding", fileEncoding != null && 
fileEncoding.length() != 0 ? fileEncoding : defaultCharset);
-        properties.setProperty("charset", charset != null && charset.length() 
!= 0 ? charset : defaultCharset);
+        properties.setProperty("fileEncoding", fileEncoding != null && 
!fileEncoding.isEmpty() ? fileEncoding : defaultCharset);
+        properties.setProperty("charset", charset != null && 
!charset.isEmpty() ? charset : defaultCharset);
 
         this.properties = properties;
 
diff --git 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyRootDocBuilder.java
 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyRootDocBuilder.java
index 9fb9023772..3fc2f47ef5 100644
--- 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyRootDocBuilder.java
+++ 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/GroovyRootDocBuilder.java
@@ -91,7 +91,7 @@ public class GroovyRootDocBuilder {
 
     private void setOverview() {
         String path = properties.getProperty("overviewFile");
-        if (path != null && path.length() > 0) {
+        if (path != null && !path.isEmpty()) {
             try {
                 String content = ResourceGroovyMethods.getText(new File(path));
                 calcThenSetOverviewDescription(content);
diff --git 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
index f6fa781e7e..16fe347ae3 100644
--- 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
+++ 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/SimpleGroovyClassDoc.java
@@ -560,7 +560,7 @@ public class SimpleGroovyClassDoc extends 
SimpleGroovyAbstractableElementDoc imp
     }
 
     private static String buildUrl(String relativeRoot, String[] target, 
String shortClassName) {
-        if (relativeRoot.length() > 0 && !relativeRoot.endsWith("/")) {
+        if (!relativeRoot.isEmpty() && !relativeRoot.endsWith("/")) {
             relativeRoot += "/";
         }
         String url = relativeRoot + target[0].replace('.', '/').replace('$', 
'.') + ".html" + (target.length > 1 ? "#" + target[1] : "");
diff --git 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/antlr4/GroovydocJavaVisitor.java
 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/antlr4/GroovydocJavaVisitor.java
index dc40233634..2592cd3cee 100644
--- 
a/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/antlr4/GroovydocJavaVisitor.java
+++ 
b/subprojects/groovy-groovydoc/src/main/java/org/codehaus/groovy/tools/groovydoc/antlr4/GroovydocJavaVisitor.java
@@ -189,7 +189,7 @@ public class GroovydocJavaVisitor extends 
VoidVisitorAdapter<Object> {
     }
 
     private String genericTypesAsString(NodeList<TypeParameter> 
typeParameters) {
-        if (typeParameters == null || typeParameters.size() == 0)
+        if (typeParameters == null || typeParameters.isEmpty())
             return "";
         return "<" + DefaultGroovyMethods.join(typeParameters, ", ") + ">";
     }
diff --git 
a/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurperClassic.java 
b/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurperClassic.java
index 667f67af42..2e92714a08 100644
--- a/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurperClassic.java
+++ b/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurperClassic.java
@@ -69,7 +69,7 @@ public class JsonSlurperClassic {
      * @return a data structure of lists and maps
      */
     public Object parseText(String text) {
-        if (text == null || text.length() == 0) {
+        if (text == null || text.isEmpty()) {
             throw new IllegalArgumentException("The JSON input text should 
neither be null nor empty.");
         }
 
@@ -131,7 +131,7 @@ public class JsonSlurperClassic {
     private Object parseFile(File file, String charset) {
         Reader reader = null;
         try {
-            if (charset == null || charset.length() == 0) {
+            if (charset == null || charset.isEmpty()) {
                 reader = ResourceGroovyMethods.newReader(file);
             } else {
                 reader = ResourceGroovyMethods.newReader(file, charset);
diff --git 
a/subprojects/groovy-json/src/main/java/groovy/json/StreamingJsonBuilder.java 
b/subprojects/groovy-json/src/main/java/groovy/json/StreamingJsonBuilder.java
index ca666c871b..7d442490ce 100644
--- 
a/subprojects/groovy-json/src/main/java/groovy/json/StreamingJsonBuilder.java
+++ 
b/subprojects/groovy-json/src/main/java/groovy/json/StreamingJsonBuilder.java
@@ -386,7 +386,7 @@ public class StreamingJsonBuilder extends 
GroovyObjectSupport {
             writer.write(JsonOutput.COLON);
             writer.write(generator.toJson(value));
         }
-        StreamingJsonDelegate.cloneDelegateAndGetContent(writer, callable, 
map.size() == 0, generator);
+        StreamingJsonDelegate.cloneDelegateAndGetContent(writer, callable, 
map.isEmpty(), generator);
         writer.write(DOUBLE_CLOSE_BRACKET);
     }
 
diff --git 
a/subprojects/groovy-json/src/main/java/org/apache/groovy/json/internal/BaseJsonParser.java
 
b/subprojects/groovy-json/src/main/java/org/apache/groovy/json/internal/BaseJsonParser.java
index 7f08659bec..5744225308 100644
--- 
a/subprojects/groovy-json/src/main/java/org/apache/groovy/json/internal/BaseJsonParser.java
+++ 
b/subprojects/groovy-json/src/main/java/org/apache/groovy/json/internal/BaseJsonParser.java
@@ -157,7 +157,7 @@ public abstract class BaseJsonParser implements JsonParser {
     public Object parse(File file, String charset) {
         Reader reader = null;
         try {
-            if (charset == null || charset.length() == 0) {
+            if (charset == null || charset.isEmpty()) {
                 reader = ResourceGroovyMethods.newReader(file);
             } else {
                 reader = ResourceGroovyMethods.newReader(file, charset);
diff --git 
a/subprojects/groovy-jsr223/src/main/java/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java
 
b/subprojects/groovy-jsr223/src/main/java/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java
index 12107b4ab2..35b60442b7 100644
--- 
a/subprojects/groovy-jsr223/src/main/java/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java
+++ 
b/subprojects/groovy-jsr223/src/main/java/org/codehaus/groovy/jsr223/GroovyScriptEngineImpl.java
@@ -143,7 +143,7 @@ public class GroovyScriptEngineImpl extends 
AbstractScriptEngine implements Comp
         try {
             String val = (String) 
ctx.getAttribute("#jsr223.groovy.engine.keep.globals", 
ScriptContext.ENGINE_SCOPE);
             ReferenceBundle bundle = ReferenceBundle.getHardBundle();
-            if (val != null && val.length() > 0) {
+            if (val != null && !val.isEmpty()) {
                 if ("soft".equalsIgnoreCase(val)) {
                     bundle = ReferenceBundle.getSoftBundle();
                 } else if ("weak".equalsIgnoreCase(val)) {
diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java 
b/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
index e2198eefa1..42b6017651 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/DataSet.java
@@ -363,8 +363,8 @@ public class DataSet extends Sql {
         if (where != null) {
             whereClaus += getSqlWhereVisitor().getWhere();
         }
-        if (parentClaus.length() == 0) return whereClaus;
-        if (whereClaus.length() == 0) return parentClaus;
+        if (parentClaus.isEmpty()) return whereClaus;
+        if (whereClaus.isEmpty()) return parentClaus;
         return parentClaus + " and " + whereClaus;
     }
 
@@ -375,13 +375,13 @@ public class DataSet extends Sql {
             parentClaus = parent.getSqlOrderBy();
         }
         if (reversed) {
-            if (parentClaus.length() > 0) parentClaus += " DESC";
+            if (!parentClaus.isEmpty()) parentClaus += " DESC";
         }
         if (sort != null) {
             sortByClaus += getSqlOrderByVisitor().getOrderBy();
         }
-        if (parentClaus.length() == 0) return sortByClaus;
-        if (sortByClaus.length() == 0) return parentClaus;
+        if (parentClaus.isEmpty()) return sortByClaus;
+        if (sortByClaus.isEmpty()) return parentClaus;
         return parentClaus + ", " + sortByClaus;
     }
 
@@ -389,11 +389,11 @@ public class DataSet extends Sql {
         if (sql == null) {
             sql = "select * from " + table;
             String whereClaus = getSqlWhere();
-            if (whereClaus.length() > 0) {
+            if (!whereClaus.isEmpty()) {
                 sql += " where " + whereClaus;
             }
             String orderByClaus = getSqlOrderBy();
-            if (orderByClaus.length() > 0) {
+            if (!orderByClaus.isEmpty()) {
                 sql += " order by " + orderByClaus;
             }
         }
diff --git 
a/subprojects/groovy-sql/src/main/java/groovy/sql/ExtractIndexAndSql.java 
b/subprojects/groovy-sql/src/main/java/groovy/sql/ExtractIndexAndSql.java
index 17656b03b8..df88743938 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/ExtractIndexAndSql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/ExtractIndexAndSql.java
@@ -194,10 +194,10 @@ class ExtractIndexAndSql {
             newSql.append(sql, txtIndex, matcher.start()).append('?');
             String indexStr = matcher.group(1);
             if (indexStr == null) indexStr = matcher.group(3);
-            int index = (indexStr == null || indexStr.length() == 0 || 
":".equals(indexStr)) ? 0 : Integer.parseInt(indexStr) - 1;
+            int index = (indexStr == null || indexStr.isEmpty() || 
":".equals(indexStr)) ? 0 : Integer.parseInt(indexStr) - 1;
             String prop = matcher.group(2);
             if (prop == null) prop = matcher.group(4);
-            indexPropList.add(new Tuple<Object>(index, prop == null || 
prop.length() == 0 ? "<this>" : prop));
+            indexPropList.add(new Tuple<Object>(index, prop == null || 
prop.isEmpty() ? "<this>" : prop));
             txtIndex = matcher.end();
         }
         newSql.append(sql, txtIndex, sql.length()); // append ending SQL after 
last param.
diff --git 
a/subprojects/groovy-sql/src/main/java/groovy/sql/ResultSetMetaDataWrapper.java 
b/subprojects/groovy-sql/src/main/java/groovy/sql/ResultSetMetaDataWrapper.java
index b73360f54b..2512d9e333 100644
--- 
a/subprojects/groovy-sql/src/main/java/groovy/sql/ResultSetMetaDataWrapper.java
+++ 
b/subprojects/groovy-sql/src/main/java/groovy/sql/ResultSetMetaDataWrapper.java
@@ -67,7 +67,7 @@ public class ResultSetMetaDataWrapper extends 
GroovyObjectSupport {
     }
 
     private String getPropertyGetterName(String prop) {
-        if (prop == null || prop.length() < 1) {
+        if (prop == null || prop.isEmpty()) {
             throw new MissingPropertyException(prop, target.getClass());
         }
         return "get" + prop.substring(0, 1).toUpperCase() + prop.substring(1);
diff --git 
a/subprojects/groovy-templates/src/main/groovy/groovy/text/XmlTemplateEngine.java
 
b/subprojects/groovy-templates/src/main/groovy/groovy/text/XmlTemplateEngine.java
index 5c5172a595..7eb165ded9 100644
--- 
a/subprojects/groovy-templates/src/main/groovy/groovy/text/XmlTemplateEngine.java
+++ 
b/subprojects/groovy-templates/src/main/groovy/groovy/text/XmlTemplateEngine.java
@@ -244,7 +244,7 @@ public class XmlTemplateEngine extends TemplateEngine {
                 // check uri and for legacy cases just check prefix name (not 
recommended)
                 if 
("http://groovy.codehaus.org/2005/gsp".equals(qn.getNamespaceURI()) || 
"gsp".equals(qn.getPrefix())) {
                     String s = qn.getLocalPart();
-                    if (s.length() == 0) {
+                    if (s.isEmpty()) {
                         throw new RuntimeException("No local part after 'gsp:' 
given in node " + node);
                     }
                     printGroovyTag(s, node.text());
diff --git 
a/subprojects/groovy-test/src/main/java/groovy/test/AllTestSuite.java 
b/subprojects/groovy-test/src/main/java/groovy/test/AllTestSuite.java
index 46e31b2a43..bb6b46444b 100644
--- a/subprojects/groovy-test/src/main/java/groovy/test/AllTestSuite.java
+++ b/subprojects/groovy-test/src/main/java/groovy/test/AllTestSuite.java
@@ -24,8 +24,8 @@ import groovy.util.IFileNameFinder;
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.codehaus.groovy.control.CompilationFailedException;
 import org.apache.groovy.test.ScriptTestAdapter;
+import org.codehaus.groovy.control.CompilationFailedException;
 
 import java.io.File;
 import java.io.IOException;
@@ -108,7 +108,7 @@ public class AllTestSuite extends TestSuite {
 
     public static Test suite(String basedir, String pattern, String 
excludesPattern) {
         AllTestSuite suite = new AllTestSuite();
-        List<String> filenames = excludesPattern.length() > 0
+        List<String> filenames = !excludesPattern.isEmpty()
                 ? finder.getFileNames(basedir, pattern, excludesPattern)
                 : finder.getFileNames(basedir, pattern);
         for (String filename : filenames) {
diff --git a/subprojects/groovy-xml/src/main/java/groovy/xml/MarkupBuilder.java 
b/subprojects/groovy-xml/src/main/java/groovy/xml/MarkupBuilder.java
index 6a58e082b0..1acc9d9d4b 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/MarkupBuilder.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/MarkupBuilder.java
@@ -327,7 +327,7 @@ public class MarkupBuilder extends BuilderSupport {
             Object attributeValue = entry.getValue();
             boolean skipNull = attributeValue == null && omitNullAttributes;
             boolean skipEmpty = attributeValue != null && omitEmptyAttributes 
&&
-                    attributeValue.toString().length() == 0;
+                    attributeValue.toString().isEmpty();
             if (!skipNull && !skipEmpty) {
                 out.print(" ");
                 // Output the attribute name,
diff --git a/subprojects/groovy-xml/src/main/java/groovy/xml/Namespace.java 
b/subprojects/groovy-xml/src/main/java/groovy/xml/Namespace.java
index db97a5079f..51a594cde2 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/Namespace.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/Namespace.java
@@ -22,7 +22,7 @@ import groovy.namespace.QName;
 
 /**
  * A simple helper class which acts as a factory of {@link QName} instances.
- * 
+ *
  */
 public class Namespace {
 
@@ -43,12 +43,12 @@ public class Namespace {
 
     /**
      * Returns the QName for the given localName.
-     * 
+     *
      * @param localName
      *            the local name within this
      */
     public QName get(String localName) {
-        if (uri != null && uri.length() > 0) {
+        if (uri != null && !uri.isEmpty()) {
             if (prefix != null) {
                 return new QName(uri, localName, prefix);
             }
@@ -63,7 +63,7 @@ public class Namespace {
 
     /**
      * Returns the prefix mapped to this namespace
-     * 
+     *
      * @return the prefix assigned to this namespace or null if no namespace is
      *         mapped.
      */
@@ -73,7 +73,7 @@ public class Namespace {
 
     /**
      * Returns the URI of this namespace
-     * 
+     *
      * @return the URI of this namespace
      */
     public String getUri() {
diff --git 
a/subprojects/groovy-xml/src/main/java/groovy/xml/XmlNodePrinter.java 
b/subprojects/groovy-xml/src/main/java/groovy/xml/XmlNodePrinter.java
index d7bd9885cf..9225a2fcab 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/XmlNodePrinter.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/XmlNodePrinter.java
@@ -303,7 +303,7 @@ public class XmlNodePrinter {
                         ctx.registerNamespacePrefix(prefix, namespaceUri);
                         out.print(" ");
                         out.print("xmlns");
-                        if (prefix.length() > 0) {
+                        if (!prefix.isEmpty()) {
                             out.print(":");
                             out.print(prefix);
                         }
@@ -344,7 +344,7 @@ public class XmlNodePrinter {
         if (!node.children().isEmpty()) {
             return false;
         }
-        return node.text().length() == 0;
+        return node.text().isEmpty();
     }
 
     protected String getName(Object object) {
diff --git a/subprojects/groovy-xml/src/main/java/groovy/xml/XmlParser.java 
b/subprojects/groovy-xml/src/main/java/groovy/xml/XmlParser.java
index 2f678c4c01..e8fdb5417d 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/XmlParser.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/XmlParser.java
@@ -457,9 +457,9 @@ public class XmlParser implements ContentHandler {
         String text = bodyText.toString();
         if (!trimWhitespace && keepIgnorableWhitespace) {
             parent.children().add(text);
-        } else if (!trimWhitespace && text.trim().length() > 0) {
+        } else if (!trimWhitespace && !text.trim().isEmpty()) {
             parent.children().add(text);
-        } else if (text.trim().length() > 0) {
+        } else if (!text.trim().isEmpty()) {
             parent.children().add(text.trim());
         }
         bodyText = new StringBuilder();
@@ -492,13 +492,13 @@ public class XmlParser implements ContentHandler {
     protected Object getElementName(String namespaceURI, String localName, 
String qName) {
         String name = localName;
         String prefix = "";
-        if ((name == null) || (name.length() < 1)) {
+        if ((name == null) || (name.isEmpty())) {
             name = qName;
         }
         if (namespaceURI == null || namespaceURI.length() <= 0) {
             return name;
         }
-        if (qName != null && qName.length() > 0 && namespaceAware) {
+        if (qName != null && !qName.isEmpty() && namespaceAware) {
             int index = qName.lastIndexOf(':');
             if (index > 0) {
                 prefix = qName.substring(0, index);
diff --git 
a/subprojects/groovy-xml/src/main/java/groovy/xml/dom/DOMCategory.java 
b/subprojects/groovy-xml/src/main/java/groovy/xml/dom/DOMCategory.java
index ad07dc9a28..fe44186178 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/dom/DOMCategory.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/dom/DOMCategory.java
@@ -21,8 +21,8 @@ package groovy.xml.dom;
 import groovy.lang.Closure;
 import groovy.lang.GroovyRuntimeException;
 import groovy.lang.IntRange;
-import groovy.xml.DOMBuilder;
 import groovy.namespace.QName;
+import groovy.xml.DOMBuilder;
 import org.apache.groovy.xml.extensions.XmlExtensions;
 import org.codehaus.groovy.runtime.InvokerHelper;
 import org.w3c.dom.Attr;
@@ -462,10 +462,10 @@ public class DOMCategory {
                 }
             } else if (node.getNodeType() == Node.TEXT_NODE) {
                 String value = node.getNodeValue();
-                if ((!isGlobalKeepIgnorableWhitespace() && 
value.trim().length() == 0) || isGlobalTrimWhitespace()) {
+                if ((!isGlobalKeepIgnorableWhitespace() && 
value.trim().isEmpty()) || isGlobalTrimWhitespace()) {
                     value = value.trim();
                 }
-                if ("*".equals(elementName) && value.length() > 0) {
+                if ("*".equals(elementName) && !value.isEmpty()) {
                     node.setNodeValue(value);
                     result.add(node);
                 }
diff --git 
a/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/Attributes.java
 
b/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/Attributes.java
index bfb6a5ad93..e5d4ede762 100644
--- 
a/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/Attributes.java
+++ 
b/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/Attributes.java
@@ -83,7 +83,7 @@ public class Attributes extends NodeChildren {
                         String attributeKey = Attributes.this.attributeName;
                         if (Attributes.this.namespacePrefix != null &&
                                 !"*".equals(Attributes.this.namespacePrefix) &&
-                                Attributes.this.namespacePrefix.length() > 0) {
+                            !Attributes.this.namespacePrefix.isEmpty()) {
                             attributeKey = new 
QName(Attributes.this.lookupNamespace(Attributes.this.namespacePrefix), 
Attributes.this.attributeName).toString();
                         }
                         final String value = (String) ((Node) 
next).attributes().get(attributeKey);
diff --git 
a/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/GPathResult.java
 
b/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/GPathResult.java
index 5687294c94..7a46f07142 100644
--- 
a/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/GPathResult.java
+++ 
b/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/GPathResult.java
@@ -364,7 +364,7 @@ public abstract class GPathResult extends 
GroovyObjectSupport implements Writabl
 
     private boolean textIsEmptyOrNull() {
         String t = text();
-        return null == t || 0 == t.length();
+        return null == t || t.isEmpty();
     }
 
     /**
diff --git 
a/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/Node.java 
b/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/Node.java
index 69a59558a6..84c2687912 100644
--- a/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/Node.java
+++ b/subprojects/groovy-xml/src/main/java/groovy/xml/slurpersupport/Node.java
@@ -242,7 +242,7 @@ public class Node implements Writable {
                 }
             };
 
-            if (this.namespaceURI.length() == 0 && 
this.attributeNamespaces.isEmpty()) {
+            if (this.namespaceURI.isEmpty() && 
this.attributeNamespaces.isEmpty()) {
                 builder.invokeMethod(this.name, new Object[]{this.attributes, 
rest});
             } else {
                 final List newTags = new LinkedList();
@@ -292,11 +292,11 @@ public class Node implements Writable {
                 // we have to declare the namespace - choose a tag
                 tag = findNamespaceTag(local, namespaceURI);  // If the 
namespace has been declared in the GPath expression use that tag
 
-                if (tag == null || tag.length() == 0) {
+                if (tag == null || tag.isEmpty()) {
                     tag = findNamespaceTag(tagHints, namespaceURI);  // If the 
namespace has been used in the parse document use that tag
                 }
 
-                if (tag == null || tag.length() == 0) { // otherwise make up a 
new tag and check it has not been used before
+                if (tag == null || tag.isEmpty()) { // otherwise make up a new 
tag and check it has not been used before
                     int suffix = 0;
                     do {
                         final String possibleTag = "tag" + suffix++;
diff --git 
a/subprojects/groovy-xml/src/main/java/org/apache/groovy/xml/tools/DomToGroovy.java
 
b/subprojects/groovy-xml/src/main/java/org/apache/groovy/xml/tools/DomToGroovy.java
index 9cf8d7838d..5e5017ce55 100644
--- 
a/subprojects/groovy-xml/src/main/java/org/apache/groovy/xml/tools/DomToGroovy.java
+++ 
b/subprojects/groovy-xml/src/main/java/org/apache/groovy/xml/tools/DomToGroovy.java
@@ -153,7 +153,7 @@ public class DomToGroovy {
         printIndent();
 
         String prefix = element.getPrefix();
-        boolean hasPrefix = prefix != null && prefix.length() > 0;
+        boolean hasPrefix = prefix != null && !prefix.isEmpty();
         String localName = getLocalName(element);
         boolean isKeyword = checkEscaping(localName);
         if (isKeyword || hasPrefix) print(qt);
@@ -229,7 +229,7 @@ public class DomToGroovy {
 
     protected void printComment(Comment comment, boolean endWithComma) {
         String text = comment.getData().trim();
-        if (text.length() >0) {
+        if (!text.isEmpty()) {
             printIndent();
             print("/* ");
             print(text);
@@ -239,7 +239,7 @@ public class DomToGroovy {
 
     protected void printText(Text node, boolean endWithComma) {
         String text = getTextNodeData(node);
-        if (text.length() > 0) {
+        if (!text.isEmpty()) {
             printIndent();
             if (inMixed) print("mkp.yield ");
             printQuoted(text);
@@ -254,7 +254,7 @@ public class DomToGroovy {
     protected Map defineNamespaces(Element element, Map namespaces) {
         Map answer = null;
         String prefix = element.getPrefix();
-        if (prefix != null && prefix.length() > 0 && 
!namespaces.containsKey(prefix)) {
+        if (prefix != null && !prefix.isEmpty() && 
!namespaces.containsKey(prefix)) {
             answer = new HashMap(namespaces);
             defineNamespace(answer, prefix, element.getNamespaceURI());
         }
@@ -263,7 +263,7 @@ public class DomToGroovy {
         for (int i = 0; i < length; i++) {
             Attr attribute = (Attr) attributes.item(i);
             prefix = attribute.getPrefix();
-            if (prefix != null && prefix.length() > 0 && 
!namespaces.containsKey(prefix)) {
+            if (prefix != null && !prefix.isEmpty() && 
!namespaces.containsKey(prefix)) {
                 if (answer == null) {
                     answer = new HashMap(namespaces);
                 }
@@ -310,7 +310,7 @@ public class DomToGroovy {
 
     protected void printAttributeWithPrefix(Attr attribute, StringBuffer 
buffer) {
         String prefix = attribute.getPrefix();
-        if (prefix != null && prefix.length() > 0 && !"xmlns".equals(prefix)) {
+        if (prefix != null && !prefix.isEmpty() && !"xmlns".equals(prefix)) {
             if (buffer.length() > 0) {
                 buffer.append(", ");
             }
@@ -330,7 +330,7 @@ public class DomToGroovy {
 
     protected boolean printAttributeWithoutPrefix(Attr attribute, boolean 
hasAttribute) {
         String prefix = attribute.getPrefix();
-        if (prefix == null || prefix.length() == 0) {
+        if (prefix == null || prefix.isEmpty()) {
             if (!hasAttribute) {
                 hasAttribute = true;
             } else {
@@ -364,7 +364,7 @@ public class DomToGroovy {
                 hasElement = true;
             } else if (node instanceof Text) {
                 String text = getTextNodeData((Text) node);
-                if (text.length() > 0) {
+                if (!text.isEmpty()) {
                     hasText = true;
                 }
             }

Reply via email to