Class MessageKindFilter<M extends Message>

Type Parameters:
M - the type of the messages
All Implemented Interfaces:
MessageReceiver<M>

public class MessageKindFilter<M extends Message> extends MessagePasser<M>
A filter which propagates only those messages the kind of which is currently in the selection.

As with any MessagePasser, the receiver must be set to a non-null value before the first message is received. Otherwise the code may crash intentionally.

  • Field Details

  • Constructor Details

    • MessageKindFilter

      public MessageKindFilter(@Opt @Opt MessageReceiver<? super M> d)
      Constructor with no kind is initially selected.
      Parameters:
      d - the receiver of the messages.
    • MessageKindFilter

      public MessageKindFilter(@Opt @Opt MessageReceiver<? super M> d, Message.Kind... kk)
      Constructor with the given kinds initially selected.
      Parameters:
      d - the receiver of the messages.
      kk - the kinds initially selected.
  • Method Details

    • addAllCriticalKinds

      public MessageKindFilter<M> addAllCriticalKinds()
      Adds all Message.Kinds which are marked as critical.
      Returns:
      this for message chaining.
      See Also:
    • addKind

      public MessageKindFilter<M> addKind(Message.Kind k)
      Adds the given kind to the selection.
      Parameters:
      k - kind to add.
      Returns:
      this instance for message chaining.
    • addKind

      public MessageKindFilter<M> addKind(Message.Kind... kk)
      Adds the given kinds to the selection.
      Parameters:
      kk - kinds to add.
      Returns:
      this instance for message chaining.
    • addAllKinds

      public MessageKindFilter<M> addAllKinds()
      Add all kinds to the selection.
      Returns:
      this instance for message chaining.
    • removeKind

      public MessageKindFilter<M> removeKind(Message.Kind k)
      Remove the given kind from the selection
      Parameters:
      k - kind to remove.
      Returns:
      this instance for message chaining.
    • removeKind

      public MessageKindFilter<M> removeKind(Message.Kind... kk)
      Remove the given kinds from the selection
      Parameters:
      kk - kinds to remove.
      Returns:
      this instance for message chaining.
    • removeAllKinds

      public MessageKindFilter<M> removeAllKinds()
      Remove all kinds from the selection. No message will be propagated at all.
      Returns:
      this instance for message chaining.
    • receive

      public void receive(M m)
      Propagate to the SingleSender.drain if the message kind is in selection.
      Specified by:
      receive in interface MessageReceiver<M extends Message>
      Overrides:
      receive in class MessagePasser<M extends Message>
      Parameters:
      m - message to propagate.