Package eu.bandm.tools.message
Class MessageLevelFilter<M extends Message>
java.lang.Object
eu.bandm.tools.message.MessageLevelFilter<M>
- Type Parameters:
M
- the message subtype which can be received
- All Implemented Interfaces:
MessageReceiver<M>
A filter which sends messages only to its sink if their
level value is equal to or below a given threshold.
-
Field Summary
Modifier and TypeFieldDescription(package private) MessageReceiver
<? super M> The receiver of all messages which pass this filter.(package private) int
Level threshold.(package private) EnumSet
<Message.Kind> Set of Message.Kind which will not be suppressed by the threshold, i.e. which will always be forwarded. -
Constructor Summary
ConstructorDescriptionConstructor with no initial drain.MessageLevelFilter
(MessageReceiver<M> drain) Constructor with an initial drain. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Receive a message and propagate it when it passes the threshold.setDrain
(MessageReceiver<? super M> drain) Set the receiver of all messages which pass this filter.setLevel
(int level) Set the level threshold.setUnfilteredKinds
(EnumSet<Message.Kind> unfiltered) Define the set of Message.Kind which will not be suppressed by the threshold, i.e. which will always be forwarded.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
-
level
int levelLevel threshold. Only messages with a level equal or lower to this value are propagated. -
drain
MessageReceiver<? super M extends Message> drainThe receiver of all messages which pass this filter. -
unfiltered
EnumSet<Message.Kind> unfilteredSet of Message.Kind which will not be suppressed by the threshold, i.e. which will always be forwarded.
-
-
Constructor Details
-
MessageLevelFilter
public MessageLevelFilter()Constructor with no initial drain. Before the filter can be used,setDrain(MessageReceiver)
must be called. -
MessageLevelFilter
Constructor with an initial drain.- Parameters:
drain
- the receiver of all messages which pass this filter.
-
-
Method Details
-
setDrain
Set the receiver of all messages which pass this filter.- Parameters:
drain
- the receiver of all messages which pass this filter.- Returns:
- this for message chaining.
-
setLevel
Set the level threshold. Only messages with a level equal or lower to this value are propagated.- Parameters:
level
- the threshold level.- Returns:
- this for message chaining.
-
setUnfilteredKinds
Define the set of Message.Kind which will not be suppressed by the threshold, i.e. which will always be forwarded. The initial setting lets all error and failure messages pass, what is appropriate in most use cases.- Parameters:
unfiltered
- the set of kinds which will not be suppressed by the level- Returns:
- this for message chaining.
-
receive
Receive a message and propagate it when it passes the threshold.- Specified by:
receive
in interfaceMessageReceiver<M extends Message>
- Parameters:
m
- the message to receive.- Throws:
NullPointerException
- if the drain has not been set, either by constructor or by invokingsetDrain(MessageReceiver)
.
-