Interface Sort

All Known Subinterfaces:
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
     
    boolean
     
    static Sort
    of(Sort.Order... orders)
    Creates a sort from an array orders.
    static Sort
    of(List<Sort.Order> orderList)
    Create a sort from the given list of orders.
    Adds an order object.
    order(String propertyName)
    Orders by the specified property name (defaults to ascending).
    order(String propertyName, Sort.Order.Direction direction)
    Orders by the specified property name and direction.
    static Sort
     
  • Field Details

    • UNSORTED

      static final Sort UNSORTED
      Constant for unsorted.
  • Method Details

    • isSorted

      boolean isSorted()
      Returns:
      Is sorting applied
    • order

      @NonNull Sort order(@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 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 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 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 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