protected ComplexEventChunk<StateEvent> constructMatchingStateEventChunk(
            ComplexEventChunk matchingComplexEventChunk, boolean convertToStreamEvent,
            StateEventFactory stateEventFactory,
            int matchingStreamIndex, StreamEventFactory streamEventFactory,
            StreamEventConverter streamEventConverter) {
        ComplexEventChunk<StateEvent> stateEventChunk = new ComplexEventChunk<>();
        while (matchingComplexEventChunk.hasNext()) {
            ComplexEvent matchingComplexEvent = matchingComplexEventChunk.next();
            matchingComplexEventChunk.remove();
            StateEvent stateEvent = stateEventFactory.newInstance();
            if (convertToStreamEvent) {
                StreamEvent borrowEvent = streamEventFactory.newInstance();
                streamEventConverter.convertData(
                        matchingComplexEvent.getTimestamp(),
                        matchingComplexEvent.getOutputData(),
                        matchingComplexEvent.getType() == ComplexEvent.Type.EXPIRED ? ComplexEvent.Type.CURRENT :
                                matchingComplexEvent.getType(),
                        borrowEvent);
                stateEvent.addEvent(matchingStreamIndex, borrowEvent);
            } else {
                stateEvent.addEvent(matchingStreamIndex, (StreamEvent) matchingComplexEvent);
            }
            stateEventChunk.add(stateEvent);
        }
        return stateEventChunk;
    }
Abstract class to represent parent callback implementation which allows users to get processed events from Siddhi
queries. There are multiple implementation of this which will receive events and perform various tasks.
modules/siddhi-core/src/main/java/io/siddhi/core/query/output/callback/OutputCallback.java