Record Class AppendCondition

java.lang.Object
java.lang.Record
io.umadb.client.AppendCondition
Record Components:
failIfEventsMatch - a non-null query defining events that must not already exist for the append operation to succeed
after - an optional position after which the condition applies; may be null to indicate no lower bound

public record AppendCondition(Query failIfEventsMatch, Long after) extends Record
Represents a conditional constraint applied when appending events.

The append operation will fail if events matching the provided failIfEventsMatch query already exist. Optionally, the condition can be further constrained to only consider events occurring after a given position.

  • Constructor Details

    • AppendCondition

      public AppendCondition(Query failIfEventsMatch, Long after)
      Creates a new AppendCondition.
      Throws:
      IllegalArgumentException - if failIfEventsMatch is null
  • Method Details

    • failIfExists

      public static AppendCondition failIfExists(Query query)
      Creates an AppendCondition that fails the append operation if any events matching the given query already exist.
      Parameters:
      query - the query defining events that must not exist
      Returns:
      a new AppendCondition
      Throws:
      IllegalArgumentException - if query is null
    • failIfExistsAfter

      public static AppendCondition failIfExistsAfter(Query query, long after)
      Creates an AppendCondition that fails the append operation if events matching the given query exist after the specified position.
      Parameters:
      query - the query defining events that must not exist
      after - the lower bound (position or timestamp) after which matching events are considered
      Returns:
      a new AppendCondition
      Throws:
      IllegalArgumentException - if query is null
    • after

      public AppendCondition after(long after)
      Returns a copy of this condition that applies only to events occurring after the specified position or timestamp.

      This method is useful for fluently refining an existing condition.

      Parameters:
      after - the lower bound (position or timestamp)
      Returns:
      a new AppendCondition with the updated after value
    • 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.
    • failIfEventsMatch

      public Query failIfEventsMatch()
      Returns the value of the failIfEventsMatch record component.
      Returns:
      the value of the failIfEventsMatch record component
    • after

      public Long after()
      Returns the value of the after record component.
      Returns:
      the value of the after record component