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>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Build the Connection - can only be called once.withLimit(int limit) Set a limit on the number of items returned by the connection.withNextPage(boolean b) Force the "has next page" value, in case the supplied data doesn't expose that but a new query would find itwithPreviousPage(boolean b) Force the "has previous page" value, in case the supplied data doesn't expose that but a new query would find it.withStartAfter(@Nullable Cursor c) If set, the connection will skip to the first item after thecCursor.
-
Constructor Details
-
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 Details
-
withLimit
Set a limit on the number of items returned by the connection.- Parameters:
limit- must be <= MAX_LIMIT- Returns:
- this builder
-
withStartAfter
If set, the connection will skip to the first item after thecCursor.- Parameters:
c- the cursor forstartAfter- Returns:
- this builder
-
withPreviousPage
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
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
Build the Connection - can only be called once.- Returns:
- a
Connection
-