Package eu.bandm.tools.message
Class MessageDemux<E extends Enum<E>,M extends Message>
java.lang.Object
eu.bandm.tools.message.PrimitiveMessageDemux<E,M>
eu.bandm.tools.message.MessageDemux<E,M>
- All Implemented Interfaces:
MessageReceiver<M>
- Direct Known Subclasses:
MessageDemux.All
,MessageDemux.ByKind
public abstract class MessageDemux<E extends Enum<E>,M extends Message>
extends PrimitiveMessageDemux<E,M>
Auxiliary class which concretizes
PrimitiveMessageDemux
in so far
it calculates a set of enum values for every message it receives, and then
calls the PrimitiveMessageDemux.receive(Enum,Message)
method for all these.-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Trivial instantiation ofMessageDemux
which propagates each message to all receivers in the map, as it has been constructed byPrimitiveMessageDemux.setReceiver(Enum,MessageReceiver)
static class
MessageDemux.ByKind<M extends Message>
AMessageDemux
which sorts messages by their kind. -
Field Summary
Fields inherited from class eu.bandm.tools.message.PrimitiveMessageDemux
outlets, tagclass
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends Enum<E>,
M extends Message>
MessageDemux<E, M> Delivers a trivial instantiation ofMessageDemux
, seeMessageDemux.All
.static <M extends Message>
MessageDemux<Message.Kind, M> byKind()
Factory method for the constructorMessageDemux.ByKind
getOutputTags
(M m) Has to be re-defined by derived classes to calculate the set of enum items which indicate the receivers the message shall be propagated to.void
Propagates the received message to all receivers indicated by the calculated enum item set.Methods inherited from class eu.bandm.tools.message.PrimitiveMessageDemux
getReceiver, receive, setReceiver
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
-
Constructor Details
-
MessageDemux
Only constructor.- Parameters:
tagclass
- the class of the controlling tags.
-
-
Method Details
-
getOutputTags
Has to be re-defined by derived classes to calculate the set of enum items which indicate the receivers the message shall be propagated to.This is the only method which needs to be overrideden by a subclass to be operative.
- Parameters:
m
- the message to be sent.- Returns:
- all tags to which this message shall be sent.
-
receive
Propagates the received message to all receivers indicated by the calculated enum item set. CallsgetOutputTags(Message)
to calculate this set.- Parameters:
message
- the message to be sent.
-
all
Delivers a trivial instantiation ofMessageDemux
, seeMessageDemux.All
.- Type Parameters:
E
- the type of the controlling tags.M
- the type of the messages.- Parameters:
tags
- the class of the enum type which shall control the message delivery.- Returns:
- a new instance of MessageDemux which sends to all registered receivers.
-
byKind
Factory method for the constructorMessageDemux.ByKind
- Type Parameters:
M
- the class of the messages.- Returns:
- a demultiplexer which is controlled by the kinds of the messages.
-