Class LucenePage<T,K,V>
java.lang.Object
org.springframework.data.gemfire.domain.support.AbstractSliceSupport<T>
org.springframework.data.gemfire.domain.support.AbstractPageSupport<T>
org.springframework.data.gemfire.search.lucene.support.LucenePage<T,K,V>
The
LucenePage
class is a Spring Data Page
implementation supporting Spring Data style paging
of PageableLuceneQueryResults
complete with Spring Data projections.- Since:
- 1.1.0
- Author:
- John Blum
- See Also:
-
Constructor Summary
ConstructorDescriptionLucenePage
(ProjectingLuceneAccessor template, PageableLuceneQueryResults<K, V> queryResults, int pageSize, Class<T> projectionType) Constructs a new instance ofLucenePage
initialized with the givenLucene query results
,page size
andprojection type
.LucenePage
(ProjectingLuceneAccessor template, PageableLuceneQueryResults<K, V> queryResults, int pageSize, Class<T> projectionType, LucenePage<T, K, V> previous) Constructs a new instance ofLucenePage
initialized with the givenLucene query results
,page size
,projection type
andprevious page
, if one exists. -
Method Summary
Modifier and TypeMethodDescriptionLucenePage<T,
K, V> getNext()
int
protected int
Returns the number of elements perpage
.LucenePage<T,
K, V> Returns theClass
type of the projection.protected PageableLuceneQueryResults<K,
V> Returns theLucene query results
backing thisLucenePage
.int
getSize()
protected ProjectingLuceneAccessor
Returns theProjectingLuceneAccessor
used by thisLucenePage
to perform Lucene data access operations and projections.long
int
boolean
hasNext()
boolean
<S> Page<S>
materialize
(ProjectingLuceneAccessor template, List<LuceneResultStruct<K, V>> pageOfQueryResults, Class<T> projectionType) static <T,
K, V> LucenePage<T, K, V> newLucenePage
(ProjectingLuceneAccessor template, PageableLuceneQueryResults<K, V> queryResults, int pageSize, Class<T> projectionType) Factory method used to construct a new instance ofLucenePage
initialized with the givenLucene query results
,page size
, andprojection type
.static <T,
K, V> LucenePage<T, K, V> newLucenePage
(ProjectingLuceneAccessor template, PageableLuceneQueryResults<K, V> queryResults, int pageSize, Class<T> projectionType, LucenePage<T, K, V> previousPage) Factory method used to construct a new instance ofLucenePage
initialized with the givenLucene query results
,page size
,projection type
andprevious page
, if one exists.Methods inherited from class org.springframework.data.gemfire.domain.support.AbstractSliceSupport
getNumberOfElements, getSort, hasContent, isFirst, isLast, iterator, nextPageable, previousPageable
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface org.springframework.data.domain.Slice
getNumberOfElements, getPageable, getSort, hasContent, isFirst, isLast, nextOrLastPageable, nextPageable, previousOrFirstPageable, previousPageable
-
Constructor Details
-
LucenePage
public LucenePage(ProjectingLuceneAccessor template, PageableLuceneQueryResults<K, V> queryResults, int pageSize, Class<T> projectionType) Constructs a new instance ofLucenePage
initialized with the givenLucene query results
,page size
andprojection type
. Theprevious page
is set to null.- Parameters:
template
-ProjectingLuceneAccessor
used to perform Lucene queries and data access operations along with projections.queryResults
-PageableLuceneQueryResults
wrapped by thisLucenePage
.pageSize
- number of elements on aLucenePage
.projectionType
-Class
type of the projection used to view an individualLuceneResultStruct
in theLucene query results
.- Throws:
IllegalArgumentException
- ifProjectingLuceneAccessor
or thePageableLuceneQueryResults
are null, or thePageableLuceneQueryResults
do not have anext page
.- See Also:
-
LucenePage
public LucenePage(ProjectingLuceneAccessor template, PageableLuceneQueryResults<K, V> queryResults, int pageSize, Class<T> projectionType, LucenePage<T, K, V> previous) Constructs a new instance ofLucenePage
initialized with the givenLucene query results
,page size
,projection type
andprevious page
, if one exists.- Parameters:
template
-ProjectingLuceneAccessor
used to perform Lucene queries and data access operations along with projections.queryResults
-PageableLuceneQueryResults
wrapped by thisLucenePage
.pageSize
- number of elements on aLucenePage
.projectionType
-Class
type of the projection used to view an individualLuceneResultStruct
in theLucene query results
.previous
-previous page
in the chain ofpages
, if thisLucenePage
is not the firstLucenePage
. Can be null.- Throws:
IllegalArgumentException
- ifProjectingLuceneAccessor
or thePageableLuceneQueryResults
are null, or thePageableLuceneQueryResults
do not have anext page
.- See Also:
-
-
Method Details
-
newLucenePage
public static <T,K, LucenePage<T,V> K, newLucenePageV> (ProjectingLuceneAccessor template, PageableLuceneQueryResults<K, V> queryResults, int pageSize, Class<T> projectionType) Factory method used to construct a new instance ofLucenePage
initialized with the givenLucene query results
,page size
, andprojection type
. Theprevious page
is set to null.- Parameters:
template
-ProjectingLuceneAccessor
used to perform Lucene queries and data access operations along with projections.queryResults
-PageableLuceneQueryResults
wrapped by thisLucenePage
.pageSize
- number of elements on aLucenePage
.projectionType
-Class
type of the projection used to view an individualLuceneResultStruct
in theLucene query results
.- Throws:
IllegalArgumentException
- ifProjectingLuceneAccessor
or thePageableLuceneQueryResults
are null, or thePageableLuceneQueryResults
do not have anext page
.- See Also:
-
newLucenePage
public static <T,K, LucenePage<T,V> K, newLucenePageV> (ProjectingLuceneAccessor template, PageableLuceneQueryResults<K, V> queryResults, int pageSize, Class<T> projectionType, LucenePage<T, K, V> previousPage) Factory method used to construct a new instance ofLucenePage
initialized with the givenLucene query results
,page size
,projection type
andprevious page
, if one exists.- Parameters:
template
-ProjectingLuceneAccessor
used to perform Lucene queries and data access operations along with projections.queryResults
-PageableLuceneQueryResults
wrapped by thisLucenePage
.pageSize
- number of elements on aLucenePage
.projectionType
-Class
type of the projection used to view an individualLuceneResultStruct
in theLucene query results
.previousPage
-previous page
in the chain ofpages
, if thisLucenePage
is not the firstLucenePage
. Can be null.- Throws:
IllegalArgumentException
- ifProjectingLuceneAccessor
or thePageableLuceneQueryResults
are null, or thePageableLuceneQueryResults
do not have anext page
.- See Also:
-
materialize
protected List<T> materialize(ProjectingLuceneAccessor template, List<LuceneResultStruct<K, V>> pageOfQueryResults, Class<T> projectionType) - Parameters:
template
-ProjectingLuceneAccessor
used to project the desired values from theList
ofLuceneResultStruct
objects.pageOfQueryResults
- Lucene query results captured in theList
ofLuceneResultStruct
objects.projectionType
-Class
type to project theLuceneResultStruct
objects as.- Returns:
- a
List
of projected values of the givenprojection type
. - See Also:
-
getPageSize
protected int getPageSize()Returns the number of elements perpage
.- Returns:
- an integer value indicating the number of elements on a
page
.
-
getProjectionType
Returns theClass
type of the projection.- Returns:
- a
Class
specifying the projection type.
-
getQueryResults
Returns theLucene query results
backing thisLucenePage
.- Returns:
- a reference to the
PageableLuceneQueryResults
backing thisLucenePage
. - See Also:
-
getTemplate
Returns theProjectingLuceneAccessor
used by thisLucenePage
to perform Lucene data access operations and projections.- Returns:
- the
ProjectingLuceneAccessor
used by thisLucenePage
to perform Lucene data access operations and projections. - See Also:
-
hasNext
public boolean hasNext() -
hasPrevious
public boolean hasPrevious()- Specified by:
hasPrevious
in interfaceSlice<T>
- Overrides:
hasPrevious
in classAbstractSliceSupport<T>
-
getContent
- Specified by:
getContent
in interfaceSlice<T>
- Overrides:
getContent
in classAbstractSliceSupport<T>
-
getNext
- Returns:
- the next
page
in the collection ofpages
. - Throws:
IllegalStateException
- if no morepages
exist beyond thispage
.- See Also:
-
getNumber
public int getNumber() -
getPrevious
- Returns:
- the previous
page
in the collection ofpages
or null if noLucenePage
proceeds thispage
. - See Also:
-
getSize
public int getSize() -
getTotalElements
public long getTotalElements()- Specified by:
getTotalElements
in interfacePage<T>
- Overrides:
getTotalElements
in classAbstractPageSupport<T>
-
getTotalPages
public int getTotalPages()- Specified by:
getTotalPages
in interfacePage<T>
- Overrides:
getTotalPages
in classAbstractPageSupport<T>
-
map
-