Package NTNU.IDATT1002.repository
Class Sort
java.lang.Object
NTNU.IDATT1002.repository.Sort
public class Sort
extends java.lang.Object
Represents a part of a sorted
PageRequest.
Composes an Order wrapped in an Optional
which can be used when building an ordered CriteriaQuery.
If no sorting is specified or required, empty() should be used.
This returns a Optional.empty() when building queries.
The default order is ascending.-
Method Summary
Modifier and Type Method Description Sortascending()Return aSortin ascending order.static Sortby(java.lang.String field)Return aSortby given field.Sortdescending()Return aSortin descending order.static Sortempty()Return aSortwhich does not sort by any field.<T> java.util.Optional<javax.persistence.criteria.Order>getOrder(javax.persistence.criteria.CriteriaBuilder criteriaBuilder, javax.persistence.criteria.Root<T> from)Compose and return thisSortas anOrderwrapped in anOptionalwhich can be used when building queries withCriteriaQuery.
-
Method Details
-
by
Return aSortby given field. -
descending
Return aSortin descending order. -
ascending
Return aSortin ascending order. -
empty
Return aSortwhich does not sort by any field. -
getOrder
public <T> java.util.Optional<javax.persistence.criteria.Order> getOrder(javax.persistence.criteria.CriteriaBuilder criteriaBuilder, javax.persistence.criteria.Root<T> from)Compose and return thisSortas anOrderwrapped in anOptionalwhich can be used when building queries withCriteriaQuery. ReturnOptional.empty()if thisSortis empty,- Parameters:
criteriaBuilder- theCriteriaBuilderto build theOrderfromfrom- theRootspecifying which table the query acts on.
-