public abstract class AbstractAction extends Object implements Action
Modifier and Type | Field and Description |
---|---|
private String |
name
The name of the action
|
private Collection<PostCondition> |
post
The set of postconditions for this Action
|
private Collection<PreCondition> |
pre
The set of preconditions for this Action
|
Constructor and Description |
---|
AbstractAction()
Defers to
AbstractAction(String) where the parameter is "Action". |
AbstractAction(String theName)
Initializes the internal data structures.
|
Modifier and Type | Method and Description |
---|---|
void |
addPostCondition(PostCondition theCondition)
Adds the Condition to this Acitons's set of postconditions.
|
void |
addPostConditions(Collection<PostCondition> theConditions)
Adds Conditions to this Action's set of postconditions.
|
void |
addPreCondition(PreCondition theCondition)
Adds the Condition to this Acitons's set of preconditions.
|
void |
addPreConditions(Collection<PreCondition> theConditions)
Adds Conditions to this Action's set of preconditions.
|
void |
clearPostConditions()
Removes all postconditions from this action.
|
void |
clearPreConditions()
Removes all preconditions from this action.
|
int |
compareTo(Action theAction)
Compares based on:
the
String.compareTo(String) of getName()
the compareTo() of the sorted members of the preconditions
the compareTo() of the sorted members of the postconditions
|
boolean |
equals(Object theAction) |
Status |
execute(Object... theParameters)
If
isEnabled() returns true, then calls run(Object...) with the parameters of this method. |
String |
getName()
Used in
#compareTo(Action) and #equals(Object) . |
Collection<PostCondition> |
getPostConditions() |
Collection<PreCondition> |
getPreConditions() |
boolean |
isEnabled() |
void |
removePostCondition(PostCondition theCondition)
Removes the Condition from this action, if it in the set of preconditions.
|
void |
removePreCondition(PreCondition theCondition)
Removes the Condition from this action, if it in the set of preconditions.
|
protected abstract Status |
run(Object... theParameters)
This is the actual action of the action.
|
private Collection<PreCondition> pre
private Collection<PostCondition> post
private String name
public AbstractAction()
AbstractAction(String)
where the parameter is "Action".public AbstractAction(String theName)
theName
- The name of this Action.public final void addPreCondition(PreCondition theCondition)
Action
addPreCondition
in interface Action
public final void addPreConditions(Collection<PreCondition> theConditions)
Action
addPreConditions
in interface Action
public final void removePreCondition(PreCondition theCondition)
Action
removePreCondition
in interface Action
public final Collection<PreCondition> getPreConditions()
getPreConditions
in interface Action
public final void clearPreConditions()
Action
clearPreConditions
in interface Action
public final void addPostCondition(PostCondition theCondition)
Action
addPostCondition
in interface Action
public final void addPostConditions(Collection<PostCondition> theConditions)
Action
addPostConditions
in interface Action
public final void removePostCondition(PostCondition theCondition)
Action
removePostCondition
in interface Action
public final Collection<PostCondition> getPostConditions()
getPostConditions
in interface Action
public final void clearPostConditions()
Action
clearPostConditions
in interface Action
public int compareTo(Action theAction)
String.compareTo(String)
of getName()
compareTo
in interface Comparable<Action>
Action
- the other actionpublic final boolean equals(Object theAction)
equals
in class Object
compareTo(Action)
returns 0.public final String getName()
Action
#compareTo(Action)
and #equals(Object)
.getName
in interface Action
AbstractAction()
and AbstractAction(String)
.public boolean isEnabled()
public final Status execute(Object... theParameters) throws IllegalOperationException
isEnabled()
returns true, then calls run(Object...)
with the parameters of this method.
Otherwise throws an exception.execute
in interface Action
theParameters
- The parameters to pass to run(Object...)
.Status
returned by the call to run(Object...)
.IllegalOperationException
- if isEnabled()
returns false.Status
protected abstract Status run(Object... theParameters) throws IllegalOperationException
execute(Object...)
.theParameters
- Any parameters required by the specific override of this method.Status
object, according the the specific override of this method.IllegalOperationException