Package com.jalios.util
Class ReverseComparator<T>
- java.lang.Object
-
- com.jalios.util.ReverseComparator<T>
-
- All Implemented Interfaces:
java.util.Comparator<T>
public class ReverseComparator<T> extends java.lang.Object implements java.util.Comparator<T>
This class is comparator which reverse the ordering of a given comparator.- Author:
- Olivier Dedieu
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Comparator<T>
comparator
-
Constructor Summary
Constructors Constructor Description ReverseComparator()
Defaut constructor reverse NaturalComparator Objects mus be ComparableReverseComparator(java.util.Comparator<T> comparator)
This constructor will reverse returned value by given comparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(T o1, T o2)
java.util.Comparator<T>
getReversedComparator()
Retrieve the Comparator this ReverseComparator is reversing or null when the natural Comparator is reversed.
-
-
-
Field Detail
-
comparator
protected java.util.Comparator<T> comparator
-
-
Constructor Detail
-
ReverseComparator
public ReverseComparator()
Defaut constructor reverse NaturalComparator Objects mus be Comparable
-
ReverseComparator
public ReverseComparator(java.util.Comparator<T> comparator)
This constructor will reverse returned value by given comparator.- Parameters:
comparator
- used to compare object
-
-
Method Detail
-
getReversedComparator
public java.util.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.
-
-