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

## Constructor Summary

Constructors
Constructor
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.

## Method Summary

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 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`.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## 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

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 the `c` `Cursor`.

Parameters:
  `c` - the cursor for `startAfter`
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` - a `boolean` that can force the `hasPreviousPage`
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` - a `boolean` that can force the `hasNextPage`
Returns:
  this builder

### build

public Connection<T> build()
Build the Connection - can only be called once.

Returns:
  a `Connection`