Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


com.tangosol.util.comparator
Class InverseComparator

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.util.comparator.SafeComparator
          extended by com.tangosol.util.comparator.InverseComparator

All Implemented Interfaces:
ExternalizableLite, PortableObject, EntryAwareComparator, QueryMapComparator, java.io.Serializable, java.util.Comparator

public class InverseComparator
extends SafeComparator
implements QueryMapComparator

Comparator that reverses the result of another comparator.

Author:
cp/gg 2002.11.01

Field Summary

 

Fields inherited from class com.tangosol.util.comparator.SafeComparator
INSTANCE, m_comparator

 

Constructor Summary
InverseComparator()
          Default constructor (for ExternalizableLite and PortableObject).
InverseComparator(java.util.Comparator comparator)
          Construct an InverseComparator.

 

Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Use the wrapped Comparator to compare the two arguments for order and negate the result.
 int compareEntries(QueryMap.Entry entry1, QueryMap.Entry entry2)
          Compare two entries using the underlying comparator and negate the result.
 boolean equals(java.lang.Object o)
          Compare the InverseComparator with another object to determine equality.

 

Methods inherited from class com.tangosol.util.comparator.SafeComparator
compareSafe, getComparator, hashCode, isKeyComparator, isKeyComparator, readExternal, readExternal, toString, writeExternal, writeExternal

 

Constructor Detail

InverseComparator

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

InverseComparator

public InverseComparator(java.util.Comparator comparator)
Construct an InverseComparator.
Parameters:
comparator - the comparator whose results are inverted by this Comparator

Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Use the wrapped Comparator to compare the two arguments for order and negate the result.
Specified by:
compare in interface java.util.Comparator
Overrides:
compare in class SafeComparator
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
Overrides:
compareEntries in class SafeComparator
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(java.lang.Object o)
Compare the InverseComparator with another object to determine equality.
Specified by:
equals in interface java.util.Comparator
Overrides:
equals in class SafeComparator
Parameters:
o - the other comparator
Returns:
true iff this InverseComparator and the passed object are equivalent InverseComparator
See Also:
Object.equals(java.lang.Object), Object.hashCode()

Skip navigation links

Oracle® Coherence Java API Reference
Release 3.7.1.0

E22843-01


Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.