Class GenericConnection.Builder<T>

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