Search in sources :

Example 1 with NodeWithValue

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue in project controller by opendaylight.

the class NormalizedNodePrunerTest method testLeafSetEntryNodePrunedWhenHasParentAndSchemaMissing.

@Test
public void testLeafSetEntryNodePrunedWhenHasParentAndSchemaMissing() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.INVALID_QNAME));
    LeafSetEntryNode<Object> child = Builders.leafSetEntryBuilder().withValue("test").withNodeIdentifier(new NodeWithValue<>(TestModel.INVALID_QNAME, "test")).build();
    NormalizedNode<?, ?> input = Builders.leafSetBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.INVALID_QNAME)).withChild(child).build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);
    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertNull(actual);
}
Also used : NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) Test(org.junit.Test)

Example 2 with NodeWithValue

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue in project controller by opendaylight.

the class ResolveDataChangeState method getListenerChildrenWildcarded.

private static Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> getListenerChildrenWildcarded(final Collection<RegistrationTreeNode<DataChangeListenerRegistration<?>>> parentNodes, final PathArgument child) {
    if (parentNodes.isEmpty()) {
        return Collections.emptyList();
    }
    final List<RegistrationTreeNode<DataChangeListenerRegistration<?>>> result = new ArrayList<>();
    if (child instanceof NodeWithValue || child instanceof NodeIdentifierWithPredicates) {
        NodeIdentifier wildcardedIdentifier = new NodeIdentifier(child.getNodeType());
        addChildNodes(result, parentNodes, wildcardedIdentifier);
    }
    addChildNodes(result, parentNodes, child);
    return result;
}
Also used : RegistrationTreeNode(org.opendaylight.mdsal.dom.spi.RegistrationTreeNode) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) ArrayList(java.util.ArrayList) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)

Example 3 with NodeWithValue

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue in project controller by opendaylight.

the class NormalizedNodeInputStreamReader method readNormalizedNodeInternal.

private NormalizedNode<?, ?> readNormalizedNodeInternal() throws IOException {
    // each node should start with a byte
    byte nodeType = input.readByte();
    if (nodeType == NodeTypes.END_NODE) {
        LOG.trace("End node reached. return");
        lastLeafSetQName = null;
        return null;
    }
    switch(nodeType) {
        case NodeTypes.AUGMENTATION_NODE:
            YangInstanceIdentifier.AugmentationIdentifier augIdentifier = new YangInstanceIdentifier.AugmentationIdentifier(readQNameSet());
            LOG.trace("Reading augmentation node {} ", augIdentifier);
            return addDataContainerChildren(Builders.augmentationBuilder().withNodeIdentifier(augIdentifier)).build();
        case NodeTypes.LEAF_SET_ENTRY_NODE:
            QName name = lastLeafSetQName;
            if (name == null) {
                name = readQName();
            }
            Object value = readObject();
            NodeWithValue<Object> leafIdentifier = new NodeWithValue<>(name, value);
            LOG.trace("Reading leaf set entry node {}, value {}", leafIdentifier, value);
            return leafSetEntryBuilder().withNodeIdentifier(leafIdentifier).withValue(value).build();
        case NodeTypes.MAP_ENTRY_NODE:
            NodeIdentifierWithPredicates entryIdentifier = new NodeIdentifierWithPredicates(readQName(), readKeyValueMap());
            LOG.trace("Reading map entry node {} ", entryIdentifier);
            return addDataContainerChildren(Builders.mapEntryBuilder().withNodeIdentifier(entryIdentifier)).build();
        default:
            return readNodeIdentifierDependentNode(nodeType, new NodeIdentifier(readQName()));
    }
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)

Example 4 with NodeWithValue

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue in project controller by opendaylight.

the class AbstractNormalizedNodeDataOutput method writePathArgument.

@SuppressFBWarnings(value = "BC_UNCONFIRMED_CAST", justification = "The casts in the switch clauses are indirectly confirmed via the determination of 'type'.")
@Override
public void writePathArgument(final PathArgument pathArgument) throws IOException {
    byte type = PathArgumentTypes.getSerializablePathArgumentType(pathArgument);
    output.writeByte(type);
    switch(type) {
        case PathArgumentTypes.NODE_IDENTIFIER:
            NodeIdentifier nodeIdentifier = (NodeIdentifier) pathArgument;
            writeQName(nodeIdentifier.getNodeType());
            break;
        case PathArgumentTypes.NODE_IDENTIFIER_WITH_PREDICATES:
            NodeIdentifierWithPredicates nodeIdentifierWithPredicates = (NodeIdentifierWithPredicates) pathArgument;
            writeQName(nodeIdentifierWithPredicates.getNodeType());
            writeKeyValueMap(nodeIdentifierWithPredicates.getKeyValues());
            break;
        case PathArgumentTypes.NODE_IDENTIFIER_WITH_VALUE:
            NodeWithValue<?> nodeWithValue = (NodeWithValue<?>) pathArgument;
            writeQName(nodeWithValue.getNodeType());
            writeObject(nodeWithValue.getValue());
            break;
        case PathArgumentTypes.AUGMENTATION_IDENTIFIER:
            AugmentationIdentifier augmentationIdentifier = (AugmentationIdentifier) pathArgument;
            // No Qname in augmentation identifier
            writeQNameSet(augmentationIdentifier.getPossibleChildNames());
            break;
        default:
            throw new IllegalStateException("Unknown node identifier type is found : " + pathArgument.getClass().toString());
    }
}
Also used : AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 5 with NodeWithValue

use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue in project controller by opendaylight.

the class NormalizedNodePrunerTest method testLeafSetEntryNodeNotPrunedWhenHasParent.

@Test
public void testLeafSetEntryNodeNotPrunedWhenHasParent() throws IOException {
    NormalizedNodePruner pruner = prunerFullSchema(TestModel.TEST_PATH.node(TestModel.SHOE_QNAME));
    LeafSetEntryNode<Object> child = Builders.leafSetEntryBuilder().withValue("puma").withNodeIdentifier(new NodeWithValue<>(TestModel.SHOE_QNAME, "puma")).build();
    NormalizedNode<?, ?> input = Builders.leafSetBuilder().withNodeIdentifier(new NodeIdentifier(TestModel.SHOE_QNAME)).withChild(child).build();
    NormalizedNodeWriter.forStreamWriter(pruner).write(input);
    NormalizedNode<?, ?> actual = pruner.normalizedNode();
    assertEquals("normalizedNode", input, actual);
}
Also used : NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) NodeWithValue(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue) Test(org.junit.Test)

Aggregations

NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)5 NodeWithValue (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeWithValue)5 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)3 Test (org.junit.Test)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 ArrayList (java.util.ArrayList)1 RegistrationTreeNode (org.opendaylight.mdsal.dom.spi.RegistrationTreeNode)1 QName (org.opendaylight.yangtools.yang.common.QName)1 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)1 AugmentationIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier)1