Class IterableComparator<T>

java.lang.Object
org.dmfs.jems2.comparator.DelegatingComparator<Iterable<? extends T>>
org.dmfs.jems2.comparator.IterableComparator<T>
All Implemented Interfaces:
Comparator<Iterable<? extends T>>

public final class IterableComparator<T> extends DelegatingComparator<Iterable<? extends T>>
Comparator for Iterables. Elements are compared by the given Comparator of Optionals. The delegate will receive absent Optionals when the shorter Iterable has run out of elements.

Examples

With new OptionalComparator(naturalOrder) as the delegate

 [] == []
 [1, 2, 3] == [1, 2, 3]
 [1, 2, 3] < [1, 2, 3, 4]
 [1, 2, 3] < [1, 2, 4]
 [1, 2, 3] < [1, 3]
 
  • Constructor Details

    • IterableComparator

      public IterableComparator(Comparator<? super Optional<? extends T>> delegate)