public void addNode()

in src/main/java/org/apache/sling/feature/cpconverter/index/IndexDefinitions.java [57:87]


    public void addNode(@NotNull String parentPath, @NotNull DocViewNode2 node) {
        List<DocViewNode2> currentChildren = children.computeIfAbsent(parentPath, k -> new ArrayList<>());
        DocViewNode2 existing = null;

        if ( CollectionUtils.isEmpty(node.getProperties())
                && ( binaries.get(parentPath + "/" + node.getName().getLocalName()) == null
                || node.getName().getLocalName().contains(".xml"))){
            return;
        }
        for ( DocViewNode2 currentChild : currentChildren ) {

            // prevent duplicates
            if ( currentChild.getName().equals(node.getName() )) {
                // new node holds less information. There should not be a scenario where we need to
                // merge properties.
                if ( node.getProperties().size() <= currentChild.getProperties().size() ) {
                    return;
                }

                existing = currentChild;
            }
        }

        // remove node marked as placeholder
        if ( existing != null ) {
            currentChildren.remove(existing);
        }

        // add new node
        currentChildren.add(node);
    }