S
- the source typeT
- the target typepublic class ConvertingComparator<S,T> extends Object implements Comparator<S>
Comparator
that converts values before they are compared.
The specified Converter
will be used to convert each value
before it is passed to the underlying Comparator
.
Constructor and Description |
---|
ConvertingComparator(Comparator<T> comparator,
ConversionService conversionService,
Class<? extends T> targetType)
Create a new
ConvertingComparator instance. |
ConvertingComparator(Comparator<T> comparator,
Converter<S,T> converter)
Create a new
ConvertingComparator instance. |
ConvertingComparator(Converter<S,T> converter)
Create a new
ConvertingComparator instance. |
Modifier and Type | Method and Description |
---|---|
int |
compare(S o1,
S o2) |
static <K,V> ConvertingComparator<Map.Entry<K,V>,K> |
mapEntryKeys(Comparator<K> comparator)
|
static <K,V> ConvertingComparator<Map.Entry<K,V>,V> |
mapEntryValues(Comparator<V> comparator)
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
comparing, comparing, comparingDouble, comparingInt, comparingLong, equals, naturalOrder, nullsFirst, nullsLast, reversed, reverseOrder, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
public ConvertingComparator(Converter<S,T> converter)
ConvertingComparator
instance.converter
- the converterpublic ConvertingComparator(Comparator<T> comparator, Converter<S,T> converter)
ConvertingComparator
instance.comparator
- the underlying comparator used to compare the converted valuesconverter
- the converterpublic ConvertingComparator(Comparator<T> comparator, ConversionService conversionService, Class<? extends T> targetType)
ConvertingComparator
instance.comparator
- the underlying comparatorconversionService
- the conversion servicetargetType
- the target typepublic int compare(S o1, S o2)
compare
in interface Comparator<S>
public static <K,V> ConvertingComparator<Map.Entry<K,V>,K> mapEntryKeys(Comparator<K> comparator)
comparator
- the underlying comparator used to compare keysConvertingComparator
instancepublic static <K,V> ConvertingComparator<Map.Entry<K,V>,V> mapEntryValues(Comparator<V> comparator)
comparator
- the underlying comparator used to compare valuesConvertingComparator
instance