Class InverseComparator<T>

java.lang.Object
com.tangosol.util.Base
com.tangosol.util.comparator.SafeComparator<T>
com.tangosol.util.comparator.InverseComparator<T>
All Implemented Interfaces:
ExternalizableLite, PortableObject, EntryAwareComparator<T>, QueryMapComparator<T>, Remote.Comparator<T>, Serializable, Comparator<T>

public class InverseComparator<T> extends SafeComparator<T> implements QueryMapComparator<T>
Comparator that reverses the result of another comparator.
Author:
cp/gg 2002.11.01
See Also:
  • Constructor Details

    • InverseComparator

      public InverseComparator()
      Default constructor (for ExternalizableLite and PortableObject).
    • InverseComparator

      public InverseComparator(Comparator<? super T> comparator)
      Construct an InverseComparator.
      Parameters:
      comparator - the comparator whose results are inverted by this Comparator
  • Method Details

    • compare

      public int compare(T o1, T o2)
      Use the wrapped Comparator to compare the two arguments for order and negate the result.
      Specified by:
      compare in interface Comparator<T>
      Overrides:
      compare in class SafeComparator<T>
      Parameters:
      o1 - the first object to be compared
      o2 - the second object to be compared
      Returns:
      a positive integer, zero, or a negative integer as the first argument is less than, equal to, or greater than the second
    • compareEntries

      public int compareEntries(QueryMap.Entry entry1, QueryMap.Entry entry2)
      Compare two entries using the underlying comparator and negate the result.
      Specified by:
      compareEntries in interface QueryMapComparator<T>
      Overrides:
      compareEntries in class SafeComparator<T>
      Parameters:
      entry1 - the first entry to compare values from; read-only
      entry2 - the second entry to compare values from; read-only
      Returns:
      a negative integer, zero, or a positive integer as the first entry denotes a value that is is less than, equal to, or greater than the value denoted by the second entry
    • equals

      public boolean equals(Object o)
      Compare the InverseComparator with another object to determine equality.
      Specified by:
      equals in interface Comparator<T>
      Overrides:
      equals in class SafeComparator<T>
      Parameters:
      o - the other comparator
      Returns:
      true iff this InverseComparator and the passed object are equivalent InverseComparator