@Override public int compareTo( VirtualValue other, Comparator<AnyValue> comparator ) { if ( other == null || !(other instanceof PathValue) ) { throw new IllegalArgumentException( "Cannot compare different virtual values" ); } PathValue otherPath = (PathValue) other; NodeValue[] nodes = nodes(); RelationshipValue[] relationships = relationships(); NodeValue[] otherNodes = otherPath.nodes(); RelationshipValue[] otherRelationships = otherPath.relationships(); int x = nodes[0].compareTo( otherNodes[0], comparator ); if ( x == 0 ) { int i = 0; int length = Math.min( relationships.length, otherRelationships.length ); while ( x == 0 && i < length ) { x = relationships[i].compareTo( otherRelationships[i], comparator ); ++i; } if ( x == 0 ) { x = Integer.compare( relationships.length, otherRelationships.length ); } } return x; }
@Override public int compareTo( VirtualValue other, Comparator<AnyValue> comparator ) { if ( other == null || !(other instanceof PathValue) ) { throw new IllegalArgumentException( "Cannot compare different virtual values" ); } PathValue otherPath = (PathValue) other; NodeValue[] nodes = nodes(); RelationshipValue[] relationships = relationships(); NodeValue[] otherNodes = otherPath.nodes(); RelationshipValue[] otherRelationships = otherPath.relationships(); int x = nodes[0].compareTo( otherNodes[0], comparator ); if ( x == 0 ) { int i = 0; int length = Math.min( relationships.length, otherRelationships.length ); while ( x == 0 && i < length ) { x = relationships[i].compareTo( otherRelationships[i], comparator ); ++i; } if ( x == 0 ) { x = Integer.compare( relationships.length, otherRelationships.length ); } } return x; }