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.
    Author:
    Nick Collier
    • Constructor Detail

      • Notifier2

        public Notifier2​(NotifierID id,
                         WatchParameters params,
                         ISchedule schedule)
        Creates a Notifier from the specified parameters and schedule.
        Parameters:
        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.
        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

        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.
        Parameters:
        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.
        Parameters:
        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.
        Parameters:
        watcher - the watcher to remove