Class Notifier2

  • public class Notifier2
    extends Object
    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.
    Nick Collier
    • Constructor Detail

      • Notifier2

        public Notifier2​(NotifierID id,
                         WatchParameters params,
                         ISchedule schedule)
        Creates a Notifier from the specified parameters and schedule.
        id - a notifierID the ids this Notifier2
        params - the parameters used in the notification
        schedule - the schedule on which any method calls with be scheduled
    • Method Detail

      • watchers

        public Iterable<Object> watchers​(boolean shuffle)
        Gets an iterable over all the watchers managed by this Notifier.
        shuffle - whether or not the iterable should be over shuffled list of the watchers.
        an iterable over all the watchers managed by this Notifier.
      • getWatcherCount

        public int getWatcherCount()
        Gets the number watchers managed by this Notifier.
        the number watchers managed by this Notifier.
      • addWatcher

        public void addWatcher​(Object watcher)
        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.
        watcher - the watcher to add
      • triggered

        public void triggered​(Object watchee,
                              Object value)
        Called when the watchee state (i.e. a field set) has changed and the watchers need to be notified.
        watchee - the watchee
        value - the new value of the field
      • removeWatcher

        public void removeWatcher​(Object watcher)
        Removes the specified watcher from this notifier. The specified watcher will no longer have the relevant method called when the watchee changes.
        watcher - the watcher to remove