Package com.fauna.event
Class FaunaEvent<E>
- java.lang.Object
-
- com.fauna.event.FaunaEvent<E>
-
- Type Parameters:
E
- The type of data contained in the event.
public final class FaunaEvent<E> extends java.lang.Object
Represents an event emitted in an Event Feed or Event Stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
FaunaEvent.Builder<E>
Builder class for constructing aFaunaEvent
instance.static class
FaunaEvent.EventType
Enum representing possible event types from a Fauna event source.
-
Constructor Summary
Constructors Constructor Description FaunaEvent(FaunaEvent.EventType type, java.lang.String cursor, java.lang.Long txnTs, E data, QueryStats stats, ErrorInfo error)
Constructs a newFaunaEvent
with the specified properties.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <E> FaunaEvent.Builder<E>
builder(Codec<E> dataCodec)
Creates a newBuilder
for constructing aFaunaEvent
.java.lang.String
getCursor()
Retrieves the cursor for this event.java.util.Optional<E>
getData()
Retrieves the Fauna document data associated with this event.ErrorInfo
getError()
Retrieves the error information for this event, if any.QueryStats
getStats()
Retrieves stats associated with this event.java.util.Optional<java.lang.Long>
getTimestamp()
Retrieves the transaction timestamp for the document change that triggered the event.FaunaEvent.EventType
getType()
Retrieves the type of this event.static <E> FaunaEvent<E>
parse(com.fasterxml.jackson.core.JsonParser parser, Codec<E> dataCodec)
Parses aFaunaEvent
from the JSON parser using the specified codec.
-
-
-
Constructor Detail
-
FaunaEvent
public FaunaEvent(FaunaEvent.EventType type, java.lang.String cursor, java.lang.Long txnTs, E data, QueryStats stats, ErrorInfo error)
Constructs a newFaunaEvent
with the specified properties.- Parameters:
type
- The type of the event.cursor
- The cursor for the event.txnTs
- The transaction timestamp for the document change that triggered the event.data
- The data for the document that triggered the event.stats
- The event stats.error
- The error information for the event, if any.
-
-
Method Detail
-
getType
public FaunaEvent.EventType getType()
Retrieves the type of this event.- Returns:
- The
FaunaEvent.EventType
of this event.
-
getData
public java.util.Optional<E> getData()
Retrieves the Fauna document data associated with this event.- Returns:
- An
Optional
containing the event data, or empty if no data is available.
-
getTimestamp
public java.util.Optional<java.lang.Long> getTimestamp()
Retrieves the transaction timestamp for the document change that triggered the event.- Returns:
- An
Optional
containing the transaction timestamp, or empty if not present.
-
getCursor
public java.lang.String getCursor()
Retrieves the cursor for this event.- Returns:
- A
String
representing the cursor.
-
getStats
public QueryStats getStats()
Retrieves stats associated with this event.- Returns:
- A
QueryStats
object representing the statistics.
-
getError
public ErrorInfo getError()
Retrieves the error information for this event, if any.- Returns:
- An
ErrorInfo
object containing error details, ornull
if no error is present.
-
builder
public static <E> FaunaEvent.Builder<E> builder(Codec<E> dataCodec)
Creates a newBuilder
for constructing aFaunaEvent
.- Type Parameters:
E
- The type of data contained in the event.- Parameters:
dataCodec
- TheCodec
used to decode event data.- Returns:
- A new
Builder
instance.
-
parse
public static <E> FaunaEvent<E> parse(com.fasterxml.jackson.core.JsonParser parser, Codec<E> dataCodec) throws java.io.IOException
Parses aFaunaEvent
from the JSON parser using the specified codec.- Type Parameters:
E
- The type of data contained in the event.- Parameters:
parser
- TheJsonParser
positioned at the start of the event.dataCodec
- TheCodec
used to decode event data.- Returns:
- The parsed
FaunaEvent
. - Throws:
java.io.IOException
- If an error occurs while parsing.
-
-