Interface Sort

All Known Subinterfaces:
CursoredPageable, Pageable

@DefaultImplementation(io.micronaut.data.model.DefaultSort.class) 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
Author:
graemerocher
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static class 
    The ordering of results.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Sort
    Constant for unsorted.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NonNull List<Sort.Order>
     
    boolean
     
    static @NonNull Sort
    of(@Nullable List<Sort.Order> orderList)
    Create a sort from the given list of orders.
    static @NonNull Sort
    of(Sort.Order... orders)
    Creates a sort from an array orders.
    @NonNull Sort
    order(@NonNull String propertyName)
    Orders by the specified property name (defaults to ascending).
    @NonNull Sort
    order(@NonNull String propertyName, Sort.Order.Direction direction)
    Orders by the specified property name and direction.
    @NonNull Sort
    Adds an order object.
    default @NonNull Sort
    orders(@NonNull List<Sort.Order> orders)
    Adds an orders.
    static Sort
     
  • Field Details

    • UNSORTED

      static final Sort UNSORTED
      Constant for unsorted.
  • Method Details

    • isSorted

      boolean isSorted()
      Returns:
      Is sorting applied
    • order

      @NonNull @NonNull Sort order(@NonNull @NonNull 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 @NonNull Sort order(@NonNull Sort.Order order)
      Adds an order object.
      Parameters:
      order - The order object
      Returns:
      A new sort with the order applied
    • orders

      @NonNull default @NonNull Sort orders(@NonNull @NonNull List<Sort.Order> orders)
      Adds an orders.
      Parameters:
      orders - The orders
      Returns:
      A new sort with the order applied
      Since:
      4.10
    • order

      @NonNull @NonNull Sort order(@NonNull @NonNull 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 @NonNull List<Sort.Order> getOrderBy()
      Returns:
      The order definitions for this sort.
    • unsorted

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

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

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