public static SelectiveComplexEventPopulater constructEventPopulator(MetaStreamEvent metaStreamEvent, int
            streamEventChainIndex, List<Attribute> attributes) {

        List<StreamMappingElement> streamMappingElements = new ArrayList<StreamMappingElement>();
        for (int i = 0, attributesSize = attributes.size(); i < attributesSize; i++) {
            Attribute attribute = attributes.get(i);
            StreamMappingElement streamMappingElement = new StreamMappingElement();
            streamMappingElement.setFromPosition(i);
            int index = metaStreamEvent.getOutputData().indexOf(attribute);
            if (index > -1) {
                streamMappingElement.setToPosition(new int[]{streamEventChainIndex, 0, OUTPUT_DATA_INDEX, index});
            } else {
                index = metaStreamEvent.getOnAfterWindowData().indexOf(attribute);
                if (index > -1) {
                    streamMappingElement.setToPosition(new int[]{streamEventChainIndex, 0,
                            ON_AFTER_WINDOW_DATA_INDEX, index});
                } else {
                    index = metaStreamEvent.getBeforeWindowData().indexOf(attribute);
                    if (index > -1) {
                        streamMappingElement.setToPosition(new int[]{streamEventChainIndex, 0,
                                BEFORE_WINDOW_DATA_INDEX, index});
                    } else {
                        streamMappingElement.setToPosition(null);
                    }
                }
            }
            streamMappingElements.add(streamMappingElement);
        }

        return new SelectiveComplexEventPopulater(streamMappingElements);

    }
Constructs StreamEventPopulater according to MetaStateEvent and to be mapped attributes

@param metaStreamEvent       info for populating the StreamEvent
@param streamEventChainIndex StreamEvent chain index
@param attributes            mapped attributes
@return StateEventPopulater
modules/siddhi-core/src/main/java/io/siddhi/core/event/stream/populater/StreamEventPopulaterFactory.java