Record Class ReadRequest

java.lang.Object
java.lang.Record
io.umadb.client.ReadRequest
Record Components:
query - optional filter for selecting specific event types or tags; may be null to read all events
start - optional sequence number to start reading from; must be >= 0 if provided
backwards - optional flag to read in reverse order; defaults to false if null
limit - optional maximum number of events to return; must be > 0 if provided
subscribe - optional flag to keep the stream open; defaults to false if null
batchSize - optional batch size hint for streaming responses; must be > 0 if provided

public record ReadRequest(Query query, Long start, Boolean backwards, Integer limit, Boolean subscribe, Integer batchSize) extends Record
Represents a request to read events from the event store.

A ReadRequest can be sent to the Read RPC to retrieve events matching a Query. Optional fields allow controlling the starting position, reading direction, maximum number of events, subscription mode, and batch size.

Defaults:

  • backwards defaults to false
  • subscribe defaults to false
  • start, limit, and batchSize are optional
  • Constructor Details

    • ReadRequest

      public ReadRequest(Query query, Long start, Boolean backwards, Integer limit, Boolean subscribe, Integer batchSize)
      Creates an instance of a ReadRequest record class.
      Parameters:
      query - the value for the query record component
      start - the value for the start record component
      backwards - the value for the backwards record component
      limit - the value for the limit record component
      subscribe - the value for the subscribe record component
      batchSize - the value for the batchSize record component
  • Method Details

    • all

      public static ReadRequest all()
      Creates a minimal ReadRequest selecting all events from the beginning.
      Returns:
      a ReadRequest with default parameters
    • of

      public static ReadRequest of(Query query)
      Creates a ReadRequest for a specific query.
      Parameters:
      query - the query to filter events; may be null to read all events
      Returns:
      a ReadRequest with default parameters
    • subscribe

      public ReadRequest subscribe(Integer batchSize)
      Returns a copy of this request with subscription enabled.
      Parameters:
      batchSize - optional batch size hint for streaming; may be null
      Returns:
      a new ReadRequest with subscription enabled
    • withStart

      public ReadRequest withStart(long start)
      Returns a copy of this request with a specified start position.
      Parameters:
      start - sequence number to start reading from
      Returns:
      a new ReadRequest with the specified start
    • withDirection

      public ReadRequest withDirection(boolean backwards)
      Returns a copy of this request with a specified read direction.
      Parameters:
      backwards - true to read in reverse order
      Returns:
      a new ReadRequest with the specified direction
    • withLimit

      public ReadRequest withLimit(int limit)
      Returns a copy of this request with a specified limit.
      Parameters:
      limit - maximum number of events to return
      Returns:
      a new ReadRequest with the specified limit
    • 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.
    • query

      public Query query()
      Returns the value of the query record component.
      Returns:
      the value of the query record component
    • start

      public Long start()
      Returns the value of the start record component.
      Returns:
      the value of the start record component
    • backwards

      public Boolean backwards()
      Returns the value of the backwards record component.
      Returns:
      the value of the backwards record component
    • limit

      public Integer limit()
      Returns the value of the limit record component.
      Returns:
      the value of the limit record component
    • subscribe

      public Boolean subscribe()
      Returns the value of the subscribe record component.
      Returns:
      the value of the subscribe record component
    • batchSize

      public Integer batchSize()
      Returns the value of the batchSize record component.
      Returns:
      the value of the batchSize record component