Class 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 a FaunaEvent 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 new FaunaEvent 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 new Builder for constructing a FaunaEvent.
      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 a FaunaEvent from the JSON parser using the specified codec.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • FaunaEvent

        public FaunaEvent​(FaunaEvent.EventType type,
                          java.lang.String cursor,
                          java.lang.Long txnTs,
                          E data,
                          QueryStats stats,
                          ErrorInfo error)
        Constructs a new FaunaEvent 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

      • 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, or null if no error is present.
      • builder

        public static <E> FaunaEvent.Builder<E> builder​(Codec<E> dataCodec)
        Creates a new Builder for constructing a FaunaEvent.
        Type Parameters:
        E - The type of data contained in the event.
        Parameters:
        dataCodec - The Codec 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 a FaunaEvent from the JSON parser using the specified codec.
        Type Parameters:
        E - The type of data contained in the event.
        Parameters:
        parser - The JsonParser positioned at the start of the event.
        dataCodec - The Codec used to decode event data.
        Returns:
        The parsed FaunaEvent.
        Throws:
        java.io.IOException - If an error occurs while parsing.