protected NodeDefinition findChildNodeDef()

in src/main/java/org/apache/sling/testing/mock/jcr/MockNode.java [494:519]


    protected NodeDefinition findChildNodeDef(String name) throws RepositoryException {
        NodeDefinition nodeDef = null;
        Node parent = getParent();
        if (parent != null) {
            // try the primary type
            NodeType nt = parent.getPrimaryNodeType();
            NodeDefinition[] childNodeDefinitions = nt.getChildNodeDefinitions();
            nodeDef = Stream.of(childNodeDefinitions)
                .filter(def -> name.equals(def.getName()))
                .findFirst().orElse(null);
            if (nodeDef == null) {
                // try the mixins
                NodeType[] mixinNodeTypes = parent.getMixinNodeTypes();
                for (NodeType nodeType : mixinNodeTypes) {
                    childNodeDefinitions = nodeType.getChildNodeDefinitions();
                    nodeDef = Stream.of(childNodeDefinitions)
                        .filter(def -> name.equals(def.getName()))
                        .findFirst().orElse(null);
                    if (nodeDef != null) {
                        break;
                    }
                }
            }
        }
        return nodeDef;
    }