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.ObjectRepresents an event emitted in an Event Feed or Event Stream.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFaunaEvent.Builder<E>Builder class for constructing aFaunaEventinstance.static classFaunaEvent.EventTypeEnum 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 newFaunaEventwith 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 newBuilderfor constructing aFaunaEvent.java.lang.StringgetCursor()Retrieves the cursor for this event.java.util.Optional<E>getData()Retrieves the Fauna document data associated with this event.ErrorInfogetError()Retrieves the error information for this event, if any.QueryStatsgetStats()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.EventTypegetType()Retrieves the type of this event.static <E> FaunaEvent<E>parse(com.fasterxml.jackson.core.JsonParser parser, Codec<E> dataCodec)Parses aFaunaEventfrom 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 newFaunaEventwith 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.EventTypeof this event.
-
getData
public java.util.Optional<E> getData()
Retrieves the Fauna document data associated with this event.- Returns:
- An
Optionalcontaining 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
Optionalcontaining the transaction timestamp, or empty if not present.
-
getCursor
public java.lang.String getCursor()
Retrieves the cursor for this event.- Returns:
- A
Stringrepresenting the cursor.
-
getStats
public QueryStats getStats()
Retrieves stats associated with this event.- Returns:
- A
QueryStatsobject representing the statistics.
-
getError
public ErrorInfo getError()
Retrieves the error information for this event, if any.- Returns:
- An
ErrorInfoobject containing error details, ornullif no error is present.
-
builder
public static <E> FaunaEvent.Builder<E> builder(Codec<E> dataCodec)
Creates a newBuilderfor constructing aFaunaEvent.- Type Parameters:
E- The type of data contained in the event.- Parameters:
dataCodec- TheCodecused to decode event data.- Returns:
- A new
Builderinstance.
-
parse
public static <E> FaunaEvent<E> parse(com.fasterxml.jackson.core.JsonParser parser, Codec<E> dataCodec) throws java.io.IOException
Parses aFaunaEventfrom the JSON parser using the specified codec.- Type Parameters:
E- The type of data contained in the event.- Parameters:
parser- TheJsonParserpositioned at the start of the event.dataCodec- TheCodecused to decode event data.- Returns:
- The parsed
FaunaEvent. - Throws:
java.io.IOException- If an error occurs while parsing.
-
-