CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

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, Serializable, 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(Comparator comparator)
          Construct an InverseComparator.
 
Method Summary
 int compare(Object o1, 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(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(Comparator comparator)
Construct an InverseComparator.

Parameters:
comparator - the comparator whose results are inverted by this Comparator
Method Detail

compare

public int compare(Object o1,
                   Object o2)
Use the wrapped Comparator to compare the two arguments for order and negate the result.

Specified by:
compare in interface 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(Object o)
Compare the InverseComparator with another object to determine equality.

Specified by:
equals in interface Comparator
Overrides:
equals in class SafeComparator
Parameters:
o - the other comparator
Returns:
true iff this InverseComparator and the passed object are equivalent InverseComparator

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation