@Override public int compareTo(Statement other) { if (other == null || other == this) return(0); int c; // compare subject c = this.getSubject().compareTo(other.getSubject()); if (c != 0) return c; // compare predicate c = this.getPredicate().toString().compareTo(other.getPredicate().toString()); if (c != 0) return c; // compare objects c = this.getObject().toString().compareTo(other.getObject().toString()); if (c != 0) return c; return 0; }
@Override public boolean equals(Object object) { if (object == null || ! (object instanceof Statement)) return false; if (object == this) return true; Statement other = (Statement) object; // two statements are equal if their components are equals if (! this.getSubject().equals(other.getSubject())) return false; if (! this.getPredicate().equals(other.getPredicate())) return false; if (! this.getObject().equals(other.getObject())) return false; return true; }