Package com.tangosol.util.comparator
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:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.Base
Base.LoggingWriter
-
-
Field Summary
-
Fields inherited from class com.tangosol.util.comparator.SafeComparator
INSTANCE, m_comparator, m_fNullFirst
-
-
Constructor Summary
Constructors Constructor Description InverseComparator()
Default constructor (for ExternalizableLite and PortableObject).InverseComparator(Comparator<? super T> comparator)
Construct an InverseComparator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(T o1, T 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, compareSafe, getComparator, hashCode, INSTANCE, isKeyComparator, isKeyComparator, isNullFirst, readExternal, readExternal, toString, writeExternal, writeExternal
-
Methods inherited from class com.tangosol.util.Base
azzert, azzert, azzert, azzertFailed, breakLines, breakLines, capitalize, checkNotEmpty, checkNotNull, checkRange, computeSafeWaitTime, decimalValue, dup, dup, ensureBigDecimal, ensureClassLoader, ensureRuntimeException, ensureRuntimeException, equals, equalsDeep, err, err, err, err, err, escape, formatDateTime, getCallerStackFrame, getCommonMonitor, getCommonMonitor, getCommonMonitor, getContextClassLoader, getContextClassLoader, getDeepMessage, getErr, getLastSafeTimeMillis, getLog, getMaxDecDigits, getMaxHexDigits, getOriginalException, getOut, getProcessRandom, getRandom, getRandomBinary, getRandomBinary, getRandomString, getSafeTimeMillis, getStackFrame, getStackFrames, getStackTrace, getStackTrace, getStackTrace, getThreadFactory, getTimeZone, getUpTimeMillis, hashCode, hexValue, indentString, indentString, isDecimal, isHex, isLogEcho, isOctal, log, log, log, log, log, makeInteger, makeLong, makeThread, mergeArray, mergeBooleanArray, mergeByteArray, mergeCharArray, mergeDoubleArray, mergeFloatArray, mergeIntArray, mergeLongArray, mod, mod, octalValue, out, out, out, out, out, pad, parseBandwidth, parseBandwidth, parseDelimitedString, parseHex, parseHex, parseMemorySize, parseMemorySize, parsePercentage, parseTime, parseTime, parseTimeNanos, parseTimeNanos, printStackTrace, randomize, randomize, randomize, randomize, read, read, read, read, read, read, read, replace, setErr, setLog, setLogEcho, setOut, sleep, toBandwidthString, toBandwidthString, toCharEscape, toCrc, toCrc, toCrc, toCrc, toCrc, toDecString, toDelimitedString, toDelimitedString, toDelimitedString, toDelimitedString, toHex, toHex, toHexDump, toHexEscape, toHexEscape, toHexEscape, toHexEscape, toHexString, toMemorySizeString, toMemorySizeString, toQuotedCharEscape, toQuotedStringEscape, toSqlString, toString, toString, toStringEscape, toUnicodeEscape, trace, trace, trace, trace, trace, trace, trace, trace, trace, truncateString, truncateString, wait
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from interface com.tangosol.util.function.Remote.Comparator
reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Constructor Detail
-
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 Detail
-
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 interfaceComparator<T>
- Overrides:
compare
in classSafeComparator<T>
- Parameters:
o1
- the first object to be comparedo2
- 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 interfaceQueryMapComparator<T>
- Overrides:
compareEntries
in classSafeComparator<T>
- Parameters:
entry1
- the first entry to compare values from; read-onlyentry2
- 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 interfaceComparator<T>
- Overrides:
equals
in classSafeComparator<T>
- Parameters:
o
- the other comparator- Returns:
- true iff this InverseComparator and the passed object are equivalent InverseComparator
-
-