Class ObserverDescriptor<E extends Event<?>,O extends Observer<E>,EM extends EventMatcher<E>>

java.lang.Object
org.refcodes.observer.ObserverDescriptor<E,O,EM>
Type Parameters:
E - the element type
O - the generic type
EM - the generic type
All Implemented Interfaces:
Observer<E>

public class ObserverDescriptor<E extends Event<?>,O extends Observer<E>,EM extends EventMatcher<E>> extends Object implements Observer<E>
This ObserverDescriptor describes the Observer, i.e. in some cases an Observer requires an EventMatcher which determines which ActionEvent instances to pass to the Observer. The ObserverDescriptor is itself an Observer calling the EventMatcher to determine whether to delegate the ActionEvent to contained Observer or not.
  • Constructor Details

    • ObserverDescriptor

      public ObserverDescriptor(O aEventListener, EM aEventMatcher)
      Constructs the event listener descriptor with the given event listener and the given event matcher.
      Parameters:
      aEventListener - The listener to be stored in the event listener descriptor.
      aEventMatcher - The matcher to be stored in the event listener descriptor.
  • Method Details

    • onEvent

      public void onEvent(E aEvent)
      The listener implementing this interface is notified of an event via this method. The publisher pushes the event to the subscriber.
      Specified by:
      onEvent in interface Observer<E extends Event<?>>
      Parameters:
      aEvent - aEvent The event to be pushed from the publisher to the subscriber.
    • getObserver

      public O getObserver()
      Returns the Observer associated with the given EventMatcher.
      Returns:
      The Observer as it is being managed by the ObserverDescriptor.
    • getEventMatcher

      public EM getEventMatcher()
      Returns the EventMatcher associated with the given Observer.
      Returns:
      The EventMatcher as it is being managed by the ObserverDescriptor.