}
public Message deserialize(byte[] bytes) throws IOException {
final DeserializeBean bean = mapper.readValue(bytes, DeserializeBean.class);
final Map<String, Object> fields = bean.getFields();
final Message message = new Message(
(String) fields.remove("message"),
(String) fields.remove("source"),
new DateTime((long) fields.remove("timestamp"), DateTimeZone.UTC)
);
final List<Stream> streamList = Lists.newArrayList();
for (String id : bean.getStreams()) {
Stream stream = getStream(id);
if (stream != null) {
streamList.add(stream);
}
}
message.setStreams(streamList);
message.addFields(fields);
final MessageInput input;
if (bean.getSourceInput() != null)
input = getMessageInput(bean.getSourceInput());
else
input = null;
if (input != null) {
message.setSourceInput(input);
}
return message;
}