edu.luc.cs.trull
Class If
java.lang.Object
edu.luc.cs.trull.EmptyComponent
edu.luc.cs.trull.TerminatingComponent
edu.luc.cs.trull.AbstractComponent
edu.luc.cs.trull.AbstractCombinator
edu.luc.cs.trull.Switch
edu.luc.cs.trull.If
- All Implemented Interfaces:
- Combinator, Component, PropertyChangeSource, Startable, Suspendable, Terminating, java.beans.PropertyChangeListener, java.util.EventListener
public class If
- extends Switch
A data-driven selection mechanism that evaluates its predicate and
immediately chooses and starts the corresponding branch.
The resulting component
terminates when the chosen branch terminates.
| Methods inherited from class edu.luc.cs.trull.Switch |
disconnectComponent, getChildTerminationListener, getCurrentComponent, getValuator, propertyChange, removeComponent, resume, setValuator, start, stop, suspend, switchToComponent |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
predicate
private EventPredicate predicate
- The predicate used by this combinator.
If
public If()
- Constructs an empty If component. Specific properties can be changed later.
If
public If(EventPredicate predicate,
Component yes)
- Constructs an If component with only a yes branch.
- Parameters:
predicate - the event predicate used in choosing a branch.yes - the branch chosen when the predicate evalutes to true.
If
public If(EventPredicate predicate,
Component yes,
Component no)
- Constructs an If component.
- Parameters:
predicate - the event predicate used in choosing a branch.yes - the branch chosen when the predicate evalutes to true.no - the branch chosen when the predicate evalutes to false.
getPredicate
public EventPredicate getPredicate()
- Returns the event predicate used by this If component.
- Returns:
- the event predicate.
predicateToValuator
protected static EventValuator predicateToValuator(EventPredicate predicate)
- Converts an event predicate to an event valuator.
This method is used since the If combinator is implemented as a Switch.
- Parameters:
predicate - the event predicate.
- Returns:
- the corresponding event valuator.
setPredicate
public void setPredicate(EventPredicate predicate)
- Sets the event predicate used by this If component.
- Parameters:
predicate - the event predicate.
http://www.cs.luc.edu/trull/