Package org.dellroad.stuff.vaadin7
Class WindowQueryList<T>
- java.lang.Object
-
- org.dellroad.stuff.vaadin7.WindowQueryList<T>
-
- All Implemented Interfaces:
QueryList<T>
public class WindowQueryList<T> extends Object implements QueryList<T>
QueryListimplementation that only actually holds a portion, or "window" of a larger list. If a list element outside the "window" is accessed, anInvalidQueryListExceptionis thrown, prompting another query.- See Also:
AbstractQueryContainer
-
-
Constructor Summary
Constructors Constructor Description WindowQueryList(long offset, List<? extends T> window, long totalSize)Constructor when a "window" list is given with its position in the original list.WindowQueryList(List<? extends T> list, int offset, int count)Constructor when the original list is given with window bounds.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Tget(long index)Get an item in the list, or throw an exception if this instance is no longer valid or cannot provide the item.longsize()Get the total size of this list.
-
-
-
Constructor Detail
-
WindowQueryList
public WindowQueryList(List<? extends T> list, int offset, int count)
Constructor when the original list is given with window bounds.- Parameters:
list- original list from which to cache elementsoffset- index in the list of the first element in the windowcount- number of elements in the window- Throws:
IllegalArgumentException- iflistis nullIllegalArgumentException- ifoffsetand/orcountare invalid
-
WindowQueryList
public WindowQueryList(long offset, List<? extends T> window, long totalSize)Constructor when a "window" list is given with its position in the original list.- Parameters:
window- list of only those elements in the "window"offset- offset of the "window" in the original listtotalSize- total size of the original list- Throws:
IllegalArgumentException- ifwindowis nullIllegalArgumentException- ifoffset < 0IllegalArgumentException- ifoffset + window.size() > totalSize
-
-
Method Detail
-
size
public long size()
Description copied from interface:QueryListGet the total size of this list.For any given
QueryListinstance, 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.
-
get
public T get(long index) throws InvalidQueryListException
Description copied from interface:QueryListGet an item in the list, or throw an exception if this instance is no longer valid or cannot provide the item.- Specified by:
getin interfaceQueryList<T>- Parameters:
index- index of the item (zero-based)- Returns:
- the list item at
index - Throws:
InvalidQueryListException- if this list has become invalid or cannot provide the item
-
-