public int compareTo(Object o) { Projection other = (Projection)o; int result = size() - other.size(); if (result == 0) { // Projections have equal size for (int i = 0; i < size() && result == 0; i++) { Value thisValue = get(i); Value otherValue = other.get(i); result = thisValue.compareTo(otherValue); } } return result; }
/** * Compares this Statement with the supplied object. * * @throws ClassCastException if o is not of type Statement * @see java.lang.Comparable **/ public int compareTo(Object o) { if (this == o) { return 0; } Statement other = (Statement)o; int result = 0; result = _object.compareTo(other.getObject()); if (result == 0) { // objects are equal result = _subject.compareTo(other.getSubject()); } if (result == 0) { // subjects and objects are equal result = _predicate.compareTo(other.getPredicate()); } return result; }