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.
  • Constructor Details

    • MessageDemux

      protected MessageDemux(Class<E> tagclass)
  • Method Details

    • getOutputTags

      protected abstract EnumSet<E> 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.

      Only method which needs to be re-defined by a subclass to be operative.
    • receive

      public void receive(M message)
      Propagates the received message to all receivers indicated by the calculated enum item set.

      Calls getOutputTags(Message) to calculate this set.
    • all

      public static <E extends Enum<E>, M extends Message> MessageDemux<E,M> all(Class<E> tags)
      Delivers a trivial instantiation of MessageDemux, see MessageDemux.All.
    • byKind

      public static <M extends Message> MessageDemux<Message.Kind,M> byKind()
      factory method for MessageDemux.ByKind