-
public final class AnySortComparator<T extends Object>A type-erased wrapper for sort comparators that can work with any model type.
This class provides a way to store and use sort comparators without knowing their specific generic type parameters. It's useful for creating collections of different sort configurations that can all work with the same model type.
Type erased type avoids making SortField generic while keeping the underlying value type intact (no runtime type checks while sorting).
-
-
Constructor Summary
Constructors Constructor Description AnySortComparator(SortComparator<T, ?> sort)Creates a type-erased comparator from a specific comparator instance. AnySortComparator(Function3<T, T, SortDirection, Integer> compare)
-
Method Summary
Modifier and Type Method Description final Integercompare(T lhs, T rhs, SortDirection direction)Compares two model instances using the wrapped comparator. -
-
Constructor Detail
-
AnySortComparator
AnySortComparator(SortComparator<T, ?> sort)
Creates a type-erased comparator from a specific comparator instance.- Parameters:
sort- The specific comparator to wrap
-
AnySortComparator
AnySortComparator(Function3<T, T, SortDirection, Integer> compare)
-
-
Method Detail
-
compare
final Integer compare(T lhs, T rhs, SortDirection direction)
Compares two model instances using the wrapped comparator.
- Parameters:
lhs- The left-hand side model instancerhs- The right-hand side model instancedirection- The direction of the sort
-
-
-
-