StreamEventParser API
Custom parser converts a domain Quote object into an internal Joule StreamEvent
Objective
A StreamEventParser
converts domain-specific objects, such as a Quote
, into the required Joule StreamEvent
object ready for processing.
Example
The example demonstrates a custom implementation of the StreamEventParser
interface, specifically designed to convert a Quote
object into a StreamEvent
.
Class: StreamEventParser
All implementations must provide a concrete implement of the translate
method.
Parser Annotation
The class annotation defines the parser DSL element, indicating the parser's role in converting Quote
objects. It aids in custom serialisation settings. This is required.
Constructor
The constructor is required but does not contain any specific logic for this example.
Translate method
The core method that converts the input object into a collection of StreamEvent
objects.
This example the method checks if the input object is an instance of Quote
. If not, it returns null
, indicating non-valid conversion.
Otherwise, the quote attributes are mapped in to a single StreamEvent
which is then placed in to a Collections.singletonList()
and returned as a collection, as required by the method's signature.
Last updated