Class SearchResultsBatchWorkSource<T>
- java.lang.Object
-
- com.atlassian.confluence.content.render.xhtml.migration.macro.SearchResultsBatchWorkSource<T>
-
- All Implemented Interfaces:
BatchableWorkSource<T>
public class SearchResultsBatchWorkSource<T> extends Object implements BatchableWorkSource<T>
Provides a worksource from a searchQuery, the query should return searchResults that can be converted ContentEntityObjects
-
-
Constructor Summary
Constructors Constructor Description SearchResultsBatchWorkSource(SearchManager searchManager, List<SearchResult> searchResults, int batchSize, com.google.common.base.Function<Searchable,T> transformer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<T>
getBatch()
gets the list of entities that form the batch.int
getTotalSize()
boolean
hasMoreBatches()
int
numberOfBatches()
void
reset(int total)
Reset the work source ready to begin getting batches again.
-
-
-
Constructor Detail
-
SearchResultsBatchWorkSource
public SearchResultsBatchWorkSource(SearchManager searchManager, List<SearchResult> searchResults, int batchSize, com.google.common.base.Function<Searchable,T> transformer)
- Parameters:
searchManager
-searchResults
-batchSize
-transformer
- - the function used to transform the list of Searchables returned from the query to the type required by the batch, may also perform filtering, so it is safe for the apply method to return null, the apply method should also accept null values.
-
-
Method Detail
-
getBatch
public List<T> getBatch()
gets the list of entities that form the batch. The list is retrieved by executing the query and converting the search result to a list of entities, it is only then that the transformer is returned, so the number of entities per batch as returned from this method may differ from the batch size, and may in fact be empty. An empty list returned from this method does not connote that there are no more batches, rather @see hasMoreBatches- Specified by:
getBatch
in interfaceBatchableWorkSource<T>
- Returns:
- the entities in this batch, the list does not contain any null values.
-
hasMoreBatches
public boolean hasMoreBatches()
- Specified by:
hasMoreBatches
in interfaceBatchableWorkSource<T>
- Returns:
- true if more work batches exist
-
numberOfBatches
public int numberOfBatches()
- Specified by:
numberOfBatches
in interfaceBatchableWorkSource<T>
- Returns:
- total number of work batches available.
-
reset
public void reset(int total)
Description copied from interface:BatchableWorkSource
Reset the work source ready to begin getting batches again.- Specified by:
reset
in interfaceBatchableWorkSource<T>
-
getTotalSize
public int getTotalSize()
- Specified by:
getTotalSize
in interfaceBatchableWorkSource<T>
-
-