public class IterableComparator extends Object implements Comparator<Iterable<?>>
This comparator compares two
Iterables by comparing their items.
Iterables are compared on the first items, then on the second items, etc. If
Iterable A is larger than Iterable B, but all the items of B compared 0
(equal) with the corresponding items in A, then the comparator will sort the
smaller Iterable before the bigger Iterable.
The two Iterables don't need to contain items of the same classes, as long as
Comparable.compareTo(Object) allow comparison. (For
instance a Iterable<String> would not compare against
Iterable<Integer>). As according to
Comparator.compare(Object, Object) a
be thrown in such cases.
Items in the Iterable are compared using
NullSafeComparator, so this
comparator will handle Iterables containing
predictably. This comparator also allows
null in the same way,
so comparison of a
null will sort
null before the Iterable.
If an item in the Iterable is a
Iterable which is not itself
Comparable, and it is being compared with a different Iterable, it
will be recursively compared with the same instance of
IterableComparator. However, if such
Iterables are compared
ClassCastException would be thrown.
|Constructor and Description|
|Modifier and Type||Method and Description|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Copyright © 2015–2016 The Apache Software Foundation. All rights reserved.