Class Sort
- java.lang.Object
-
- com.blazebit.persistence.deltaspike.data.Sort
-
- All Implemented Interfaces:
Serializable,Iterable<Sort.Order>
public class Sort extends Object implements Iterable<Sort.Order>, Serializable
Immutable container for sorting information, heavily inspired by Spring Data'sSort.- Since:
- 1.2.0
- Author:
- Christian Beikov
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSort.DirectionSort directions.static classSort.NullHandlingEnumeration for null handling of anSort.Order.static classSort.OrderPropertyPath implements the pairing of anSort.Directionand a property.
-
Constructor Summary
Constructors Constructor Description Sort(Sort.Direction direction, String... paths)Creates a new Sort with the given paths the given direction.Sort(Sort.Direction direction, List<String> paths)Creates a new Sort with the given paths and given direction.Sort(Sort.Order... orders)Creates a new Sort with the givenSort.Orders.Sort(String... paths)Creates a new Sort with the given paths and theSort.Direction.ASC.Sort(Collection<Sort.Order> orders)Creates a new Sort with the givenSort.Orders.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Sortand(Sort sort)booleanequals(Object obj)Sort.OrdergetOrderFor(String path)Returns the order for the given path ornullif there is none.inthashCode()Iterator<Sort.Order>iterator()StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
Sort
public Sort(Sort.Order... orders)
Creates a new Sort with the givenSort.Orders.- Parameters:
orders- The orders to use for sorting
-
Sort
public Sort(Collection<Sort.Order> orders)
Creates a new Sort with the givenSort.Orders.- Parameters:
orders- The orders to use for sorting
-
Sort
public Sort(String... paths)
Creates a new Sort with the given paths and theSort.Direction.ASC.- Parameters:
paths- The paths by which to sort
-
Sort
public Sort(Sort.Direction direction, String... paths)
Creates a new Sort with the given paths the given direction.- Parameters:
direction- The direction to use for sortingpaths- The paths by which to sort
-
Sort
public Sort(Sort.Direction direction, List<String> paths)
Creates a new Sort with the given paths and given direction.- Parameters:
direction- The direction to use for sortingpaths- The paths by which to sort
-
-
Method Detail
-
and
public Sort and(Sort sort)
- Parameters:
sort- The other sort, may be null- Returns:
- A new Sort with the union of this and the
Sort.Orders of the givenSort
-
getOrderFor
public Sort.Order getOrderFor(String path)
Returns the order for the given path ornullif there is none.- Parameters:
path- The path for which to get theSort.Order- Returns:
- The
Sort.Orderfor the given path ornullit there is none
-
iterator
public Iterator<Sort.Order> iterator()
- Specified by:
iteratorin interfaceIterable<Sort.Order>
-
-