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 aComparator
object 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 int
compare(T o1, T o2)
Compares the provided objects to determine their relative order in a sorted list.boolean
equals(java.lang.Object o)
Indicates whether the provided object may be considered equal to this comparator.int
hashCode()
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 theComparable
interface.
-
ReverseComparator
public ReverseComparator(@NotNull 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(@NotNull T o1, @NotNull T o2)
Compares the provided objects to determine their relative order in a sorted list.- Specified by:
compare
in 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:
hashCode
in classjava.lang.Object
- Returns:
- A hash code for this class.
-
equals
public boolean equals(@Nullable java.lang.Object o)
Indicates whether the provided object may be considered equal to this comparator.- Specified by:
equals
in interfacejava.util.Comparator<T>
- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- The object for which to make the determination.- Returns:
true
if the provided object may be considered equal to this comparator, orfalse
if not.
-
-