Class Page
java.lang.Object
org.omnifaces.persistence.model.dto.Page
This class basically defines a paged view of a database based on a given offset, limit, ordering, required criteria
and optional criteria. This is used by BaseEntityService.getPage(Page, boolean)
methods.
- Author:
- Bauke Scholtz
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionPage
(Integer offset, Integer limit, LinkedHashMap<String, Boolean> ordering, Map<String, Object> requiredCriteria, Map<String, Object> optionalCriteria) Creates a new Page.Page
(Integer offset, Integer limit, Identifiable<?> last, Boolean reversed, LinkedHashMap<String, Boolean> ordering, Map<String, Object> requiredCriteria, Map<String, Object> optionalCriteria) Creates a new Page whereby value based paging will be performed instead of offset based paging when applicable. -
Method Summary
Modifier and TypeMethodDescriptionall()
Returns a clone of the current page which returns all results matching the current ordering, required criteria and optional criteria.boolean
Identifiable<?>
getLast()
Returns the last entity of the previous page, if any.int
getLimit()
Returns the limit.int
Returns the offset.Returns the optional criteria.Returns the ordering.Returns the required criteria.int
hashCode()
boolean
Returns whether the value based paging is reversed.static Page
of
(int offset, int limit) Use this if you want a page of given offset and limit.toString()
static Page.Builder
with()
Use this if you want to build a new page.
-
Field Details
-
ALL
-
ONE
-
-
Constructor Details
-
Page
public Page(Integer offset, Integer limit, LinkedHashMap<String, Boolean> ordering, Map<String, Object> requiredCriteria, Map<String, Object> optionalCriteria) Creates a new Page. You can for convenience also useof(int, int)
or thewith()
builder.- Parameters:
offset
- Zero-based offset of the page. May not be negative. Defaults to 0.limit
- Maximum amount of records to be matched. May not be less than 1. Defaults toInteger.MAX_VALUE
.ordering
- Ordering of results. Map key represents property path and map value represents whether to sort ascending. Defaults to{"id",false}
.requiredCriteria
- Required criteria. Map key represents property path and map value represents criteria. Each entity must match all of given criteria.optionalCriteria
- Optional criteria. Map key represents property path and map value represents criteria. Each entity must match at least one of given criteria.
-
Page
public Page(Integer offset, Integer limit, Identifiable<?> last, Boolean reversed, LinkedHashMap<String, Boolean> ordering, Map<String, Object> requiredCriteria, Map<String, Object> optionalCriteria) Creates a new Page whereby value based paging will be performed instead of offset based paging when applicable. Value based paging is not applicable when the result type is a DTO, or when the ordering contains an aggregated field.- Parameters:
offset
- Zero-based offset of the page. May not be negative. Defaults to 0.limit
- Maximum amount of records to be matched. May not be less than 1. Defaults toInteger.MAX_VALUE
.last
- Last entity of the previous page. When notnull
, then value based paging will be performed instead of offset based paging when applicable.reversed
- Whether value based paging is reversed. This is ignored when last entity isnull
. Defaults tofalse
.ordering
- Ordering of results. Map key represents property path and map value represents whether to sort ascending. Defaults to{"id",false}
.requiredCriteria
- Required criteria. Map key represents property path and map value represents criteria. Each entity must match all of given criteria.optionalCriteria
- Optional criteria. Map key represents property path and map value represents criteria. Each entity must match at least one of given criteria.
-
-
Method Details
-
getOffset
public int getOffset()Returns the offset. Defaults to 0.- Returns:
- The offset.
-
getLimit
public int getLimit()Returns the limit. Defaults toInteger.MAX_VALUE
.- Returns:
- The limit.
-
getLast
Returns the last entity of the previous page, if any. If notnull
, then value based paging will be performed instead of offset based paging when applicable.- Returns:
- The last entity of the previous page, if any.
-
isReversed
public boolean isReversed()Returns whether the value based paging is reversed. This is only used whengetLast()
is notnull
.- Returns:
- Whether the value based paging is reversed.
-
getOrdering
Returns the ordering. Map key represents property path and map value represents whether to sort ascending. Defaults to{"id",false}
.- Returns:
- The ordering.
-
getRequiredCriteria
Returns the required criteria. Map key represents property path and map value represents criteria. Each entity must match all of given criteria.- Returns:
- The required criteria.
-
getOptionalCriteria
Returns the optional criteria. Map key represents property path and map value represents criteria. Each entity must match at least one of given criteria.- Returns:
- The optional criteria.
-
equals
-
hashCode
public int hashCode() -
toString
-
all
Returns a clone of the current page which returns all results matching the current ordering, required criteria and optional criteria.- Returns:
- A clone of the current page which returns all results matching the current ordering, required criteria and optional criteria.
-
with
Use this if you want to build a new page.- Returns:
- A new page builder.
-
of
Use this if you want a page of given offset and limit.- Parameters:
offset
- Zero-based offset of the page. May not be negative. Defaults to 0.limit
- Maximum amount of records to be matched. May not be less than 1. Defaults toInteger.MAX_VALUE
.- Returns:
- A new page of given offset and limit.
-