compareTo
public int compareTo(Key other)
Compares two Key objects. The algorithm proceeds as follows:
Turn each Key into an iterator where the first element returned
is the top-most ancestor, the next element is the child
of the previous element, and so on. The last element will
be the Key we started with. Once we have assembled these two
iterators (one for 'this' and one for the Key we're comparing to),
consume them in parallel, comparing the next element from each iterator.
If at any point the comparison of these two elements yields a non-zero
result, return that as the result of the overall comparison. If we
exhaust the iterator built from 'this' before we exhaust
the iterator built from the other Key, we return less than. An
example:
app1.type1.4.app1.type2.9 < app1.type1.4.app1.type2.9.app1.type3.2
If we exhaust the iterator built from the other Key before we
exhaust the iterator built from 'this', we return greater than. An
example:
app1.type1.4.app1.type2.9.app1.type3.2 > app1.type1.4.app1.type2.9
The relationship between individual Key Keys is performed
by comparing app followed by kind followed by id. If both keys are
assigned names rather than ids, compares names instead of ids. If neither
key has an id or a name we return an arbitrary but consistent result.
Assuming all other components are equal, all ids are less than all names.