Browse Source

refine toString() and compareTo() methods

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278490 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 20 years ago
parent
commit
d788f76c8d
1 changed files with 2 additions and 15 deletions
  1. +2
    -15
      src/main/org/apache/tools/ant/types/Resource.java

+ 2
- 15
src/main/org/apache/tools/ant/types/Resource.java View File

@@ -269,16 +269,7 @@ public class Resource extends DataType
throw new IllegalArgumentException(
"Can only be compared with Resources");
}
Resource r = (Resource) other;
String name = getName();
String oname = r.getName();
if (name == null && oname == null) {
return 0;
}
if (name == null) {
return -1;
}
return oname == null ? 1 : name.compareTo(oname);
return toString().compareTo(other.toString());
}

/**
@@ -392,11 +383,7 @@ public class Resource extends DataType
return getCheckedRef().toString();
}
String n = getName();
if (n != null) {
return n;
}
String classname = getClass().getName();
return "anonymous " + classname.substring(classname.lastIndexOf('.') + 1);
return n == null ? "(anonymous)" : n;
}

/**


Loading…
Cancel
Save