Record Class EntryState
java.lang.Object
java.lang.Record
ai.badmonkey.agentspaces.space.crdt.EntryState
- Record Components:
record- the immutable entry record as written (its lease field is superseded bylease)adds- observed add dotsremoves- observed remove dotslease- the current lease, LWW by HLCcompleted- monotone completion flag
public record EntryState(EntryRecord record, Set<Dot> adds, Set<Dot> removes, LwwRegister<LeaseInfo> lease, boolean completed)
extends Record
The replicated state of one entry (spec ยง7.3): observed-remove add/remove dot
sets, a last-writer-wins lease register, and a monotone completed flag. The
completed flag is what makes double
complete impossible to merge back
in: once any replica records completion, every merge preserves it.
Immutable; every operation returns a new state, and merge(EntryState) is
commutative, associative, and idempotent by construction.
-
Constructor Summary
ConstructorsConstructorDescriptionEntryState(EntryRecord record, Set<Dot> adds, Set<Dot> removes, LwwRegister<LeaseInfo> lease, boolean completed) Creates an instance of aEntryStaterecord class. -
Method Summary
Modifier and TypeMethodDescriptionstatic EntryStateadded(EntryRecord record, Dot addDot, LwwRegister<LeaseInfo> stamp) Creates the state for a freshly written entry.adds()Returns the value of theaddsrecord component.booleanReturns the value of thecompletedrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.lease()Returns the value of theleaserecord component.merge(EntryState other) Merges two replicas' states for the same entry.booleanpresent()Returns whether the entry is present: some add dot is unremoved and it is not completed.record()Returns the value of therecordrecord component.removes()Returns the value of theremovesrecord component.final StringtoString()Returns a string representation of this record class.Returns a state marked completed.withLease(LwwRegister<LeaseInfo> leaseWrite) Returns a state with a lease write merged in (LWW by HLC).Returns a state with all currently observed add dots removed (withdrawal).
-
Constructor Details
-
EntryState
public EntryState(EntryRecord record, Set<Dot> adds, Set<Dot> removes, LwwRegister<LeaseInfo> lease, boolean completed) Creates an instance of aEntryStaterecord class.
-
-
Method Details
-
added
Creates the state for a freshly written entry.- Parameters:
record- the written recordaddDot- the writing replica's dotstamp- the write's lease register- Returns:
- the new state
-
present
public boolean present()Returns whether the entry is present: some add dot is unremoved and it is not completed. -
withObservedRemoved
Returns a state with all currently observed add dots removed (withdrawal). -
withCompleted
Returns a state marked completed. Monotone: no operation clears it. -
withLease
Returns a state with a lease write merged in (LWW by HLC).- Parameters:
leaseWrite- the lease write- Returns:
- the updated state
-
merge
Merges two replicas' states for the same entry.- Parameters:
other- the other replica's state- Returns:
- the merged state
-
toString
-
hashCode
-
equals
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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
record
-
adds
-
removes
-
lease
-
completed
-