Search in sources :

Example 1 with InnerNode

use of org.onosproject.yang.model.InnerNode in project onos by opennetworkinglab.

the class DataNodes method child.

public static Optional<DataNode> child(DataNode node, String name, String namespace) {
    if (node instanceof InnerNode) {
        InnerNode inode = (InnerNode) node;
        NodeKey<?> key = NodeKey.builder().schemaId(name, namespace).build();
        return Optional.ofNullable(inode.childNodes().get(key));
    } else {
        return Optional.empty();
    }
}
Also used : InnerNode(org.onosproject.yang.model.InnerNode)

Example 2 with InnerNode

use of org.onosproject.yang.model.InnerNode in project onos by opennetworkinglab.

the class DataNodes method child.

public static Optional<DataNode> child(DataNode node, SchemaId child) {
    if (node instanceof InnerNode) {
        InnerNode inode = (InnerNode) node;
        NodeKey<?> key = NodeKey.builder().schemaId(child).build();
        return Optional.ofNullable(inode.childNodes().get(key));
    } else {
        return Optional.empty();
    }
}
Also used : InnerNode(org.onosproject.yang.model.InnerNode)

Example 3 with InnerNode

use of org.onosproject.yang.model.InnerNode in project onos by opennetworkinglab.

the class DistributedDynamicConfigStore method traverseInner.

// FIXME this is more like addInnteNode
/**
 * @param path pointing to {@code node}
 * @param node node
 */
private void traverseInner(String path, InnerNode node) {
    log.trace("traverseInner({}, {})", path, node);
    addKey(path, node.type());
    Map<NodeKey, DataNode> entries = node.childNodes();
    if (entries.size() == 0) {
        return;
    }
    // FIXME ignoring results
    entries.forEach((k, v) -> {
        String tempPath;
        tempPath = ResourceIdParser.appendNodeKey(path, v.key());
        if (v.type() == DataNode.Type.SINGLE_INSTANCE_LEAF_VALUE_NODE) {
            addLeaf(tempPath, (LeafNode) v);
        } else if (v.type() == DataNode.Type.MULTI_INSTANCE_LEAF_VALUE_NODE) {
            tempPath = ResourceIdParser.appendLeafList(tempPath, (LeafListKey) v.key());
            addLeaf(tempPath, (LeafNode) v);
        } else if (v.type() == DataNode.Type.SINGLE_INSTANCE_NODE) {
            traverseInner(tempPath, (InnerNode) v);
        } else if (v.type() == DataNode.Type.MULTI_INSTANCE_NODE) {
            tempPath = ResourceIdParser.appendKeyList(tempPath, (ListKey) v.key());
            traverseInner(tempPath, (InnerNode) v);
        } else {
            throw new FailedException("Invalid node type");
        }
    });
}
Also used : DataNode(org.onosproject.yang.model.DataNode) FailedException(org.onosproject.config.FailedException) LeafNode(org.onosproject.yang.model.LeafNode) NodeKey(org.onosproject.yang.model.NodeKey) InnerNode(org.onosproject.yang.model.InnerNode)

Aggregations

InnerNode (org.onosproject.yang.model.InnerNode)3 FailedException (org.onosproject.config.FailedException)1 DataNode (org.onosproject.yang.model.DataNode)1 LeafNode (org.onosproject.yang.model.LeafNode)1 NodeKey (org.onosproject.yang.model.NodeKey)1