Package eu.bandm.tools.message
Class SimpleMessage.LocationMapper<D,E>
java.lang.Object
eu.bandm.tools.message.SingleSender<SimpleMessage<E>>
eu.bandm.tools.message.SimpleMessage.LocationMapper<D,E>
- Type Parameters:
D
- the type of the document identifier of the incoming locationsE
- the type of the document identifier of the outcoming locations
- All Implemented Interfaces:
MessageReceiver<SimpleMessage<D>>
- Enclosing class:
SimpleMessage<D>
public static class SimpleMessage.LocationMapper<D,E>
extends SingleSender<SimpleMessage<E>>
implements MessageReceiver<SimpleMessage<D>>
Passes all incoming messages to its drain, after applying the
given location map.
As with every SingleSender, the receiver must be set to a non-null value before the first message is received. Otherwise the code will crash intentionally.
(Since in and out locations can be of different type, this
general class cannot extend MessagePasser
.)
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) final LocationMap
<D, E> The map to be used for the location translations.(package private) final Function
<SimpleMessage<D>, SimpleMessage<E>> Function to be applied to the messages for translating the locations.Fields inherited from class eu.bandm.tools.message.SingleSender
drain
-
Constructor Summary
ConstructorsConstructorDescriptionLocationMapper
(@Opt MessageReceiver<SimpleMessage<E>> drain, LocationMap<D, E> map) Only constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoid
receive
(SimpleMessage<D> msg) Receive a message, apply the mapping to its location, and send it to the current receiver.Methods 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
-
map
The map to be used for the location translations. -
mapMessages
Function to be applied to the messages for translating the locations.
-
-
Constructor Details
-
LocationMapper
Only constructor.- Parameters:
drain
- where to send the translated messagesmap
- the map to use for location transformation
-
-
Method Details
-
receive
Receive a message, apply the mapping to its location, and send it to the current receiver.- Specified by:
receive
in interfaceMessageReceiver<D>
- Parameters:
msg
- the message to receive.
-