ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gin...@apache.org
Subject ant git commit: Use isEmpty() in tasks
Date Fri, 06 Apr 2018 18:40:19 GMT
Repository: ant
Updated Branches:
  refs/heads/master c3b91f90f -> 73bda1fb1


Use isEmpty() in tasks

Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/73bda1fb
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/73bda1fb
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/73bda1fb

Branch: refs/heads/master
Commit: 73bda1fb1795335156e6fc9dc8a539ab805bf20c
Parents: c3b91f9
Author: Gintas Grigelionis <gintas@apache.org>
Authored: Fri Apr 6 20:40:04 2018 +0200
Committer: Gintas Grigelionis <gintas@apache.org>
Committed: Fri Apr 6 20:40:04 2018 +0200

----------------------------------------------------------------------
 src/main/org/apache/tools/ant/taskdefs/Ant.java        |  6 +++---
 src/main/org/apache/tools/ant/taskdefs/Available.java  |  2 +-
 .../org/apache/tools/ant/taskdefs/BindTargets.java     |  2 +-
 .../org/apache/tools/ant/taskdefs/DefaultExcludes.java |  6 +++---
 src/main/org/apache/tools/ant/taskdefs/Echo.java       | 13 +++++--------
 src/main/org/apache/tools/ant/taskdefs/Jar.java        |  4 ++--
 src/main/org/apache/tools/ant/taskdefs/Javadoc.java    |  2 +-
 src/main/org/apache/tools/ant/taskdefs/Replace.java    |  4 ++--
 .../tools/ant/taskdefs/optional/ccm/Continuus.java     |  2 +-
 .../ant/taskdefs/optional/clearcase/ClearCase.java     |  2 +-
 .../apache/tools/ant/taskdefs/optional/net/FTP.java    |  2 +-
 .../tools/ant/taskdefs/optional/net/FTPTask.java       |  2 +-
 .../ant/taskdefs/optional/net/FTPTaskMirrorImpl.java   |  6 +++---
 13 files changed, 25 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/Ant.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java
