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.
| Modifier and Type | Class and Description |
|---|---|
| private static class | ConvertingComparator.
Adapts a |
| Modifier and Type | Field and Description |
|---|---|
| private final Comparator | |
| private final Converter |
| Access | Constructor and Description |
|---|---|
| public | ConvertingComparator(Converter<S, T>
the converter converter)Create a new |
| public | ConvertingComparator(Comparator<T>
the underlying comparator used to compare the converted values comparator, Converter<S, T> the converter converter)Create a new |
| public | ConvertingComparator(Comparator<T>
the underlying comparator comparator, ConversionService the conversion service conversionService, Class<? extends T> the target type targetType)Create a new |
| Modifier and Type | Method and Description |
|---|---|
| public int | compare(S
the first object to be compared. o1, S the second object to be compared. o2)Implements java. Compares its two arguments for order. |
| public static <K, V> ConvertingComparator | Returns: a newConvertingComparator instancethe underlying comparator used to compare keys comparator)Create a new |
| public static <K, V> ConvertingComparator | Returns: a newConvertingComparator instancethe underlying comparator used to compare values comparator)Create a new |
| comparator | back to summary |
|---|---|
| private final Comparator<T> comparator | |
| converter | back to summary |
|---|---|
| private final Converter<S, T> converter | |
| ConvertingComparator | back to summary |
|---|---|
| public ConvertingComparator(Converter<S, T> converter) Create a new
| |
| ConvertingComparator | back to summary |
|---|---|
| public ConvertingComparator(Comparator<T> comparator, Converter<S, T> converter) Create a new
| |
| ConvertingComparator | back to summary |
|---|---|
| public ConvertingComparator(Comparator<T> comparator, ConversionService conversionService, Class<? extends T> targetType) Create a new
| |
| compare | back to summary |
|---|---|
| public int compare(S o1, S o2) Implements java. Doc from java. Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
The implementor must ensure that
The implementor must also ensure that the relation is transitive:
Finally, the implementor must ensure that
| |
| mapEntryKeys | back to summary |
|---|---|
| public static <K, V> ConvertingComparator Create a new
| |
| mapEntryValues | back to summary |
|---|---|
| public static <K, V> ConvertingComparator Create a new
| |
| Modifier and Type | Field and Description |
|---|---|
| private final ConversionService | |
| private final Class |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public T | convert(S
the source object to convert, which must be an instance of source)S (never null)Implements org. Convert the source object of type |
| conversionService | back to summary |
|---|---|
| private final ConversionService conversionService | |
| targetType | back to summary |
|---|---|
| private final Class<? extends T> targetType | |
| ConversionServiceConverter | back to summary |
|---|---|
| public ConversionServiceConverter(ConversionService conversionService, Class<? extends T> targetType) | |
| convert | back to summary |
|---|---|
| public T convert(S source) Implements org. Doc from org. Convert the source object of type | |