Record Class Snapshot

java.lang.Object
java.lang.Record
org.axonframework.eventsourcing.snapshot.api.Snapshot
Record Components:
position - the position in the event stream corresponding to this snapshot, never null
version - the entity's version at the time of this snapshot, never null
payload - the payload to associate with the snapshot, never null
timestamp - the timestamp to associate with the snapshot, never null
metadata - the metadata to associate with the snapshot, never null

public record Snapshot(Position position, String version, Object payload, Instant timestamp, Map<String,String> metadata) extends Record
Represents a snapshot of an entity at a specific position in the event stream.

A snapshot captures the state of the entity at a given point, allowing the entity to be sourced from this state instead of from scratch.

Since:
5.1.0
Author:
John Hendrikx
  • Constructor Details

  • Method Details

    • payload

      public Snapshot payload(Object payload)
      Creates a copy of this snapshot with the given payload.
      Parameters:
      payload - the new payload, cannot be null
      Returns:
      a new snapshot, never null
    • 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.
    • position

      public Position position()
      Returns the value of the position record component.
      Returns:
      the value of the position record component
    • version

      public String version()
      Returns the value of the version record component.
      Returns:
      the value of the version record component
    • payload

      public Object payload()
      Returns the value of the payload record component.
      Returns:
      the value of the payload record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Returns:
      the value of the timestamp record component
    • metadata

      public Map<String,String> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component