Class ImmutableModelRoot<T>

Type Parameters:
T - model value type
All Implemented Interfaces:
Entity<T>, ModelRoot<T>, PersistedRoot<T>

public class ImmutableModelRoot<T> extends ImmutableRoot<T> implements ModelRoot<T>
Immutable entity wrapper for one independently stored model revision.

Model sequence numbers are local to the model stream. ModelRoot.stateIndex() is the namespace-wide state boundary at which this revision became current; it is deliberately distinct from the global event-log index exposed through Entity.lastEventIndex().

  • Method Details

    • initial

      public static <T> ImmutableModelRoot<T> initial(Object id, Class<T> type, String idProperty, T value, EntityHelper entityHelper, Serializer serializer)
      Creates a new uncommitted model root with the current timestamp.
    • initial

      public static <T> ImmutableModelRoot<T> initial(Object id, Class<T> type, String idProperty, T value)
      Creates a lightweight new or staged model root without runtime collaborators.
    • staged

      public static <T> ImmutableModelRoot<T> staged(Object id, Class<T> type, String idProperty, T value, long sequenceNumber)
      Creates a lightweight staged model root with its known sequence number.
    • revision

      public static <T> ImmutableModelRoot<T> revision(Object id, Class<T> type, String idProperty, T value, EntityHelper entityHelper, Serializer serializer, String lastEventId, Long lastEventIndex, Instant timestamp, long sequenceNumber, long stateIndex, Entity<T> previous)
      Creates a model root from one authoritative stored revision.
    • withEventIndex

      public Entity<T> withEventIndex(Long index, String messageId)
      Description copied from interface: Entity
      Updates the event index and message ID of the entity and returns the updated version of the entity.
      Specified by:
      withEventIndex in interface Entity<T>
      Specified by:
      withEventIndex in interface PersistedRoot<T>
      Parameters:
      index - the event index to set for the root entity
      messageId - the message ID associated with the event
      Returns:
      the updated entity corresponding to the current entity's ID and type, or null if no such entity can be found
    • withSequenceNumber

      public Entity<T> withSequenceNumber(long sequenceNumber)
      Description copied from interface: Entity
      Returns an updated entity based on this with the specified sequence number.
      Specified by:
      withSequenceNumber in interface Entity<T>
      Specified by:
      withSequenceNumber in interface PersistedRoot<T>
      Parameters:
      sequenceNumber - the sequence number to assign to the entity
      Returns:
      the updated entity with the specified sequence number, or null if the entity could not be found in the entity hierarchy
    • withPrevious

      public ImmutableModelRoot<T> withPrevious(Entity<T> previous)
      Returns this revision with the supplied in-memory predecessor.
      Specified by:
      withPrevious in class ImmutableRoot<T>