Class 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 Detail

      • DEFAULT_DIRECTION

        public static final Direction DEFAULT_DIRECTION
    • Constructor Detail

      • 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 Detail

      • 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
      • 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
      • hashCode

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

        public void setOrders​(List<Order> orders)