use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier in project controller by opendaylight.
the class NormalizedNodePrunerTest method countNodes.
private static int countNodes(final NormalizedNode<?, ?> normalizedNode, final String namespaceFilter) {
if (normalizedNode == null) {
return 0;
}
final AtomicInteger count = new AtomicInteger();
new NormalizedNodeNavigator((level, parentPath, normalizedNode1) -> {
if (!(normalizedNode1.getIdentifier() instanceof AugmentationIdentifier)) {
if (normalizedNode1.getIdentifier().getNodeType().getNamespace().toString().contains(namespaceFilter)) {
count.incrementAndGet();
}
}
}).navigate(YangInstanceIdentifier.EMPTY.toString(), normalizedNode);
return count.get();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier in project controller by opendaylight.
the class TestModel method createAugmentedListEntry.
public static MapEntryNode createAugmentedListEntry(final int id, final String name) {
Set<QName> childAugmentations = new HashSet<>();
childAugmentations.add(AUG_CONT_QNAME);
ContainerNode augCont = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(AUG_CONT_QNAME)).withChild(ImmutableNodes.leafNode(AUG_NAME_QNAME, name)).build();
final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
final AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(augmentationIdentifier).withChild(augCont).build();
return ImmutableMapEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifierWithPredicates(AUGMENTED_LIST_QNAME, ID_QNAME, id)).withChild(ImmutableNodes.leafNode(ID_QNAME, id)).withChild(augmentationNode).build();
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier in project controller by opendaylight.
the class BindingNormalizedCodecTest method testComplexAugmentationSerialization.
@Test
public void testComplexAugmentationSerialization() {
this.codec.onGlobalContextUpdated(this.context);
final PathArgument lastArg = this.codec.toYangInstanceIdentifier(BA_TREE_COMPLEX_USES).getLastPathArgument();
assertTrue(lastArg instanceof AugmentationIdentifier);
}
use of org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier 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.AugmentationIdentifier in project controller by opendaylight.
the class BindingNormalizedCodecTest method testLeafOnlyAugmentationSerialization.
@Test
public void testLeafOnlyAugmentationSerialization() {
this.codec.onGlobalContextUpdated(this.context);
final PathArgument leafOnlyLastArg = this.codec.toYangInstanceIdentifier(BA_TREE_LEAF_ONLY).getLastPathArgument();
assertTrue(leafOnlyLastArg instanceof AugmentationIdentifier);
assertTrue(((AugmentationIdentifier) leafOnlyLastArg).getPossibleChildNames().contains(SIMPLE_VALUE_QNAME));
}
Aggregations