Class FeedPage.Builder<E>

  • Type Parameters:
    E - The type of data contained in each event.
    Enclosing class:
    FeedPage<E>

    public static class FeedPage.Builder<E>
    extends java.lang.Object
    Builder class for constructing FeedPage instances.
    • Constructor Summary

      Constructors 
      Constructor Description
      Builder​(Codec<E> elementCodec, StatsCollector statsCollector)
      Constructs a Builder with the specified codec and stats collector.
    • Constructor Detail

      • Builder

        public Builder​(Codec<E> elementCodec,
                       StatsCollector statsCollector)
        Constructs a Builder with the specified codec and stats collector.
        Parameters:
        elementCodec - The Codec used to decode events.
        statsCollector - The StatsCollector to gather statistics for the feed.
    • Method Detail

      • events

        public FeedPage.Builder<E> events​(java.util.List<FaunaEvent<E>> events)
        Sets the list of events for the feed page.
        Parameters:
        events - A list of FaunaEvent objects representing the events in this page.
        Returns:
        This Builder instance.
      • cursor

        public FeedPage.Builder<E> cursor​(java.lang.String cursor)
        Sets the cursor for pagination.
        Parameters:
        cursor - A String representing the cursor.
        Returns:
        This Builder instance.
      • hasNext

        public FeedPage.Builder<E> hasNext​(java.lang.Boolean hasNext)
        Sets the flag indicating if there are more pages available.
        Parameters:
        hasNext - A Boolean indicating if there are more pages.
        Returns:
        This Builder instance.
      • stats

        public FeedPage.Builder<E> stats​(QueryStats stats)
        Sets the statistics for the feed page.
        Parameters:
        stats - A QueryStats object containing statistics for the page.
        Returns:
        This Builder instance.
      • parseEvents

        public FeedPage.Builder<E> parseEvents​(com.fasterxml.jackson.core.JsonParser parser)
                                        throws java.io.IOException
        Parses and sets the list of events from the provided JSON parser.
        Parameters:
        parser - The JsonParser to decode the events from.
        Returns:
        This Builder instance.
        Throws:
        java.io.IOException - if an error occurs during parsing.
      • build

        public FeedPage<E> build()
        Builds a new FeedPage instance with the configured parameters.
        Returns:
        A new FeedPage instance.
        Throws:
        java.lang.IllegalArgumentException - if events is null or cursor is blank.
      • parseField

        public FeedPage.Builder<E> parseField​(com.fasterxml.jackson.core.JsonParser parser)
                                       throws java.io.IOException
        Parses and sets the appropriate field in the builder based on the JSON parser's current field.
        Parameters:
        parser - The JsonParser for reading the field value.
        Returns:
        The updated Builder instance.
        Throws:
        java.io.IOException - if an error occurs during parsing.