public class WindowQueryList<T> extends Object implements QueryList<T>
QueryList implementation that only actually holds a portion, or "window" of a larger list.
If a list element outside the "window" is accessed, an InvalidQueryListException is thrown,
prompting another query.AbstractQueryContainer| Constructor and Description |
|---|
WindowQueryList(List<? extends T> list,
int offset,
int count)
Constructor when the original list is given with window bounds.
|
WindowQueryList(long offset,
List<? extends T> window,
long totalSize)
Constructor when a "window" list is given with its position in the original list.
|
| Modifier and Type | Method and Description |
|---|---|
T |
get(long index)
Get an item in the list, or throw an exception if this instance is no longer valid
or cannot provide the item.
|
long |
size()
Get the total size of this list.
|
public WindowQueryList(List<? extends T> list, int offset, int count)
list - original list from which to cache elementsoffset - index in the list of the first element in the windowcount - number of elements in the windowIllegalArgumentException - if list is nullIllegalArgumentException - if offset and/or count are invalidpublic WindowQueryList(long offset,
List<? extends T> window,
long totalSize)
window - list of only those elements in the "window"offset - offset of the "window" in the original listtotalSize - total size of the original listIllegalArgumentException - if window is nullIllegalArgumentException - if offset < 0IllegalArgumentException - if offset + window.size() > totalSizepublic long size()
QueryList
For any given QueryList instance, this method is expected to return a the same value if invoked multiple times.
Therefore, callers may safely choose to invoke it only once on a given instance and cache the result.
public T get(long index) throws InvalidQueryListException
QueryListget in interface QueryList<T>index - index of the item (zero-based)indexInvalidQueryListException - if this list has become invalid or cannot provide the itemCopyright © 2017. All rights reserved.