Class ComparatorChain<T>

java.lang.Object
eu.bandm.tools.util.ComparatorChain<T>
All Implemented Interfaces:
Comparator<T>

public class ComparatorChain<T> extends Object implements Comparator<T>
Combines more than one Comparators in the style of a lexical ordering.
  • Field Details

    • comparators

      protected Comparator<? super T>[] comparators
  • Constructor Details

    • ComparatorChain

      @SafeVarargs public ComparatorChain(Comparator<? super T>... cs)
      Takes a sequence of comparators, ranging from the "coarsest" to "finest".
  • Method Details

    • compare

      public int compare(T o1, T o2)
      Tries the comparators from the first to the last. Returns the first comparison result !=0, or the very last.
      Specified by:
      compare in interface Comparator<T>