Interface UpdateState
- All Known Subinterfaces:
CommitterState<REF_OBJ,RESULT>
public interface UpdateState
-
Method Summary
Modifier and TypeMethodDescription<C extends Obj>
CgetWrittenById(ObjRef id, Class<C> clazz) Get an already present object by itsObjRef.getWrittenByKey(Object key) Get an already present object by a use-case defined key.Use this instance ofPersistenceinstead for operations related to this state, especially fromCommitRetryable.attempt(CommitterState, Supplier).default ObjwriteIfNew(Object key, Obj obj) <O extends Obj>
OwriteIfNew(Object key, O obj, Class<O> type) Addobjto the list of objects to be persisted, usingkeyto identify/reuse an already persisted object in a retried attempt.voidwriteIntent(Object key, Obj obj) Addobjto the list of objects to be persisted, usingkeyto identify/reuse an already persisted object in a retried attempt.default ObjwriteOrReplace(Object key, Obj obj) <O extends Obj>
OwriteOrReplace(Object key, O obj, Class<O> type) Addobjto the list of objects to be persisted, usingkeyto identify/reuse an already persisted object in a retried attempt.
-
Method Details
-
persistence
Persistence persistence()Use this instance ofPersistenceinstead for operations related to this state, especially fromCommitRetryable.attempt(CommitterState, Supplier). -
writeIfNew
Addobjto the list of objects to be persisted, usingkeyto identify/reuse an already persisted object in a retried attempt.Prefer this function over
writeIntent(Object, Obj)andgetWrittenByKey(Object).Note that objects will not be immediately persisted, but after the attempt returns, but before the commit returns.
A failed commit will delete objects passed to this function.
- Parameters:
key- key identifyingobjobj- object to persist- Returns:
- returns the given
obj, ifkeyis new, or the previous Obj, ifkeywas already used in a call to this function orwriteIntent(Object, Obj).
-
writeIfNew
-
writeOrReplace
Addobjto the list of objects to be persisted, usingkeyto identify/reuse an already persisted object in a retried attempt.If an object was already associated with the same
key, the previous object will be eventually deleted.- Parameters:
key- key identifyingobjobj- object to persist- Returns:
- returns
obj
-
writeOrReplace
-
getWrittenByKey
Get an already present object by a use-case defined key.- Returns:
- the already present object or
null, if no object is associated with thekey
-
getWrittenById
Get an already present object by itsObjRef.- Returns:
- the already present object or
null, if no object is associated with theid
-
writeIntent
Addobjto the list of objects to be persisted, usingkeyto identify/reuse an already persisted object in a retried attempt.Note that objects will not be immediately persisted, but after the attempt returns, but before the commit returns.
A failed commit will delete objects passed to this function.
Prefer
writeIfNew(Object, Obj), if possible.- Parameters:
key- key identifyingobj, must be unique across all objects. Throws anIllegalStateException, if thekeyhas already been used.obj- object to persist
-