Class ReverseComparator<T>

java.lang.Object
com.jalios.util.ReverseComparator<T>
All Implemented Interfaces:
Comparator<T>

public class ReverseComparator<T> extends Object implements Comparator<T>
This class is comparator which reverse the ordering of a given comparator.
Author:
Olivier Dedieu
  • Field Details

  • Constructor Details

    • ReverseComparator

      public ReverseComparator()
      Defaut constructor reverse NaturalComparator Objects mus be Comparable
    • ReverseComparator

      public ReverseComparator(Comparator<T> comparator)
      This constructor will reverse returned value by given comparator.
      Parameters:
      comparator - used to compare object
  • Method Details

    • getReversedComparator

      public Comparator<T> getReversedComparator()
      Retrieve the Comparator this ReverseComparator is reversing or null when the natural Comparator is reversed.
      Returns:
      the Comparator instance being used or null if we are reversing the natural Comparator of the objects.
    • compare

      public int compare(T o1, T o2)
      Specified by:
      compare in interface Comparator<T>