Interface Sort

  • All Known Subinterfaces:
    Pageable

    public interface Sort
    An interface for objects that can be sorted. Sorted instances are immutable and all mutating operations on this interface return a new instance.
    Since:
    1.0
    • Field Detail

      • UNSORTED

        static final Sort UNSORTED
        Constant for unsorted.
    • Method Detail

      • isSorted

        boolean isSorted()
        Returns:
        Is sorting applied
      • order

        @NonNull
        Sort order​(@NonNull
                   java.lang.String propertyName)
        Orders by the specified property name (defaults to ascending).
        Parameters:
        propertyName - The property name to order by
        Returns:
        A new sort with the order applied
      • order

        @NonNull
        Sort order​(@NonNull
                   Sort.Order order)
        Adds an order object.
        Parameters:
        order - The order object
        Returns:
        A new sort with the order applied
      • order

        @NonNull
        Sort order​(@NonNull
                   java.lang.String propertyName,
                   @NonNull
                   Sort.Order.Direction direction)
        Orders by the specified property name and direction.
        Parameters:
        propertyName - The property name to order by
        direction - Either "asc" for ascending or "desc" for descending
        Returns:
        A new sort with the order applied
      • getOrderBy

        @NonNull
        java.util.List<Sort.Order> getOrderBy()
        Returns:
        The order definitions for this sort.
      • unsorted

        static Sort unsorted()
        Returns:
        Default unsorted sort instance.
      • of

        @NonNull
        static Sort of​(@Nullable
                       java.util.List<Sort.Order> orderList)
        Create a sort from the given list of orders.
        Parameters:
        orderList - The order list
        Returns:
        The sort
      • of

        @NonNull
        static Sort of​(Sort.Order... orders)
        Creates a sort from an array orders.
        Parameters:
        orders - The orders
        Returns:
        The orders