/** * Compare this ArchiveResource to another Resource. * @param another the other Resource against which to compare. * @return a negative integer, zero, or a positive integer as this Resource * is less than, equal to, or greater than the specified Resource. */ @Override public int compareTo(Resource another) { return this.equals(another) ? 0 : super.compareTo(another); }
/** * Implement basic Resource equality. * @param other the object to check against. * @return true if the specified Object is equal to this Resource. * @since Ant 1.7 */ @Override public boolean equals(Object other) { if (this == other) { return true; } if (isReference()) { return getCheckedRef().equals(other); } return other != null && other.getClass().equals(getClass()) && compareTo((Resource) other) == 0; }
/** * Delegates to a comparison of names. * @param other the object to compare to. * @return a negative integer, zero, or a positive integer as this Resource * is less than, equal to, or greater than the specified Resource. * @since Ant 1.6 */ @Override public int compareTo(Resource other) { if (isReference()) { return getCheckedRef().compareTo(other); } return toString().compareTo(other.toString()); }
/** * Compare this FileResource to another Resource. * @param another the other Resource against which to compare. * @return a negative integer, zero, or a positive integer as this FileResource * is less than, equal to, or greater than the specified Resource. */ @Override public int compareTo(Resource another) { if (isReference()) { return getCheckedRef().compareTo(another); } if (this.equals(another)) { return 0; } FileProvider otherFP = another.as(FileProvider.class); if (otherFP != null) { File f = getFile(); if (f == null) { return -1; } File of = otherFP.getFile(); if (of == null) { return 1; } int compareFiles = f.compareTo(of); return compareFiles != 0 ? compareFiles : getName().compareTo(another.getName()); } return super.compareTo(another); }