java.lang.Object
com.pauware.pauware_engine.Core.AbstractGuard
- Direct Known Subclasses:
Guard
public abstract class AbstractGuard
extends java.lang.Object
This abstract class represents the general notion of Guard in UML.
Instances of this class are executed at event processing time (notation is:
event[guard]/action(s)). It is instantiated within the
AbstractStateMachine.fires(String,AbstractState,AbstractState,Object,String,Object[],Object,String,Object[],byte)
method. Instances of this class are executed by means of the
execute()
method during
a run-to-completion cycle
(AbstractStateMachine.run_to_completion(String,boolean)
method).
Compatibility: Java 9.
- Since:
- 1.0
-
Field Summary
Fields Modifier and Type Field Description protected AbstractAction
_action
The action to be evaluated.protected boolean
_value
The result of the guard's evaluation. -
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractGuard(java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args)
This constructor is called by theAbstractStateMachine.fires(String,AbstractState,AbstractState,Object,String,Object[],Object,String,Object[],byte)
method. -
Method Summary
Modifier and Type Method Description protected abstract AbstractAction
action(java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args)
Implementation of this method occurs inGuard
.boolean
equals(java.lang.Object guard)
This method is used when a guard object is put in a map data structure as a key.protected boolean
execute()
Implementation of this method depends upon the chosen platform, i.e., adaptation for platforms different from Java 9 have to provide specific code.int
hashCode()
This method is used when a guard object is put in a map data structure as a key.java.lang.String
to_UML()
This method returns the guard in the form of a UML-compliant string.protected java.lang.String
verbose()
This method returns the detailed result of the guard's execution.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
_action
The action to be evaluated. This field isnull
when no action is associated with a guard. In such a case, the_value
field is computed at the beginning of a run-to-completion cycle and frozen during this cycle. -
_value
protected boolean _valueThe result of the guard's evaluation. Caution: guards raising exceptions or errors during their evaluation are set tofalse
.
-
-
Constructor Details
-
AbstractGuard
protected AbstractGuard(java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args)This constructor is called by theAbstractStateMachine.fires(String,AbstractState,AbstractState,Object,String,Object[],Object,String,Object[],byte)
method.- Parameters:
guard_object
- The object in charge of evaluating the guard; Most of the time, this object is the software component that runs the state machine.guard_action
- The action to be executed; The execution amounts to evaluating the guard.guard_args
- The action's arguments.
-
-
Method Details
-
action
protected abstract AbstractAction action(java.lang.Object guard_object, java.lang.String guard_action, java.lang.Object[] guard_args)Implementation of this method occurs inGuard
.- Parameters:
guard_object
-guard_action
-guard_args
-- Returns:
- See Also:
Action
-
equals
public boolean equals(java.lang.Object guard)This method is used when a guard object is put in a map data structure as a key.- Overrides:
equals
in classjava.lang.Object
- Parameters:
guard
-
-
hashCode
public int hashCode()This method is used when a guard object is put in a map data structure as a key.- Overrides:
hashCode
in classjava.lang.Object
-
execute
Implementation of this method depends upon the chosen platform, i.e., adaptation for platforms different from Java 9 have to provide specific code.- Returns:
- success, failure or
false
when executed guard does not return a Boolean value. - Throws:
State_exception
- An encapsulation of any Java problem resulting from evaluating the guard.
-
verbose
protected java.lang.String verbose()This method returns the detailed result of the guard's execution. It calls theAbstractAction.verbose()
method if an action is associated with the guard. Otherwise, it returns eitherfalse
ortrue
.- Returns:
- The detailed result of the guard's execution as a string.
-
to_UML
public java.lang.String to_UML()This method returns the guard in the form of a UML-compliant string.- Returns:
- The guard as UML-readable string.
-