public final class Cursors extends Object
| Modifier and Type | Method and Description |
|---|---|
static <T> Cursor<T> |
empty()
Create an empty cursor.
|
static <T> Cursor<T> |
filter(Cursor<?> cursor,
Class<T> type)
Filter a cursor to only contain elements of type .
|
static <T> Cursor<T> |
filter(Cursor<T> cursor,
com.google.common.base.Predicate<? super T> predicate)
Filter a cursor.
|
static <T> ArrayList<T> |
makeList(Cursor<? extends T> cursor)
Read a cursor into a list, closing when it is finished.
|
static <T> Cursor<T> |
sort(Cursor<T> cursor,
Comparator<? super T> comp)
Sort a cursor.
|
static <S,T> Cursor<T> |
transform(Cursor<S> cursor,
com.google.common.base.Function<? super S,? extends T> function)
Transform a cursor's values.
|
static <T> Cursor<T> |
wrap(Collection<? extends T> collection)
Wrap a collection in a cursor.
|
static <T> Cursor<T> |
wrap(Iterator<? extends T> iterator)
Wrap an iterator in a cursor.
|
public static <T> Cursor<T> wrap(Iterator<? extends T> iterator)
T - The type of data to return.iterator - An iterator to wrappublic static <T> Cursor<T> wrap(Collection<? extends T> collection)
T - The type of data to return.collection - A collection to wrappublic static <T> Cursor<T> filter(@WillCloseWhenClosed Cursor<T> cursor, com.google.common.base.Predicate<? super T> predicate)
T - The type of cursor rows.cursor - The source cursor.predicate - A predicate indicating which rows to return.true.public static <T> Cursor<T> filter(@WillCloseWhenClosed Cursor<?> cursor, Class<T> type)
filter(Cursor, Predicate) with a predicate from
Predicates.instanceOf(Class), this method also transforms the
cursor to be of the target type.T - The type of value in the cursor.cursor - The source cursor.type - The type to filter.public static <S,T> Cursor<T> transform(@WillCloseWhenClosed Cursor<S> cursor, com.google.common.base.Function<? super S,? extends T> function)
S - The type of source cursor rowsT - The type of output cursor rowscursor - The source cursorfunction - A function to apply to each row in the cursor.public static <T> Cursor<T> empty()
T - The type of value in the cursor.public static <T> ArrayList<T> makeList(@WillClose Cursor<? extends T> cursor)
T - The type of item in the cursor.cursor - The cursor.Cursor.getRowCount() if possible,
but has not been trimmed.public static <T> Cursor<T> sort(@WillClose Cursor<T> cursor, Comparator<? super T> comp)
T - The type of value in the cursor.cursor - The cursor to sort.comp - The comparator to use to sort the cursor.Copyright © 2013 GroupLens Research. All Rights Reserved.