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>

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 Details

    • ReverseComparator

      Creates a new comparator that will sort items in reverse order. The generic type for this class must implement the Comparable interface.
    • ReverseComparator

      public ReverseComparator(@NotNull 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 Details

    • 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 interface 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 class Object
      Returns:
      A hash code for this class.
    • equals

      public boolean equals(@Nullable Object o)
      Indicates whether the provided object may be considered equal to this comparator.
      Specified by:
      equals in interface Comparator<T>
      Overrides:
      equals in class Object
      Parameters:
      o - The object for which to make the determination.
      Returns:
      true if the provided object may be considered equal to this comparator, or false if not.