Package com.fauna.event
Class FeedPage<E>
- java.lang.Object
-
- com.fauna.event.FeedPage<E>
-
- Type Parameters:
E
- The type of data contained in each event.
public class FeedPage<E> extends java.lang.Object
Represents a page of events from an Event Feed.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FeedPage.Builder<E>
Builder class for constructingFeedPage
instances.
-
Constructor Summary
Constructors Constructor Description FeedPage(java.util.List<FaunaEvent<E>> events, java.lang.String cursor, boolean hasNext, QueryStats stats)
Constructs aFeedPage
with the specified events, cursor, pagination flag, and statistics.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E> FeedPage.Builder<E>
builder(Codec<E> elementCodec, StatsCollector statsCollector)
Creates a newBuilder
for constructing aFeedPage
.java.lang.String
getCursor()
Retrieves the cursor for pagination.java.util.List<FaunaEvent<E>>
getEvents()
Retrieves the list of events in this feed page.QueryStats
getStats()
Retrieves the statistics for this feed page.boolean
hasNext()
Checks if there are more pages available.static <E> FeedPage<E>
parseResponse(java.net.http.HttpResponse<java.io.InputStream> response, Codec<E> elementCodec, StatsCollector statsCollector)
Parses an HTTP response and constructs aFeedPage
instance.
-
-
-
Constructor Detail
-
FeedPage
public FeedPage(java.util.List<FaunaEvent<E>> events, java.lang.String cursor, boolean hasNext, QueryStats stats)
Constructs aFeedPage
with the specified events, cursor, pagination flag, and statistics.- Parameters:
events
- A list ofFaunaEvent
objects representing the events in this page.cursor
- AString
representing the cursor for pagination.hasNext
- Aboolean
indicating if there are more pages available.stats
- AQueryStats
object containing statistics for the page.- Throws:
java.lang.IllegalArgumentException
- ifevents
is null orcursor
is blank.
-
-
Method Detail
-
getEvents
public java.util.List<FaunaEvent<E>> getEvents()
Retrieves the list of events in this feed page.- Returns:
- A
List
ofFaunaEvent
objects.
-
getCursor
public java.lang.String getCursor()
Retrieves the cursor for pagination.- Returns:
- A
String
representing the cursor.
-
hasNext
public boolean hasNext()
Checks if there are more pages available.- Returns:
true
if there are more pages,false
otherwise.
-
getStats
public QueryStats getStats()
Retrieves the statistics for this feed page.- Returns:
- A
QueryStats
object.
-
builder
public static <E> FeedPage.Builder<E> builder(Codec<E> elementCodec, StatsCollector statsCollector)
Creates a newBuilder
for constructing aFeedPage
.- Type Parameters:
E
- The type of data contained in each event.- Parameters:
elementCodec
- TheCodec
used to decode events.statsCollector
- TheStatsCollector
to gather statistics.- Returns:
- A new
Builder
instance.
-
parseResponse
public static <E> FeedPage<E> parseResponse(java.net.http.HttpResponse<java.io.InputStream> response, Codec<E> elementCodec, StatsCollector statsCollector)
Parses an HTTP response and constructs aFeedPage
instance.- Type Parameters:
E
- The type of data contained in each event.- Parameters:
response
- TheHttpResponse
containing the feed data.elementCodec
- TheCodec
used to decode events.statsCollector
- TheStatsCollector
to gather statistics.- Returns:
- The parsed
FeedPage
. - Throws:
ClientResponseException
- if an error occurs while parsing the feed response.
-
-