Package org.jmanikin.message
Interface LocalMessage<I extends Id<O>,O,E>
- Type Parameters:
I- the Id TypeO- the Object TypeE- the Effect Type
- All Superinterfaces:
Environment<I,O,E>,Message<I,O,E>,PreCondition<I,O,E>
- All Known Subinterfaces:
AccountModule.AccountMsg,TestModule.LMsg<E>,TransferModule.TransferMsg
- All Known Implementing Classes:
AccountModule.Deposit,AccountModule.Open,AccountModule.Withdraw,TestModule.LocalCopyId,TestModule.LocalSendSetMember,TestModule.LocalSetMember,TestModule.ThrowPstException,TransferModule.Book
public interface LocalMessage<I extends Id<O>,O,E> extends Message<I,O,E>, Environment<I,O,E>
A LocalMessage wraps the Environment in a LocalEnv, and temporarily stores the LocalEnv in a ThreadLocal variable.
In turn, the LocalEnv can be referenced in the scope of a LocalMessage: a LocalMessage IS A Environment!
Example implementation usage:
public Msg<I, O, E> local() { return
pre(() -> ...).
app(() -> ...).
eff(() -> ...).
pst(() -> ...);
}
See also example AccountModule for an example.
-
Nested Class Summary
-
Field Summary
Fields Modifier and Type Field Description static java.lang.ThreadLocal<java.lang.Object>localEnv -
Method Summary
Modifier and Type Method Description default LocalMessage.LocalEnvironment<I,O,E>env()Msg<I,O,E>local()Returns the Msg that has been build.default Msg<I,O,E>msg(Environment<I,O,E> e)Builds a Msg, given an Environmentdefault Oobj()Returns the current Object Odefault <O2> O2obj(Id<? extends O2> id)Returns the current Object O2, given its iddefault Oold()Returns the old Object Odefault <O2> O2old(Id<? extends O2> id)Returns the old Object O2, given its iddefault Apply<I,O,E>pre(java.util.function.Supplier<java.lang.Boolean> pre)Build the next Apply stage, given a lazy pre-condition supplier.default Iself()Returns the Object identifier that's in scopedefault <I2 extends Id<O2>, O2, R2>
R2send(I2 id, Message<I2,O2,R2> msg)Sends a Message to Object O, given an Object identifier
-
Field Details
-
localEnv
static final java.lang.ThreadLocal<java.lang.Object> localEnv
-
-
Method Details
-
env
-
local
Returns the Msg that has been build.- Returns:
- the Msg that has been build
-
msg
Description copied from interface:MessageBuilds a Msg, given an Environment -
self
Description copied from interface:EnvironmentReturns the Object identifier that's in scope -
obj
Description copied from interface:EnvironmentReturns the current Object O -
old
Description copied from interface:EnvironmentReturns the old Object O -
obj
Description copied from interface:EnvironmentReturns the current Object O2, given its id -
old
Description copied from interface:EnvironmentReturns the old Object O2, given its id -
pre
Description copied from interface:PreConditionBuild the next Apply stage, given a lazy pre-condition supplier. -
send
Description copied from interface:EnvironmentSends a Message to Object O, given an Object identifier
-