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 MessageReceivers. Intended for de-multiplexing a message stream as calculated by some derived class.
  • Field Details

    • outlets

      protected final EnumMap<E extends Enum<E>,@Opt MessageReceiver<? super M extends Message>> outlets
      Internal directory of the different drains per tag.
    • tagclass

      protected final Class<E extends Enum<E>> tagclass
      Configuration value holding the class used for tagging.
  • Constructor Details

    • PrimitiveMessageDemux

      protected PrimitiveMessageDemux(Class<E> tagclass)
      Only constructor.
      Parameters:
      tagclass - the class used as index to the MessageReceivers.
  • Method Details

    • setReceiver

      public void setReceiver(E tag, @Opt @Opt MessageReceiver<? super M> rec)
      Set the receiver for one particular tag. Setting null is allowed and acts like a MessageDisposer.
    • getReceiver

      @Opt public @Opt MessageReceiver<? super M> getReceiver(E tag)
      Get the receiver for one particular tag.
    • receive

      protected void receive(E tag, M msg)
      Auxiliary internal method for performing the sending to a certain MessageReceiver, as indicated by an enum value.

      This method is called by some derived class, after it has determined the applicable enum value or value set.