Interface Event<T>

  • Type Parameters:
    T - The event type

    public interface Event<T>
    Represents a Server Sent Event. See https://www.w3.org/TR/2011/WD-eventsource-20111020/.
    Since:
    1.0
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static java.lang.String DATA
      The data parameter.
      static java.lang.String EVENT
      The event parameter.
      static java.lang.String ID
      The id parameter.
      static java.lang.String RETRY
      The retry parameter.
    • Method Detail

      • getData

        T getData()
        Returns:
        The data object to write
      • getId

        java.lang.String getId()
        Returns:
        The ID of the event, or null if there is no ID
      • getName

        java.lang.String getName()
        Returns:
        The name of the event
      • getComment

        java.lang.String getComment()
        Returns:
        A comment for the event, or null if there is no comment
      • getRetry

        java.time.Duration getRetry()
        Returns:
        The duration to retry
      • retry

        Event<T> retry​(@Nullable
                       java.time.Duration duration)
        Sets the retry duration.
        Parameters:
        duration - The duration
        Returns:
        The event
      • id

        Event<T> id​(@Nullable
                    java.lang.String id)
        Sets the id.
        Parameters:
        id - The id to set
        Returns:
        The event
      • name

        Event<T> name​(@Nullable
                      java.lang.String name)
        Sets the event name.
        Parameters:
        name - The event name
        Returns:
        The event
      • comment

        Event<T> comment​(@Nullable
                         java.lang.String comment)
        Sets the event comment.
        Parameters:
        comment - The Event comment
        Returns:
        The event
      • of

        static <ET> Event<ET> of​(ET data)
        Constructs a new event for the given data.
        Type Parameters:
        ET - The data type
        Parameters:
        data - The data
        Returns:
        The event instance
      • of

        static <ET> Event<ET> of​(Event event,
                                 ET data)
        Constructs a new event for the given data.
        Type Parameters:
        ET - The data type
        Parameters:
        event - The event
        data - The data
        Returns:
        The event instance