Package com.unboundid.util
Class ReverseComparator<T>
java.lang.Object
com.unboundid.util.ReverseComparator<T>
- Type Parameters:
T- The type of object to use with this comparator.
- All Implemented Interfaces:
Serializable,Comparator<T>
@NotMutable
@ThreadSafety(level=COMPLETELY_THREADSAFE)
public final class ReverseComparator<T>
extends Object
implements Comparator<T>, Serializable
This class provides an implementation of a
Comparator object that may
be used to iterate through values in what would normally be considered
reverse order.- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new comparator that will sort items in reverse order.ReverseComparator(Comparator<T> baseComparator) Creates a new comparator that will sort items in the reverse order that they would be normally sorted using the given comparator. -
Method Summary
Modifier and TypeMethodDescriptionintCompares the provided objects to determine their relative order in a sorted list.booleanIndicates whether the provided object may be considered equal to this comparator.inthashCode()Retrieves a hash code for this class.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Constructor Details
-
ReverseComparator
public ReverseComparator()Creates a new comparator that will sort items in reverse order. The generic type for this class must implement theComparableinterface. -
ReverseComparator
Creates a new comparator that will sort items in the reverse order that they would be normally sorted using the given comparator.- Parameters:
baseComparator- The base comparator that will be used to make the determination.
-
-
Method Details
-
compare
Compares the provided objects to determine their relative order in a sorted list.- Specified by:
comparein interfaceComparator<T>- Parameters:
o1- The first object to compare.o2- The second object to compare.- Returns:
- A negative integer if the first object should be ordered before the second, a positive integer if the first object should be ordered after the second, or zero if there is no difference in their relative orders.
-
hashCode
Retrieves a hash code for this class. -
equals
Indicates whether the provided object may be considered equal to this comparator.- Specified by:
equalsin interfaceComparator<T>- Overrides:
equalsin classObject- Parameters:
o- The object for which to make the determination.- Returns:
trueif the provided object may be considered equal to this comparator, orfalseif not.
-