Package eu.bandm.tools.message
Class PrimitiveMessageDemux<E extends Enum<E>,M extends Message>
java.lang.Object
eu.bandm.tools.message.PrimitiveMessageDemux<E,M>
- Type Parameters:
E
- the enumeration type controlling the routingM
- the type of the messages
- All Implemented Interfaces:
MessageReceiver<M>
- Direct Known Subclasses:
MessageDemux
public abstract class PrimitiveMessageDemux<E extends Enum<E>,M extends Message>
extends Object
implements MessageReceiver<M>
Auxiliary class which maps from an enumeration type
to optional
MessageReceiver
s.
This class is intended as base class for classes which de-multiplex
a message stream to these receivers.-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
PrimitiveMessageDemux
(Class<E> tagclass) Only constructor. -
Method Summary
Modifier and TypeMethodDescription@Opt MessageReceiver
<? super M> getReceiver
(E tag) Get the receiver for one particular tag.protected void
Auxiliary internal method for performing the sending to a certainMessageReceiver
, as indicated by an enum value.void
setReceiver
(E tag, @Opt MessageReceiver<? super M> rec) Set the receiver for one particular tag.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface eu.bandm.tools.message.MessageReceiver
ifSubcriticalThen, ifSubcriticalThen, ifSubcriticalThenElse, receive
-
Field Details
-
outlets
Internal directory of the different drains per tag. -
tagclass
Configuration value holding the class used for tagging.
-
-
Constructor Details
-
PrimitiveMessageDemux
Only constructor.- Parameters:
tagclass
- the class used as index to theMessageReceiver
s.
-
-
Method Details
-
setReceiver
Set the receiver for one particular tag. Setting to null is allowed and make it act like aMessageDisposer
, i.e. discard the message.- Parameters:
tag
- the key under which the receiver can be activatedrec
- the message receiver activated by the tag
-
getReceiver
Get the receiver for one particular tag.- Parameters:
tag
- under which the reciever has been stored.- Returns:
- the receiver stored with the given tag, or
null
iff no such exists.
-
receive
Auxiliary internal method for performing the sending to a certainMessageReceiver
, as indicated by an enum value. If no receiver has been registered with that tag, no operation is performed.This method is called by some subclass, after it has determined the applicable enum value or value set.
- Parameters:
tag
- the tag identifying the intended receiver.msg
- the message to send
-