symphonyoss / symphony-java-client

Java client library for Symphony
Apache License 2.0
34 stars 37 forks source link

Easy conversion between SymEvent and SymMessage #79

Closed dferguson992 closed 7 years ago

dferguson992 commented 7 years ago

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.

ftbb commented 7 years ago

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();
  }