Record Class ServerSentEvent

java.lang.Object
java.lang.Record
org.a2aproject.sdk.client.http.ServerSentEvent

public record ServerSentEvent(String data, String eventType, @Nullable String id, @Nullable Long retry) extends Record
Represents a parsed Server-Sent Event (SSE).

Each instance carries the fields defined by the SSE specification:

  • data — the event payload, already concatenated from one or more data: lines
  • eventType — the event type from the event: field; never null, defaults to "message"
  • id — the event ID from the id: field; null if absent
  • retry — the reconnection interval in milliseconds from the retry: field; null if absent
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Default event type per the SSE specification when no event: field is present.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    ServerSentEvent(String data, String eventType, @Nullable String id, @Nullable Long retry)
    Creates an instance of a ServerSentEvent record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the data record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    Returns the value of the eventType record component.
    final int
    Returns a hash code value for this object.
    @Nullable String
    id()
    Returns the value of the id record component.
    @Nullable Long
    Returns the value of the retry record component.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Field Details

    • DEFAULT_EVENT_TYPE

      public static final String DEFAULT_EVENT_TYPE
      Default event type per the SSE specification when no event: field is present.
      See Also:
  • Constructor Details

    • ServerSentEvent

      public ServerSentEvent(String data, String eventType, @Nullable String id, @Nullable Long retry)
      Creates an instance of a ServerSentEvent record class.
      Parameters:
      data - the value for the data record component
      eventType - the value for the eventType record component
      id - the value for the id record component
      retry - the value for the retry record component
    • ServerSentEvent

      public ServerSentEvent(String data)
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • data

      public String data()
      Returns the value of the data record component.
      Returns:
      the value of the data record component
    • eventType

      public String eventType()
      Returns the value of the eventType record component.
      Returns:
      the value of the eventType record component
    • id

      public @Nullable String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • retry

      public @Nullable Long retry()
      Returns the value of the retry record component.
      Returns:
      the value of the retry record component