Package com.jalios.util
Class ReverseComparator<T>
java.lang.Object
com.jalios.util.ReverseComparator<T>
- All Implemented Interfaces:
Comparator<T>
This class is comparator which reverse the ordering of a given comparator.
- Author:
- Olivier Dedieu
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaut constructor reverse NaturalComparator Objects mus be ComparableReverseComparator(Comparator<T> comparator) This constructor will reverse returned value by given comparator. -
Method Summary
Modifier and TypeMethodDescriptionintRetrieve the Comparator this ReverseComparator is reversing or null when the natural Comparator is reversed.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Field Details
-
comparator
-
-
Constructor Details
-
ReverseComparator
public ReverseComparator()Defaut constructor reverse NaturalComparator Objects mus be Comparable -
ReverseComparator
This constructor will reverse returned value by given comparator.- Parameters:
comparator- used to compare object
-
-
Method Details
-
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
- Specified by:
comparein interfaceComparator<T>
-