java.lang.Object
de.digitalcollections.model.list.sorting.Sorting
All Implemented Interfaces:
Iterable<Order>

public class Sorting extends Object implements Iterable<Order>
SortingImpl option for queries. You have to provide at least a list of properties to sort for that must not include null or empty strings. The direction defaults to DEFAULT_DIRECTION. See Spring Data Commons, but more flat design and independent of Spring libraries.
  • Field Details

    • DEFAULT_DIRECTION

      public static final Direction DEFAULT_DIRECTION
  • Constructor Details

    • Sorting

      public Sorting()
    • Sorting

      public Sorting(Order... orders)
      Creates a new Sorting instance using the given Orders.
      Parameters:
      orders - must not be null.
    • Sorting

      public Sorting(List<Order> orders)
      Creates a new Sorting instance.
      Parameters:
      orders - must not be null or contain null.
    • Sorting

      public Sorting(String... properties)
      Creates a new Sorting instance. Order defaults to Direction#ASC.
      Parameters:
      properties - must not be null or contain null or empty strings
    • Sorting

      public Sorting(Direction direction, String... properties)
      Creates a new Sorting instance.
      Parameters:
      direction - defaults to DEFAULT_DIRECTION (for null cases, too)
      properties - must not be null, empty or contain null or empty strings.
    • Sorting

      public Sorting(Direction direction, List<String> properties)
      Creates a new Sorting instance.
      Parameters:
      direction - defaults to DEFAULT_DIRECTION (for null cases, too)
      properties - must not be null or contain null or empty strings.
  • Method Details

    • builder

      public static Sorting.Builder builder()
    • and

      public Sorting and(Sorting sort)
      Returns a new Sorting consisting of the Orders of the current Sorting combined with the given ones.
      Parameters:
      sort - can be null.
      Returns:
      a new combined sort
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getOrderFor

      public Order getOrderFor(String property)
      Returns the order registered for the given property.
      Parameters:
      property - given property
      Returns:
      the order registered for the given property
    • getOrders

      public List<Order> getOrders()
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • iterator

      public Iterator<Order> iterator()
      Specified by:
      iterator in interface Iterable<Order>
    • setOrders

      public void setOrders(List<Order> orders)
    • toString

      public String toString()
      Overrides:
      toString in class Object