private static AttributesHolder getAttributeMappings(Annotation mapAnnotation, String mapType,
                                                         StreamDefinition streamDefinition) {
        List<Annotation> attributeAnnotations = mapAnnotation.getAnnotations(SiddhiConstants.ANNOTATION_ATTRIBUTES);
        DefinitionParserHelper.AttributesHolder attributesHolder = new DefinitionParserHelper.AttributesHolder();
        if (attributeAnnotations.size() > 0) {
            Map<String, String> elementMap = new HashMap<>();
            List<String> elementList = new ArrayList<>();
            Boolean attributesNameDefined = null;
            for (Element element : attributeAnnotations.get(0).getElements()) {
                if (element.getKey() == null) {
                    if (attributesNameDefined != null && attributesNameDefined) {
                        throw new SiddhiAppCreationException("Error at '" + mapType + "' defined at stream'" +
                                streamDefinition.getId() + "', some attributes are defined and some are not defined.",
                                element.getQueryContextStartIndex(), element.getQueryContextEndIndex());
                    }
                    attributesNameDefined = false;
                    elementList.add(element.getValue());
                } else {
                    if (attributesNameDefined != null && !attributesNameDefined) {
                        throw new SiddhiAppCreationException("Error at '" + mapType + "' defined at stream '" +
                                streamDefinition.getId() + "', some attributes are defined and some are not defined.",
                                element.getQueryContextStartIndex(), element.getQueryContextEndIndex());
                    }
                    attributesNameDefined = true;
                    elementMap.put(element.getKey(), element.getValue());
                }
            }
            if (elementMap.size() > 0) {
                List<Attribute> attributeList = streamDefinition.getAttributeList();
                for (int i = 0, attributeListSize = attributeList.size(); i < attributeListSize; i++) {
                    Attribute attribute = attributeList.get(i);
                    String value = elementMap.get(attribute.getName());
                    if (value == null) {
                        throw new SiddhiAppCreationException("Error at '" + mapType + "' defined at stream '" +
                                streamDefinition.getId() + "', attribute '" + attribute.getName() + "' is not mapped.",
                                mapAnnotation.getQueryContextStartIndex(), mapAnnotation.getQueryContextEndIndex());
                    }
                    assignMapping(attributesHolder, elementMap, i, attribute);
                }
            } else {
                List<Attribute> attributeList = streamDefinition.getAttributeList();
                if (elementList.size() != attributeList.size()) {
                    throw new SiddhiAppCreationException("Error at '" + mapType + "' defined at stream '" +
                            streamDefinition.getId() + "', '" + elementList.size() + "' mapping attributes are " +
                            "provided but expected attributes are '" + attributeList.size() + "'.",
                            mapAnnotation.getQueryContextStartIndex(), mapAnnotation.getQueryContextEndIndex());
                } else {
                    for (int i = 0; i < attributeList.size(); i++) {
                        Attribute attribute = attributeList.get(i);
                        String value = elementList.get(i);
                        elementMap.put(attribute.getName(), value);
                    }
                }
                for (int i = 0; i < attributeList.size(); i++) {
                    Attribute attribute = attributeList.get(i);
                    assignMapping(attributesHolder, elementMap, i, attribute);
                }
            }
        }
        return attributesHolder;
    }
Utility class for queryParser to help with QueryRuntime
generation.
modules/siddhi-core/src/main/java/io/siddhi/core/util/parser/helper/DefinitionParserHelper.java