Class Update<M>
- Type Parameters:
M- the type of diagnostic messages attached to stems
- All Implemented Interfaces:
Action.Continuation<State,,State, M, State> Function<State,Action<State, M, State>>
The implementations provided by this class are not only convenient building blocks, but also undergo extensive dynamic optimization via algebraic laws.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <M> Update<M> Returns an update that copies the value currently assigned to the given key to the accumulator.static <M> Update<M> Returns an update that adds the current accumulator value as an element to the sequence assigned to the given key.Returns an update that performs the effect of this and a given other update in sequence.static <M> Update<M> Returns an update that assigns the current accumulator value to the given key.static <M> Update<M> Returns an update that tries the given alternatives in order.static <M> Update<M> diagnose(M... messages) Returns an update that attaches the given messages.Returns the caller location for the construction context of this update.static <M> Update<M> identity()Returns an update that has no effect.Returns an update that behaves like this update, but does not change the accumulator value.static <M> Update<M> lift(Action.Continuation<? super State, State, M, State> cont) Returns an update that performs the given continuation.static <M> Update<M> Returns an update that performs the given continuation.static <M> Update<M> Returns an update that performs the given continuation.static <M> Update<M> map(UnaryOperator<Data> op) Returns an update that purely transforms the accumulator value with a given function.static <M> Update<M> Returns an update that performs a pair of updates, and combines their resulting accumulator values.static <M> Update<M> merge(BinaryOperator<Data> op, Update<M> first, Update<M> second) Returns an update that performs a pair of updates, and combines their resulting accumulator values.static <M> Update<M> pop()Returns an update that leaves and discards the most recent scope.static <M> Update<M> push()Returns an update that enters a new scope.static <M> Update<M> pushEntries(Map<?, ? extends Data> entries) Returns an update that enters a new scope and maps the given keys to the given values simultaneously.static <M> Update<M> Returns an update that enters a new scope and maps the given key to the given value.static <M> Update<M> reject()Returns an update that fails and refers to the current state as obstruction.static <M> Update<M> Returns an update that removes the assignment to the given key.static <M> Update<M> Returns an update that removes the assignments to the given keys.static <M> Update<M> removeAll(Collection<?> keys) Returns an update that removes the assignments to the given keys.static <M> Update<M> setEntries(Map<Object, ? extends Data> entries) Returns an update that maps the given keys to the given values simultaneously.static <M> Update<M> Returns an update that maps the given key to the given value.static <M> Update<M> Returns an update that sets the accumulator to the given value.withCallerLocation(@Opt Location<String> callerLocation) Sets the caller location for the construction context of this update.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface eu.bandm.tools.ramus.ogma.Action.Continuation
apply, apply
-
Method Details
-
withCallerLocation
Sets the caller location for the construction context of this update.- Parameters:
callerLocation- the caller location for the construction context of this update, ornullif not available- Returns:
this
-
getCallerLocation
Returns the caller location for the construction context of this update.- Returns:
- the caller location for the construction context of this update, or
nullif not available - See Also:
-
identity
Returns an update that has no effect.- Type Parameters:
M- the type of diagnostic messages attached to stems- Returns:
- an update that has no effect
-
andThen
Returns an update that performs the effect of this and a given other update in sequence.- Parameters:
next- the update to perform after this update- Returns:
- an update that performs the effect of
thisfollowed by the effect ofnext - Throws:
NullPointerException- ifnextis null
-
setValue
Returns an update that sets the accumulator to the given value.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
value- the new accumulator value- Returns:
- an update that sets the accumulator to
value - Throws:
NullPointerException- ifvalueis null
-
setEntry
Returns an update that maps the given key to the given value.Any previous value associated with the given key is overwritten. Entries are scoped and can be undone with
pop().- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
key- the key to mapvalue- the new value- Returns:
- an update that maps
keytovalue - Throws:
NullPointerException- ifkeyorvalueis null
-
setEntries
Returns an update that maps the given keys to the given values simultaneously.Any previous value associated with a given key is overwritten. Entries are scoped and can be undone with
pop().- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
entries- the new key–value entries- Returns:
- an update that maps each key of
entriesto the corresponding value - Throws:
NullPointerException- ifentriesis or contains null
-
push
Returns an update that enters a new scope.- Type Parameters:
M- the type of diagnostic messages attached to stems- Returns:
- an update that enters a new scope
- See Also:
-
pushEntry
Returns an update that enters a new scope and maps the given key to the given value.Any previous value associated with the given key is overwritten. Entries can be undone with
pop().- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
key- the key to mapvalue- the new value- Returns:
- an update that enters a new scope and maps
keytovalue - Throws:
NullPointerException- ifkeyorvalueis null- See Also:
-
pushEntries
Returns an update that enters a new scope and maps the given keys to the given values simultaneously.Any previous value associated with a given key is overwritten. Entries can be undone with
pop().- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
entries- the new key–value entries- Returns:
- an update that enters a new scope and maps each key of
entriesto the corresponding value - Throws:
NullPointerException- ifentriesis or contains null- See Also:
-
pop
Returns an update that leaves and discards the most recent scope.All key–value mappings established since the creation of the scope are undone.
- Type Parameters:
M- the type of diagnostic messages attached to stems- Returns:
- an update that leaves and discards the most recent scope
- See Also:
-
assign
Returns an update that assigns the current accumulator value to the given key.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
key- the key- Returns:
- an update that assigns the current accumulator value to
key - Throws:
NullPointerException- ifkeyis null- See Also:
-
access
Returns an update that copies the value currently assigned to the given key to the accumulator.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
key- the key- Returns:
- an update that copies the value currently assigned to
keyto the accumulator - Throws:
NullPointerException- ifkeyis null- See Also:
-
addTo
Returns an update that adds the current accumulator value as an element to the sequence assigned to the given key.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
key- the key- Returns:
- an update that adds the current accumulator value as an element to
the sequence assigned to
key - Throws:
NullPointerException- ifkeyis nullUnsupportedOperationException- if the value assigned tokeyis not a sequence (FIXME: at next stage)IllegalArgumentException- if there is no value assigned tokey(FIXME: at next stage)
-
remove
Returns an update that removes the assignment to the given key.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
key- the key- Returns:
- an update that removes the assignment to
key - Throws:
NullPointerException- ifkeyis null- See Also:
-
removeAll
Returns an update that removes the assignments to the given keys.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
keys- the keys- Returns:
- an update that removes the assignments to all elements of
keys - Throws:
NullPointerException- ifkeysis null
-
removeAll
Returns an update that removes the assignments to the given keys.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
keys- the keys- Returns:
- an update that removes the assignments to all elements of
keys - Throws:
NullPointerException- ifkeysis null
-
choice
Returns an update that tries the given alternatives in order.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
alts- the alternatives- Returns:
- an update that tries the elements of
altsin order - Throws:
NullPointerException- ifaltsis or contains null
-
lift
Returns an update that performs the given continuation.The string description of the update is derived from the continuation.
- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
cont- the continuation to perform- Returns:
- an update that performs the given continuation
- Throws:
NullPointerException- ifcontis null
-
lift
public static <M> Update<M> lift(Action.Continuation<? super State, State, M, State> cont, @Opt String description) Returns an update that performs the given continuation.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
cont- the continuation to performdescription- a string description for the result- Returns:
- an update that performs the given continuation
- Throws:
NullPointerException- ifcontis null
-
lift
public static <M> Update<M> lift(Action.Continuation<? super State, State, M, State> cont, Supplier<@Opt String> description) Returns an update that performs the given continuation.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
cont- the continuation to performdescription- a supplier for a a string description for the result- Returns:
- an update that performs the given continuation
- Throws:
NullPointerException- ifcontordescriptionis null
-
map
Returns an update that purely transforms the accumulator value with a given function.The resulting update is deterministic and has no side-effects.
- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
op- the function to transform the accumulator value with- Returns:
- an update that purely transforms the accumulator value with
op - Throws:
NullPointerException- ifopis null
-
merge
Returns an update that performs a pair of updates, and combines their resulting accumulator values.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
op- the operator for combining the accumulator valuesfirst- the first updatesecond- the second update- Returns:
- an update that performs
firstfollowed bysecond, and combines their resulting values withop - Throws:
NullPointerException- ifop,firstorsecondis null
-
merge
public static <M> Update<M> merge(Action.BiContinuation<Data, Data, Data, M, State> op, Update<M> first, Update<M> second) Returns an update that performs a pair of updates, and combines their resulting accumulator values.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
op- the binary continuation for combining the accumulator valuesfirst- the first updatesecond- the second update- Returns:
- an update that performs
firstfollowed bysecond, and combines their resulting values withop - Throws:
NullPointerException- ifop,firstorsecondis null
-
ignoringResult
Returns an update that behaves like this update, but does not change the accumulator value.- Returns:
- an update that behaves like this update, but does not change the accumulator value
-
diagnose
Returns an update that attaches the given messages.- Type Parameters:
M- the type of diagnostic messages attached to stems- Parameters:
messages- the messages to attach- Returns:
- an update that attaches all elements of
messages - Throws:
NullPointerException- ifmessagesis null
-
reject
Returns an update that fails and refers to the current state as obstruction.- Type Parameters:
M- the type of diagnostic messages attached to stems- Returns:
- an update that fails and refers to the current state as obstruction
- See Also:
-