Package com.atlassian.jira.ofbiz
Class PagedDatabaseIterable<E,K>
java.lang.Object
com.atlassian.jira.ofbiz.PagedDatabaseIterable<E,K>
- All Implemented Interfaces:
EnclosedIterable<E>,Sized
A abstract implementation of
EnclosedIterable that takes a list of ids and
then pages them by opening an OfBizListIterator for each page.
This implementation supports preserving the order of the elements in the returned list but will load all the elements into memory in order to do so.
This implementation uses the DatabaseIterator but implements paging and sorting on top of it.
- Since:
- v3.13
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.atlassian.jira.util.collect.EnclosedIterable
EnclosedIterable.Functions, EnclosedIterable.ListResolver<T> -
Constructor Summary
ConstructorsConstructorDescriptionPagedDatabaseIterable(List<K> ids) Use where the order of the result is not important.Use where the order of the result is important.Use where the order of the result is important. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract OfBizListIteratorcreateListIterator(List<K> ids) Create a new iterator from the subset of ids.final voidApply the sink to all elements in the Collection.Used to turn generic values into Domain objectsbooleanisEmpty()final intsize()
-
Constructor Details
-
PagedDatabaseIterable
Use where the order of the result is not important.- Parameters:
ids- a Listmust not be null
-
PagedDatabaseIterable
Use where the order of the result is important.- Parameters:
ids- a Listmust not be null keyResolver- to get a domain object's key (ie. the element in the ids list). Null if sort order is unimportant
-
PagedDatabaseIterable
Use where the order of the result is important.- Parameters:
ids- a Listmust not be null keyResolver- to get a domain object's key (ie. the element in the ids list). Null if sort order is unimportantpageSize- the size of the pages to use
-
-
Method Details
-
foreach
Description copied from interface:EnclosedIterableApply the sink to all elements in the Collection.- Specified by:
foreachin interfaceEnclosedIterable<E>
-
createListIterator
Create a new iterator from the subset of ids.- Parameters:
ids- list of ids- Returns:
- an instance of OfBizListIterator
-
getResolver
Used to turn generic values into Domain objects- Returns:
- a resolver
-
size
public final int size()- Specified by:
sizein interfaceEnclosedIterable<E>- Specified by:
sizein interfaceSized- Returns:
- the likely size of the objects passed into the sink in
EnclosedIterable.foreach(Consumer). Be careful depending on this size being exact, as in many cases its best efforts value or may be unstable due to concurrent changes.
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceEnclosedIterable<E>- Specified by:
isEmptyin interfaceSized- Returns:
- true if the there is no data behind it.
-