Class AbstractReaction
-
- All Implemented Interfaces:
-
it.unibo.alchemist.model.Actionable
,it.unibo.alchemist.model.Reaction
,java.io.Serializable
,java.lang.Comparable
public abstract class AbstractReaction<T> implements Reaction<T>
The type which describes the concentration of a molecule. This class offers a partial implementation of Reaction. In particular, it allows to write new reaction specifying only which distribution time to adopt
-
-
Field Summary
Fields Modifier and Type Field Description public final TimeDistribution<T>
timeDistribution
public final Node<T>
node
-
Constructor Summary
Constructors Constructor Description AbstractReaction(Node<T> node, TimeDistribution<T> timeDistribution)
Builds a new reaction, starting at time t.
-
Method Summary
Modifier and Type Method Description final TimeDistribution<T>
getTimeDistribution()
final Node<T>
getNode()
boolean
canExecute()
The default implementation verifies if all the conditions are valid. final int
compareTo(Actionable<T> o)
final boolean
equals(Object o)
void
execute()
The default execution iterates all the actions in order and executes them. List<Action<T>>
getActions()
Override only if you need to implement extremely tricky behaviours. List<Condition<T>>
getConditions()
Override only if you need to implement extremely tricky behaviours. final ListSet<Dependency>
getOutboundDependencies()
final ListSet<Dependency>
getInboundDependencies()
final Context
getInputContext()
final Context
getOutputContext()
final Time
getTau()
final int
hashCode()
void
initializationComplete(@Nonnull() Time atTime, @Nonnull() Environment<T, out Object> environment)
String
toString()
final void
update(@Nonnull() Time currentTime, boolean hasBeenExecuted, @Nonnull() Environment<T, out Object> environment)
void
setActions(@Nonnull() List<out Action<T>> actions)
This should get overridden only if very tricky behaviours are implemented, such that the default Alchemist action addition model is no longer usable. void
setConditions(@Nonnull() List<out Condition<T>> conditions)
This should get overridden only if very tricky behaviours are implemented, such that the default Alchemist condition addition model is no longer usable. -
Methods inherited from class it.unibo.alchemist.model.Reaction
cloneOnNewNode, getNode
-
Methods inherited from class it.unibo.alchemist.model.Actionable
getRate, getTimeDistribution
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
AbstractReaction
AbstractReaction(Node<T> node, TimeDistribution<T> timeDistribution)
Builds a new reaction, starting at time t.- Parameters:
node
- the node this reaction belongs totimeDistribution
- the time distribution this reaction should follow
-
-
Method Detail
-
getTimeDistribution
@Nonnull() final TimeDistribution<T> getTimeDistribution()
-
canExecute
boolean canExecute()
The default implementation verifies if all the conditions are valid.
- Returns:
true if the reaction can execute right now.
-
compareTo
final int compareTo(Actionable<T> o)
-
execute
void execute()
The default execution iterates all the actions in order and executes them. Override to change the behaviour.
-
getActions
@Nonnull() List<Action<T>> getActions()
Override only if you need to implement extremely tricky behaviours. Must be overridden along with setActions.
- Returns:
the list of Actions.
-
getConditions
@Nonnull() List<Condition<T>> getConditions()
Override only if you need to implement extremely tricky behaviours. Must be overridden along with setConditions.
- Returns:
the list of Conditions.
-
getOutboundDependencies
@Nonnull() final ListSet<Dependency> getOutboundDependencies()
-
getInboundDependencies
@Nonnull() final ListSet<Dependency> getInboundDependencies()
-
getInputContext
@Nonnull() final Context getInputContext()
-
getOutputContext
@Nonnull() final Context getOutputContext()
-
hashCode
final int hashCode()
-
initializationComplete
void initializationComplete(@Nonnull() Time atTime, @Nonnull() Environment<T, out Object> environment)
-
toString
String toString()
- Returns:
the default implementation returns a String in the form className@timeScheduled[Conditions]-rate->[Actions]
-
update
final void update(@Nonnull() Time currentTime, boolean hasBeenExecuted, @Nonnull() Environment<T, out Object> environment)
-
setActions
void setActions(@Nonnull() List<out Action<T>> actions)
This should get overridden only if very tricky behaviours are implemented, such that the default Alchemist action addition model is no longer usable. Must be overridden along with getActions.
- Parameters:
actions
- the actions to set
-
setConditions
void setConditions(@Nonnull() List<out Condition<T>> conditions)
This should get overridden only if very tricky behaviours are implemented, such that the default Alchemist condition addition model is no longer usable. Must be overridden along with getConditions.
- Parameters:
conditions
- the actions to set
-
-
-
-