Package org.refcodes.observer
Class ObserverDescriptorImpl<E extends GenericEvent<?>,O extends Observer<E>,EM extends EventMatcher<E>>
- java.lang.Object
-
- org.refcodes.observer.ObserverDescriptorImpl<E,O,EM>
-
- Type Parameters:
E- The event type.O- the generic typeEM- the generic type
- All Implemented Interfaces:
Observer<E>,ObserverDescriptor<E,O,EM>
public class ObserverDescriptorImpl<E extends GenericEvent<?>,O extends Observer<E>,EM extends EventMatcher<E>> extends java.lang.Object implements ObserverDescriptor<E,O,EM>
As a descriptor describes something fixed, this class is immutable in the sense that there are no setters for the attributes. The attributes must be provided via the constructor.
-
-
Constructor Summary
Constructors Constructor Description ObserverDescriptorImpl(O aEventListener, EM aEventMatcher)Constructs the event listener descriptor with the given event listener and the given event matcher.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EMgetEventMatcher()Returns theEventMatcherassociated with the givenObserver.OgetObserver()Returns theObserverassociated with the givenEventMatcher.voidonEvent(E aEvent)The listener implementing this interface is notified of an event via this method.
-
-
-
Constructor Detail
-
ObserverDescriptorImpl
public ObserverDescriptorImpl(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 Detail
-
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:
onEventin interfaceObserver<E extends GenericEvent<?>>- Parameters:
aEvent- aEvent The event to be pushed from the publisher to the subscriber.
-
getObserver
public O getObserver()
Returns theObserverassociated with the givenEventMatcher.- Specified by:
getObserverin interfaceObserverDescriptor<E extends GenericEvent<?>,O extends Observer<E>,EM extends EventMatcher<E>>- Returns:
- The
Observeras it is being managed by theObserverDescriptor.
-
getEventMatcher
public EM getEventMatcher()
Returns theEventMatcherassociated with the givenObserver.- Specified by:
getEventMatcherin interfaceObserverDescriptor<E extends GenericEvent<?>,O extends Observer<E>,EM extends EventMatcher<E>>- Returns:
- The
EventMatcheras it is being managed by theObserverDescriptor.
-
-