index 064856a..7b89907 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Ant.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Ant.java
@@ -434,7 +434,7 @@ public class Ant extends Task {
             addReferences();
 
             if (!locals.isEmpty() && !(locals.size() == 1
-                                       && "".equals(locals.get(0)))) {
+                    && locals.get(0) != null && locals.get(0).isEmpty()))
{
                 BuildException be = null;
                 try {
                     log("Entering " + antFile + "...", Project.MSG_VERBOSE);
@@ -670,7 +670,7 @@ public class Ant extends Task {
      * @param targetToAdd the name of the target to invoke.
      */
     public void setTarget(String targetToAdd) {
-        if ("".equals(targetToAdd)) {
+        if (targetToAdd.isEmpty()) {
             throw new BuildException("target attribute must not be empty");
         }
         targets.add(targetToAdd);
@@ -720,7 +720,7 @@ public class Ant extends Task {
                 "nested target is incompatible with the target attribute");
         }
         String name = t.getName();
-        if ("".equals(name)) {
+        if (name.isEmpty()) {
             throw new BuildException("target name must not be empty");
         }
         targets.add(name);

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/Available.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java
index c1a3486..1a4f2b5 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Available.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Available.java
@@ -159,7 +159,7 @@ public class Available extends Task implements Condition {
      * @param classname the name of the class required.
      */
     public void setClassname(String classname) {
-        if (!"".equals(classname)) {
+        if (!classname.isEmpty()) {
             this.classname = classname;
         }
     }

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/BindTargets.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/BindTargets.java b/src/main/org/apache/tools/ant/taskdefs/BindTargets.java
index 3ac33f5..7beac61 100644
--- a/src/main/org/apache/tools/ant/taskdefs/BindTargets.java
+++ b/src/main/org/apache/tools/ant/taskdefs/BindTargets.java
@@ -65,7 +65,7 @@ public class BindTargets extends Task {
         }
 
         if (getOwningTarget() == null
-                || !"".equals(getOwningTarget().getName())) {
+                || getOwningTarget().getName().isEmpty()) {
             throw new BuildException("bindtargets only allowed as a top-level task");
         }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java b/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
index 45cdfc3..82b48eb 100644
--- a/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
+++ b/src/main/org/apache/tools/ant/taskdefs/DefaultExcludes.java
@@ -47,17 +47,17 @@ public class DefaultExcludes extends Task {
      */
     @Override
     public void execute() throws BuildException {
-        if (!defaultrequested && "".equals(add) && "".equals(remove) &&
!echo) {
+        if (!defaultrequested && add.isEmpty() && remove.isEmpty() &&
!echo) {
             throw new BuildException(
                 "<defaultexcludes> task must set at least one attribute (echo=\"false\"
doesn't count since that is the default");
         }
         if (defaultrequested) {
             DirectoryScanner.resetDefaultExcludes();
         }
-        if (!"".equals(add)) {
+        if (!add.isEmpty()) {
             DirectoryScanner.addDefaultExclude(add);
         }
-        if (!"".equals(remove)) {
+        if (!remove.isEmpty()) {
             DirectoryScanner.removeDefaultExclude(remove);
         }
         if (echo) {

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/Echo.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Echo.java b/src/main/org/apache/tools/ant/taskdefs/Echo.java
index f1e13c8..9d57b61 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Echo.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Echo.java
@@ -61,15 +61,12 @@ public class Echo extends Task {
      * @exception BuildException if something goes wrong with the build
      */
     public void execute() throws BuildException {
-        final String msg = "".equals(message) ? StringUtils.LINE_SEP : message;
         try {
-            ResourceUtils
-                    .copyResource(new StringResource(msg), output == null
-                                  ? new LogOutputResource(this, logLevel)
-                                  : output,
-                                  null, null, false, false, append, null,
-                                  "".equals(encoding) ? null : encoding,
-                                  getProject(), force);
+            ResourceUtils.copyResource(
+                    new StringResource(message.isEmpty() ? StringUtils.LINE_SEP : message),
+                    output == null ? new LogOutputResource(this, logLevel) : output,
+                    null, null, false, false, append, null,
+                    encoding.isEmpty() ? null : encoding, getProject(), force);
         } catch (IOException ioe) {
             throw new BuildException(ioe, getLocation());
         }

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/Jar.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java
index 437aaa3..02fe9e7 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Jar.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java
@@ -1108,9 +1108,9 @@ public class Jar extends Zip {
                 String name = resources[0][j].getName().replace('\\', '/');
                 if (rcs[i] instanceof ArchiveFileSet) {
                     ArchiveFileSet afs = (ArchiveFileSet) rcs[i];
-                    if (!"".equals(afs.getFullpath(getProject()))) {
+                    if (!afs.getFullpath(getProject()).isEmpty()) {
                         name = afs.getFullpath(getProject());
-                    } else if (!"".equals(afs.getPrefix(getProject()))) {
+                    } else if (!afs.getPrefix(getProject()).isEmpty()) {
                         String prefix = afs.getPrefix(getProject());
                         if (!prefix.endsWith("/") && !prefix.endsWith("\\")) {
                             prefix += "/";

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
index 4fc053e..1eb196a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java
@@ -2375,7 +2375,7 @@ public class Javadoc extends Task {
                         && name.equals("package.html")));
 
                 if (files.length > 0) {
-                    if ("".equals(dir)) {
+                    if (dir.isEmpty()) {
                         log(baseDir
                             + " contains source files in the default package, you must specify
them as source files not packages.",
                             Project.MSG_WARN);

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/Replace.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java
index 976211a..6da862d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Replace.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Replace.java
@@ -149,7 +149,7 @@ public class Replace extends MatchingTask {
                     "token is a mandatory for replacefilter.");
             }
 
-            if ("".equals(token.getText())) {
+            if (token.getText().isEmpty()) {
                 throw new BuildException(
                     "The token must not be an empty string.");
             }
@@ -586,7 +586,7 @@ public class Replace extends MatchingTask {
                 "Either token or a nested replacefilter must be specified",
                 getLocation());
         }
-        if (token != null && "".equals(token.getText())) {
+        if (token != null && token.getText().isEmpty()) {
             throw new BuildException(
                 "The token attribute must not be an empty string.",
                 getLocation());

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
index 869ed7f..a869a9a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/ccm/Continuus.java
@@ -103,7 +103,7 @@ public abstract class Continuus extends Task {
      */
     protected final String getCcmCommand() {
         String toReturn = ccmDir;
-        if (!"".equals(toReturn) && !toReturn.endsWith("/")) {
+        if (!toReturn.isEmpty() && !toReturn.endsWith("/")) {
             toReturn += "/";
         }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
index 8db603d..5771a0d 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/clearcase/ClearCase.java
@@ -128,7 +128,7 @@ public abstract class ClearCase extends Task {
      */
     protected final String getClearToolCommand() {
         String toReturn = mClearToolDir;
-        if (!"".equals(toReturn) && !toReturn.endsWith("/")) {
+        if (!toReturn.isEmpty() && !toReturn.endsWith("/")) {
             toReturn += "/";
         }
 

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
index dd485b6..75f82c0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java
@@ -2633,7 +2633,7 @@ public class FTP extends Task implements FTPTaskConfig {
          */
         public long getMilliseconds(int action) {
             String granularityU = getValue().toUpperCase(Locale.ENGLISH);
-            if ("".equals(granularityU)) {
+            if (granularityU.isEmpty()) {
                 if (action == SEND_FILES) {
                     return GRANULARITY_MINUTE;
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java
index 5b4081b..da7854f 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTask.java
@@ -941,7 +941,7 @@ public class FTPTask extends Task implements FTPTaskConfig {
          */
         public long getMilliseconds(int action) {
             String granularityU = getValue().toUpperCase(Locale.ENGLISH);
-            if ("".equals(granularityU)) {
+            if (granularityU.isEmpty()) {
                 if (action == SEND_FILES) {
                     return GRANULARITY_MINUTE;
                 }

http://git-wip-us.apache.org/repos/asf/ant/blob/73bda1fb/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
index 1e0b5f2..a0f3878 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/net/FTPTaskMirrorImpl.java
@@ -395,11 +395,11 @@ public class FTPTaskMirrorImpl implements FTPTaskMirror {
                     return;
                 }
                 String completePath;
-                if (!"".equals(vpath)) {
+                if (vpath.isEmpty()) {
+                    completePath = rootPath;
+                } else {
                     completePath = rootPath + task.getSeparator()
                         + vpath.replace(File.separatorChar, task.getSeparator().charAt(0));
-                } else {
-                    completePath = rootPath;
                 }
                 FTPFile[] newfiles = listFiles(completePath, false);
 


Mime
View raw message