Package 

Class AnySortComparator


  • 
    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).

    • Method Summary

      Modifier and Type Method Description
      final Integer compare(T lhs, T rhs, SortDirection direction) Compares two model instances using the wrapped comparator.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • AnySortComparator

        AnySortComparator(SortComparator<T, ?> sort)
        Creates a type-erased comparator from a specific comparator instance.
        Parameters:
        sort - The specific comparator to wrap
    • 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 instance
        rhs - The right-hand side model instance
        direction - The direction of the sort