org.schmant.run
Class CompoundTaskDependency

java.lang.Object
  extended by java.util.Observable
      extended by org.schmant.run.CompoundTaskDependency
All Implemented Interfaces:
Observer, TaskDependency

public class CompoundTaskDependency
extends Observable
implements TaskDependency, Observer

This object is used to bundle several TaskDependency objects into one.

Since:
0.5
Author:
Karl Gustafsson

Constructor Summary
CompoundTaskDependency()
           
 
Method Summary
 CompoundTaskDependency add(TaskDependency td)
          Add one task dependency.
 CompoundTaskDependency addAll(Collection<? extends TaskDependency> c)
          Add several task dependencies.
 CompoundTaskDependency addAll(TaskDependency... tdArr)
          Add several task dependencies.
 Observable getDependencyObservable()
          Observable that will fire with the dependency as argument when all dependencies are satisfied.
 Lock getSatisfiedStateLock()
          Get the Lock that protects the dependency's satisfied property.
 boolean isSatisfied()
          Is this dependency satisfied?
 String toString()
           
 void update(Observable obs, Object o)
           
 
Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompoundTaskDependency

public CompoundTaskDependency()
Method Detail

add

public CompoundTaskDependency add(TaskDependency td)
Add one task dependency.

Parameters:
td - The task dependency. This may not be null.
Returns:
this

addAll

public CompoundTaskDependency addAll(TaskDependency... tdArr)
Add several task dependencies.

Parameters:
tdArr - The task dependencies to add. null elements are automatically discarded
Returns:
this
Since:
1.0

addAll

public CompoundTaskDependency addAll(Collection<? extends TaskDependency> c)
Add several task dependencies.

Parameters:
c - The task dependencies to add. null elements are automatically discarded.
Returns:
this

getDependencyObservable

public Observable getDependencyObservable()
Description copied from interface: TaskDependency
Observable that will fire with the dependency as argument when all dependencies are satisfied.

Implementation note: The thread firing an event must own the satisfied state lock on the task dependency object.

Specified by:
getDependencyObservable in interface TaskDependency
Returns:
An Observable to observe.

isSatisfied

public boolean isSatisfied()
Description copied from interface: TaskDependency
Is this dependency satisfied?

Implementation note: This method should be protected by the same lock that can be retrieved by calling TaskDependency.getSatisfiedStateLock().

Specified by:
isSatisfied in interface TaskDependency
Returns:
true if the dependency is satisfied.

getSatisfiedStateLock

public Lock getSatisfiedStateLock()
Description copied from interface: TaskDependency
Get the Lock that protects the dependency's satisfied property. This lock must be locked before the dependency's satisfied state can be update.

An external class can lock this to ensure that the satisfied state is not updated while it holds the lock.

Specified by:
getSatisfiedStateLock in interface TaskDependency
Returns:
The lock used to protect the satisfied state.
See Also:
TaskDependency.isSatisfied()

update

public void update(Observable obs,
                   Object o)
Specified by:
update in interface Observer

toString

public String toString()
Overrides:
toString in class Object