public static class GenericConnection.Builder<T> extends Object
| Constructor and Description |
|---|
Builder(@NotNull Iterator<T> dataIterator,
@NotNull Function<T,String> cursorStringProvider)
Builder for a Connection that will output the supplied data, optionally skipping items
at the beginning and considering a set maximum of items.
|
| Modifier and Type | Method and Description |
|---|---|
Connection<T> |
build()
Build the Connection - can only be called once.
|
GenericConnection.Builder<T> |
withLimit(int limit)
Set a limit on the number of items returned by the connection.
|
GenericConnection.Builder<T> |
withNextPage(boolean b)
Force the "has next page" value, in case the supplied data doesn't expose that but a new query would find it
|
GenericConnection.Builder<T> |
withPreviousPage(boolean b)
Force the "has previous page" value, in case the supplied data doesn't expose that but a new query would find it.
|
GenericConnection.Builder<T> |
withStartAfter(@Nullable Cursor c)
If set, the connection will skip to the first item after the
c Cursor. |
public Builder(@NotNull
@NotNull Iterator<T> dataIterator,
@NotNull
@NotNull Function<T,String> cursorStringProvider)
dataIterator - the connection's data - must include the item that startAfter points to if that
Cursor is set, but can contain less items that set by the "limit" parameter.cursorStringProvider - extracts a String from an object of type T to create a Cursorpublic GenericConnection.Builder<T> withLimit(int limit)
limit - must be <= MAX_LIMITpublic GenericConnection.Builder<T> withStartAfter(@Nullable @Nullable Cursor c)
c Cursor.c - the cursor for startAfterpublic GenericConnection.Builder<T> withPreviousPage(boolean b)
b - a boolean that can force the hasPreviousPagepublic GenericConnection.Builder<T> withNextPage(boolean b)
b - a boolean that can force the hasNextPagepublic Connection<T> build()
ConnectionCopyright © 2007–2021 The Apache Software Foundation. All rights reserved.