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:
java.io.Serializable,java.util.Comparator<T>
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class ReverseComparator<T> extends java.lang.Object implements java.util.Comparator<T>, java.io.Serializable
This class provides an implementation of aComparatorobject that may be used to iterate through values in what would normally be considered reverse order.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ReverseComparator()Creates a new comparator that will sort items in reverse order.ReverseComparator(java.util.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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intcompare(T o1, T o2)Compares the provided objects to determine their relative order in a sorted list.booleanequals(java.lang.Object o)Indicates whether the provided object may be considered equal to this comparator.inthashCode()Retrieves a hash code for this class.
-
-
-
Constructor Detail
-
ReverseComparator
public ReverseComparator()
Creates a new comparator that will sort items in reverse order. The generic type for this class must implement theComparableinterface.
-
ReverseComparator
public ReverseComparator(java.util.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.- Parameters:
baseComparator- The base comparator that will be used to make the determination.
-
-
Method Detail
-
compare
public int compare(T o1, T o2)
Compares the provided objects to determine their relative order in a sorted list.- Specified by:
comparein interfacejava.util.Comparator<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
public int hashCode()
Retrieves a hash code for this class.- Overrides:
hashCodein classjava.lang.Object- Returns:
- A hash code for this class.
-
equals
public boolean equals(java.lang.Object o)
Indicates whether the provided object may be considered equal to this comparator.- Specified by:
equalsin interfacejava.util.Comparator<T>- Overrides:
equalsin classjava.lang.Object- Parameters:
o- The object for which to make the determination.- Returns:
trueif the provided object may be considered equal to this comparator, orfalseif not.
-
-