Package repast.simphony.engine.watcher
Class Notifier2
java.lang.Object
repast.simphony.engine.watcher.Notifier2
Notifies watchers that their watchee state has changed. This includes evaluating
any queries etc. and scheduling the actual method call on the watcher. A Notifier
has a one to one relationship with a @Watch annotation. All instances of the class
containing that annotation are managed by a single notifier.
- Author:
- Nick Collier
-
Constructor Summary
ConstructorDescriptionNotifier2
(NotifierID id, WatchParameters params, ISchedule schedule) Creates a Notifier from the specified parameters and schedule. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addWatcher
(Object watcher) Adds a watcher to be notified by this Notifier.int
Gets the number watchers managed by this Notifier.void
removeWatcher
(Object watcher) Removes the specified watcher from this notifier.void
Called when the watchee state (i.e.watchers
(boolean shuffle) Gets an iterable over all the watchers managed by this Notifier.
-
Constructor Details
-
Notifier2
Creates a Notifier from the specified parameters and schedule.- Parameters:
id
- a notifierID the ids this Notifier2params
- the parameters used in the notificationschedule
- the schedule on which any method calls with be scheduled
-
-
Method Details
-
watchers
Gets an iterable over all the watchers managed by this Notifier.- Parameters:
shuffle
- whether or not the iterable should be over shuffled list of the watchers.- Returns:
- an iterable over all the watchers managed by this Notifier.
-
getWatcherCount
public int getWatcherCount()Gets the number watchers managed by this Notifier.- Returns:
- the number watchers managed by this Notifier.
-
addWatcher
Adds a watcher to be notified by this Notifier. It is the responsibility of the caller to insure that the watch parameters of the added watcher are the same as those associated with this Notifier.- Parameters:
watcher
- the watcher to add
-
triggered
Called when the watchee state (i.e. a field set) has changed and the watchers need to be notified.- Parameters:
watchee
- the watcheevalue
- the new value of the field
-
removeWatcher
Removes the specified watcher from this notifier. The specified watcher will no longer have the relevant method called when the watchee changes.- Parameters:
watcher
- the watcher to remove
-