Package eu.bandm.tools.message
Class PrimitiveMessageDemux<E extends Enum<E>,M extends Message>
java.lang.Object
eu.bandm.tools.message.PrimitiveMessageDemux<E,M>
- 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 administrating an enumeration type and a map from
this type to optional
MessageReceiver
s.
Intended for de-multiplexing a message stream as calculated by
some derived class.-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
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 null is allowed and acts like aMessageDisposer
.- 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 wiht that tag, NOP is performed.This method is called by some derived class, after it has determined the applicable enum value or value set.
- Parameters:
tag
- the tag identifying the intended receiver.msg
- the message to send
-