Custom parsing example
Custom parser converts a domain Quote object into an internal Joule StreamEvent
Objective
Example
@JsonRootName(value = "quote parser")
public class QuoteToStreamEventParser implements StreamEventParser {
public QuoteToStreamEventParser() {
// Required
}
@Override
public Collection<StreamEvent> translate(Object o) throws TranslationException {
Collection<StreamEvent> events = null;
if(o instanceof Quote){
Quote quote = (Quote) o;
StreamEvent event = new StreamEvent("quote");
event.setEventTime(quote.time());
event.addValue("symbol", quote.symbol());
event.addValue("bid", quote.bid());
event.addValue("ask", quote.ask());
event.addValue("volatility", quote.volatility());
event.addValue("volume", quote.volume());
event.addValue("date", quote.date());
events = Collections.singletonList( event);
}
return events;
}
}Explanation
Parser Annotation
Constructor
Translate method
Quote attributes description
Attributes
Description
Type
Last updated