public class MessageUnpacker<T> extends Object
To use this class, type the generic to the Java Bean class to which the message will be unpacked and provide the constructor the class of it as well. For example:
MessageUnpacker<Twist> unpacker = new MessageUnpacker<Twist>(Twist.class);. Then provide the
unpackRosMessage(com.fasterxml.jackson.databind.JsonNode) method the JsonNode
provided to a RosListenDelegate to unpack the "msg" field into the Java Bean. This will also work
with Java Beans with generics. For example, you can do
MessageUnpacker<PrimitiveMsg<String>> unpacker = new MessageUnpacker<PrimitiveMsg<String>>(PrimitiveMsg.class);.
| Modifier and Type | Field and Description |
|---|---|
protected Class<?> |
javaClass |
protected com.fasterxml.jackson.databind.ObjectMapper |
mapper |
| Constructor and Description |
|---|
MessageUnpacker(Class<?> javaClass)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
T |
unpackRosMessage(com.fasterxml.jackson.databind.JsonNode rosBridgeMessage)
Unpacks a ros message into the appropriate Java bean from the JSON message returned by
ros bridge.
|
protected com.fasterxml.jackson.databind.ObjectMapper mapper
protected Class<?> javaClass
public T unpackRosMessage(com.fasterxml.jackson.databind.JsonNode rosBridgeMessage)
JsonNode that is given to a RosListenDelegate
RosListenDelegate.receive(com.fasterxml.jackson.databind.JsonNode, String) method.
If the provided JsonNode argument of this method
does not have a "msg" field, then it will attempt to unpack from the whole JSON node.rosBridgeMessage - the JsonNode from RosBridge.Copyright © 2016. All rights reserved.