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);
}
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;
}
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()));
}
}
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());
}
}
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);
}
Aggregations