Easy conversion between SymEvent and SymMessage
dferguson992 opened this issue · comments
SymEvent and SymMessage seem to be almost the same thing. If anything, the relationship could be a SymEvent HAS A SymMessage. This would allow all kinds of read methods to get back a SymEvent, and the developer can extract the SymMessage within, if one exists.
The reason I suggest this is because there does not seem to be an easy way to convert SymEvent to SymMessage, while there are easy ways to read both types of objects separately.
They are far from the same thing as SymEvent carries support for all event types (SymEventTypes) from the datafeed. Each event carries a specific payload that maps to a particular Sym model. To your point, SymEvent HAS A SymMessage...
So if you wanted to convert an event to a SymMessage...
SymEventTypes.Type type = SymEventTypes.Type.fromValue(symEvent.getType());
if (type == MESSAGESENT){
SymMessage symMessage = symEvent.getPayload().getMessageSent();
}