S
- the source typeT
- the target typepublic class ConvertingComparator<S,T>
extends java.lang.Object
implements java.util.Comparator<S>
Comparator
that converts values before they are compared. The specified
Converter
will be used to convert each value before it passed to the underlying
Comparator
.Constructor and Description |
---|
ConvertingComparator(java.util.Comparator<T> comparator,
ConversionService conversionService,
java.lang.Class<? extends T> targetType)
Create a new
ComparableComparator instance. |
ConvertingComparator(java.util.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<java.util.Map.Entry<K,V>,K> |
mapEntryKeys(java.util.Comparator<K> comparator)
|
static <K,V> ConvertingComparator<java.util.Map.Entry<K,V>,V> |
mapEntryValues(java.util.Comparator<V> comparator)
|
public ConvertingComparator(Converter<S,T> converter)
ConvertingComparator
instance.converter
- the converterpublic ConvertingComparator(java.util.Comparator<T> comparator, Converter<S,T> converter)
ConvertingComparator
instance.comparator
- the underlying comparator used to compare the converted valuesconverter
- the converterpublic ConvertingComparator(java.util.Comparator<T> comparator, ConversionService conversionService, java.lang.Class<? extends T> targetType)
ComparableComparator
instance.comparator
- the underlying comparatorconversionService
- the conversion servicetargetType
- the target typepublic static <K,V> ConvertingComparator<java.util.Map.Entry<K,V>,K> mapEntryKeys(java.util.Comparator<K> comparator)
comparator
- the underlying comparator used to compare keysConvertingComparator
instancepublic static <K,V> ConvertingComparator<java.util.Map.Entry<K,V>,V> mapEntryValues(java.util.Comparator<V> comparator)
comparator
- the underlying comparator used to compare valuesConvertingComparator
instance