Package eu.bandm.tools.message
Class MessageKindFilter<M extends Message>
java.lang.Object
eu.bandm.tools.message.SingleSender<M>
eu.bandm.tools.message.MessagePasser<M>
eu.bandm.tools.message.MessageKindFilter<M>
- Type Parameters:
M
- the type of the messages
- All Implemented Interfaces:
MessageReceiver<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 Summary
FieldsFields inherited from class eu.bandm.tools.message.SingleSender
drain
-
Constructor Summary
ConstructorsConstructorDescriptionMessageKindFilter
(@Opt MessageReceiver<? super M> d) Constructor with no kind is initially selected.MessageKindFilter
(@Opt MessageReceiver<? super M> d, Message.Kind... kk) Constructor with the given kinds initially selected. -
Method Summary
Modifier and TypeMethodDescriptionAdds allMessage.Kind
s which are marked as critical.Add all kinds to the selection.Adds the given kind to the selection.addKind
(Message.Kind... kk) Adds the given kinds to the selection.void
Propagate to theSingleSender.drain
if the message kind is in selection.Remove all kinds from the selection.Remove the given kind from the selectionremoveKind
(Message.Kind... kk) Remove the given kinds from the selectionMethods inherited from class eu.bandm.tools.message.SingleSender
getDrain, getReceiver, send, setDrain, 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
-
Field Details
-
kinds
The selected kinds.
-
-
Constructor Details
-
MessageKindFilter
Constructor with no kind is initially selected.- Parameters:
d
- the receiver of the messages.
-
MessageKindFilter
Constructor with the given kinds initially selected.- Parameters:
d
- the receiver of the messages.kk
- the kinds initially selected.
-
-
Method Details
-
addAllCriticalKinds
Adds allMessage.Kind
s which are marked as critical.- Returns:
- this for message chaining.
- See Also:
-
addKind
Adds the given kind to the selection.- Parameters:
k
- kind to add.- Returns:
- this instance for message chaining.
-
addKind
Adds the given kinds to the selection.- Parameters:
kk
- kinds to add.- Returns:
- this instance for message chaining.
-
addAllKinds
Add all kinds to the selection.- Returns:
- this instance for message chaining.
-
removeKind
Remove the given kind from the selection- Parameters:
k
- kind to remove.- Returns:
- this instance for message chaining.
-
removeKind
Remove the given kinds from the selection- Parameters:
kk
- kinds to remove.- Returns:
- this instance for message chaining.
-
removeAllKinds
Remove all kinds from the selection. No message will be propagated at all.- Returns:
- this instance for message chaining.
-
receive
Propagate to theSingleSender.drain
if the message kind is in selection.- Specified by:
receive
in interfaceMessageReceiver<M extends Message>
- Overrides:
receive
in classMessagePasser<M extends Message>
- Parameters:
m
- message to propagate.
-