Package org.apache.sling.graphql.helpers
Class GenericConnection.Builder<T>
- java.lang.Object
-
- org.apache.sling.graphql.helpers.GenericConnection.Builder<T>
-
- Enclosing class:
- GenericConnection<T>
public static class GenericConnection.Builder<T> extends Object
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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 itGenericConnection.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 thecCursor.
-
-
-
Constructor Detail
-
Builder
public Builder(@NotNull @NotNull Iterator<T> dataIterator, @NotNull @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.- Parameters:
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 Cursor
-
-
Method Detail
-
withLimit
public GenericConnection.Builder<T> withLimit(int limit)
Set a limit on the number of items returned by the connection.- Parameters:
limit- must be <= MAX_LIMIT- Returns:
- this builder
-
withStartAfter
public GenericConnection.Builder<T> withStartAfter(@Nullable @Nullable Cursor c)
If set, the connection will skip to the first item after thecCursor.- Parameters:
c- the cursor forstartAfter- Returns:
- this builder
-
withPreviousPage
public 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.- Parameters:
b- abooleanthat can force thehasPreviousPage- Returns:
- this builder
-
withNextPage
public 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- Parameters:
b- abooleanthat can force thehasNextPage- Returns:
- this builder
-
build
public Connection<T> build()
Build the Connection - can only be called once.- Returns:
- a
Connection
-
-