Class Page
- java.lang.Object
-
- org.omnifaces.persistence.model.dto.Page
-
public final class Page extends Object
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:
BaseEntityService
,Criteria
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Page.Builder
The page builder.
-
Constructor Summary
Constructors Constructor Description Page(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
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Page
all()
Returns a clone of the current page which returns all results matching the current ordering, required criteria and optional criteria.boolean
equals(Object object)
Identifiable<?>
getLast()
Returns the last entity of the previous page, if any.int
getLimit()
Returns the limit.int
getOffset()
Returns the offset.Map<String,Object>
getOptionalCriteria()
Returns the optional criteria.Map<String,Boolean>
getOrdering()
Returns the ordering.Map<String,Object>
getRequiredCriteria()
Returns the required criteria.int
hashCode()
boolean
isReversed()
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.String
toString()
static Page.Builder
with()
Use this if you want to build a new page.
-
-
-
Constructor Detail
-
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 Detail
-
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
public Identifiable<?> 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
public Map<String,Boolean> 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
public Map<String,Object> 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
public Map<String,Object> 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.
-
all
public Page 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
public static Page.Builder with()
Use this if you want to build a new page.- Returns:
- A new page builder.
-
of
public static Page of(int offset, int limit)
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.
-
-