Browse Source

flip tests as the IDE was complaining that we werent handing null tokens properly

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@385804 13f79535-47bb-0310-9956-ffa450edef68
master
Steve Loughran 19 years ago
parent
commit
f26833969e
1 changed files with 30 additions and 6 deletions
  1. +30
    -6
      src/main/org/apache/tools/ant/Target.java

+ 30
- 6
src/main/org/apache/tools/ant/Target.java View File

@@ -128,7 +128,7 @@ public class Target implements TaskContainer {
String token = tok.nextToken().trim();

// Make sure the dependency is not empty string
if (token.equals("") || token.equals(",")) {
if ("".equals(token) || ",".equals(token)) {
throw new BuildException("Syntax Error: Depend "
+ "attribute for target \"" + getName()
+ "\" has an empty string for dependency.");
@@ -140,7 +140,7 @@ public class Target implements TaskContainer {
// end in a ,
if (tok.hasMoreTokens()) {
token = tok.nextToken();
if (!tok.hasMoreTokens() || !token.equals(",")) {
if (!tok.hasMoreTokens() || !",".equals(token)) {
throw new BuildException("Syntax Error: Depend "
+ "attribute for target \"" + getName()
+ "\" ends with a , character");
@@ -256,7 +256,7 @@ public class Target implements TaskContainer {
* no "if" test is performed.
*/
public void setIf(String property) {
this.ifCondition = (property == null) ? "" : property;
ifCondition = (property == null) ? "" : property;
}

/**
@@ -284,7 +284,7 @@ public class Target implements TaskContainer {
* no "unless" test is performed.
*/
public void setUnless(String property) {
this.unlessCondition = (property == null) ? "" : property;
unlessCondition = (property == null) ? "" : property;
}

/**
@@ -361,11 +361,11 @@ public class Target implements TaskContainer {
}
} else if (!testIfCondition()) {
project.log(this, "Skipped because property '"
+ project.replaceProperties(this.ifCondition)
+ project.replaceProperties(ifCondition)
+ "' not set.", Project.MSG_VERBOSE);
} else {
project.log(this, "Skipped because property '"
+ project.replaceProperties(this.unlessCondition)
+ project.replaceProperties(unlessCondition)
+ "' set.", Project.MSG_VERBOSE);
}
}
@@ -454,4 +454,28 @@ public class Target implements TaskContainer {
String test = project.replaceProperties(unlessCondition);
return project.getProperty(test) == null;
}

/**
* Equality check is based on target name
* @param that other thing to check
* @return true iff type and name are equal
*/
public boolean equals(Object that) {
if (this == that) return true;
if (that == null || getClass() != that.getClass()) return false;

final Target target = (Target) that;

if (name != null ? !name.equals(target.name) : target.name != null) return false;

return true;
}

/**
* Hash code is based on name, is 0 if the name==null
* @return hash code
*/
public int hashCode() {
return (name != null ? name.hashCode() : 0);
}
}

Loading…
Cancel
Save