Browse Source

Use the isEmpty method instead of comparing the value of size() to 0.

This closes #61 pull request at github/apache/ant repo
master
reudismam Jaikiran Pai 7 years ago
parent
commit
782ec74638
6 changed files with 7 additions and 7 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/ComponentHelper.java
  2. +1
    -1
      src/main/org/apache/tools/ant/Main.java
  3. +2
    -2
      src/main/org/apache/tools/ant/helper/AntXMLContext.java
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java
  5. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java
  6. +1
    -1
      src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java

+ 1
- 1
src/main/org/apache/tools/ant/ComponentHelper.java View File

@@ -850,7 +850,7 @@ public class ComponentHelper {
} }
checkedNamespaces.add(uri); checkedNamespaces.add(uri);


if (antTypeTable.size() == 0) {
if (antTypeTable.isEmpty()) {
// Project instance doesn't know the tasks and types // Project instance doesn't know the tasks and types
// defined in defaults.properties, likely created by the // defined in defaults.properties, likely created by the
// user - without those definitions it cannot parse antlib // user - without those definitions it cannot parse antlib


+ 1
- 1
src/main/org/apache/tools/ant/Main.java View File

@@ -840,7 +840,7 @@ public class Main implements AntMain {
} }


// make sure that we have a target to execute // make sure that we have a target to execute
if (targets.size() == 0) {
if (targets.isEmpty()) {
if (project.getDefaultTarget() != null) { if (project.getDefaultTarget() != null) {
targets.addElement(project.getDefaultTarget()); targets.addElement(project.getDefaultTarget());
} }


+ 2
- 2
src/main/org/apache/tools/ant/helper/AntXMLContext.java View File

@@ -377,7 +377,7 @@ public class AntXMLContext {
*/ */
public void endPrefixMapping(String prefix) { public void endPrefixMapping(String prefix) {
List<String> list = prefixMapping.get(prefix); List<String> list = prefixMapping.get(prefix);
if (list == null || list.size() == 0) {
if (list == null || list.isEmpty()) {
return; // Should not happen return; // Should not happen
} }
list.remove(list.size() - 1); list.remove(list.size() - 1);
@@ -391,7 +391,7 @@ public class AntXMLContext {
*/ */
public String getPrefixMapping(String prefix) { public String getPrefixMapping(String prefix) {
List<String> list = prefixMapping.get(prefix); List<String> list = prefixMapping.get(prefix);
if (list == null || list.size() == 0) {
if (list == null || list.isEmpty()) {
return null; return null;
} }
return (String) list.get(list.size() - 1); return (String) list.get(list.size() - 1);


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/cvslib/CvsTagDiff.java View File

@@ -468,7 +468,7 @@ public class CvsTagDiff extends AbstractCvsTask {
* @exception BuildException if a parameter is not correctly set * @exception BuildException if a parameter is not correctly set
*/ */
private void validate() throws BuildException { private void validate() throws BuildException {
if (null == mypackage && getModules().size() == 0) {
if (null == mypackage && getModules().isEmpty()) {
throw new BuildException("Package/module must be set."); throw new BuildException("Package/module must be set.");
} }




+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/optional/XMLValidateTask.java View File

@@ -288,7 +288,7 @@ public class XMLValidateTask extends Task {
public void execute() throws BuildException { public void execute() throws BuildException {
try { try {
int fileProcessed = 0; int fileProcessed = 0;
if (file == null && (filesets.size() == 0)) {
if (file == null && (filesets.isEmpty())) {
throw new BuildException( throw new BuildException(
"Specify at least one source - " + "a file or a fileset."); "Specify at least one source - " + "a file or a fileset.");
} }


+ 1
- 1
src/tests/junit/org/apache/tools/ant/IntrospectionHelperTest.java View File

@@ -739,7 +739,7 @@ public class IntrospectionHelperTest {


public void addConfigured(Map m) { public void addConfigured(Map m) {
// Valid extension point // Valid extension point
assertTrue(m.size() == 0);
assertTrue(m.isEmpty());
} }


public void addConfigured(Hashtable h) { public void addConfigured(Hashtable h) {


Loading…
Cancel
Save