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 EM
getEventMatcher()
Returns theEventMatcher
associated with the givenObserver
.O
getObserver()
Returns theObserver
associated with the givenEventMatcher
.void
onEvent(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:
onEvent
in interfaceObserver<E extends GenericEvent<?>>
- Parameters:
aEvent
- aEvent The event to be pushed from the publisher to the subscriber.
-
getObserver
public O getObserver()
Returns theObserver
associated with the givenEventMatcher
.- Specified by:
getObserver
in interfaceObserverDescriptor<E extends GenericEvent<?>,O extends Observer<E>,EM extends EventMatcher<E>>
- Returns:
- The
Observer
as it is being managed by theObserverDescriptor
.
-
getEventMatcher
public EM getEventMatcher()
Returns theEventMatcher
associated with the givenObserver
.- Specified by:
getEventMatcher
in interfaceObserverDescriptor<E extends GenericEvent<?>,O extends Observer<E>,EM extends EventMatcher<E>>
- Returns:
- The
EventMatcher
as it is being managed by theObserverDescriptor
.
-
-