Search in sources :

Example 1 with AugmentationNode

use of org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode 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();
}
Also used : NodeIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier) AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) QName(org.opendaylight.yangtools.yang.common.QName) ContainerNode(org.opendaylight.yangtools.yang.data.api.schema.ContainerNode) AugmentationIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode) NodeIdentifierWithPredicates(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) HashSet(java.util.HashSet)

Example 2 with AugmentationNode

use of org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode in project controller by opendaylight.

the class CompositeModel method createTestContainer.

public static ContainerNode createTestContainer() {
    final LeafSetEntryNode<Object> nike = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "nike")).withValue("nike").build();
    final LeafSetEntryNode<Object> puma = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "shoe"), "puma")).withValue("puma").build();
    final LeafSetNode<Object> shoes = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "shoe"))).withChild(nike).withChild(puma).build();
    final LeafSetEntryNode<Object> five = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5)).withValue(5).build();
    final LeafSetEntryNode<Object> fifteen = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15)).withValue(15).build();
    final LeafSetNode<Object> numbers = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(QName.create(TEST_QNAME, "number"))).withChild(five).withChild(fifteen).build();
    Set<QName> childAugmentations = new HashSet<>();
    childAugmentations.add(AUG_QNAME);
    final YangInstanceIdentifier.AugmentationIdentifier augmentationIdentifier = new YangInstanceIdentifier.AugmentationIdentifier(childAugmentations);
    final AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(augmentationIdentifier).withChild(ImmutableNodes.leafNode(AUG_QNAME, "First Test")).build();
    return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)).withChild(augmentationNode).withChild(shoes).withChild(numbers).withChild(mapNodeBuilder(OUTER_LIST_QNAME).withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)).withChild(BAR_NODE).build()).build();
}
Also used : QName(org.opendaylight.yangtools.yang.common.QName) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode) HashSet(java.util.HashSet)

Example 3 with AugmentationNode

use of org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode in project controller by opendaylight.

the class SerializationUtilsTest method createNormalizedNode.

private static NormalizedNode<?, ?> createNormalizedNode() {
    final LeafSetNode<Object> leafSetNode = Builders.leafSetBuilder().withNodeIdentifier(id("leafSetNode")).withChild(createLeafSetEntry("leafSetNode", "leafSetValue1")).withChild(createLeafSetEntry("leafSetNode", "leafSetValue2")).build();
    final LeafSetNode<Object> orderedLeafSetNode = Builders.orderedLeafSetBuilder().withNodeIdentifier(id("orderedLeafSetNode")).withChild(createLeafSetEntry("orderedLeafSetNode", "value1")).withChild(createLeafSetEntry("orderedLeafSetNode", "value2")).build();
    final LeafNode<Boolean> booleanLeaf = createLeaf("booleanLeaf", true);
    final LeafNode<Byte> byteLeaf = createLeaf("byteLeaf", (byte) 0);
    final LeafNode<Short> shortLeaf = createLeaf("shortLeaf", (short) 55);
    final LeafNode<Integer> intLeaf = createLeaf("intLeaf", 11);
    final LeafNode<Long> longLeaf = createLeaf("longLeaf", 151515L);
    final LeafNode<String> stringLeaf = createLeaf("stringLeaf", "stringValue");
    final LeafNode<String> longStringLeaf = createLeaf("longStringLeaf", getLongString());
    final LeafNode<QName> qNameLeaf = createLeaf("stringLeaf", QName.create("base", "qName"));
    final LeafNode<YangInstanceIdentifier> idLeaf = createLeaf("stringLeaf", YangInstanceIdentifier.EMPTY);
    final MapEntryNode entry1 = Builders.mapEntryBuilder().withNodeIdentifier(listId("mapNode", "key", "key1")).withChild(stringLeaf).build();
    final MapEntryNode entry2 = Builders.mapEntryBuilder().withNodeIdentifier(listId("mapNode", "key", "key2")).withChild(stringLeaf).build();
    final MapNode mapNode = Builders.mapBuilder().withNodeIdentifier(id("mapNode")).withChild(entry1).withChild(entry2).build();
    final OrderedMapNode orderedMapNode = Builders.orderedMapBuilder().withNodeIdentifier(id("orderedMapNode")).withChild(entry2).withChild(entry1).build();
    final UnkeyedListEntryNode unkeyedListEntry1 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(id("unkeyedList")).withChild(stringLeaf).build();
    final UnkeyedListEntryNode unkeyedListEntry2 = Builders.unkeyedListEntryBuilder().withNodeIdentifier(id("unkeyedList")).withChild(stringLeaf).build();
    final UnkeyedListNode unkeyedListNode = Builders.unkeyedListBuilder().withNodeIdentifier(id("unkeyedList")).withChild(unkeyedListEntry1).withChild(unkeyedListEntry2).build();
    final ImmutableSet<QName> childNames = ImmutableSet.of(QName.create(CONTAINER_Q_NAME, "aug1"), QName.create(CONTAINER_Q_NAME, "aug1"));
    final AugmentationNode augmentationNode = Builders.augmentationBuilder().withNodeIdentifier(new YangInstanceIdentifier.AugmentationIdentifier(childNames)).withChild(createLeaf("aug1", "aug1Value")).withChild(createLeaf("aug2", "aug2Value")).build();
    final ChoiceNode choiceNode = Builders.choiceBuilder().withNodeIdentifier(id("choiceNode")).withChild(createLeaf("choiceLeaf", 12)).build();
    return Builders.containerBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(CONTAINER_Q_NAME)).withChild(booleanLeaf).withChild(byteLeaf).withChild(shortLeaf).withChild(intLeaf).withChild(longLeaf).withChild(stringLeaf).withChild(longStringLeaf).withChild(qNameLeaf).withChild(idLeaf).withChild(mapNode).withChild(orderedMapNode).withChild(unkeyedListNode).withChild(leafSetNode).withChild(orderedLeafSetNode).withChild(augmentationNode).withChild(choiceNode).build();
}
Also used : UnkeyedListEntryNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode) OrderedMapNode(org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode) MapNode(org.opendaylight.yangtools.yang.data.api.schema.MapNode) OrderedMapNode(org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode) ChoiceNode(org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) UnkeyedListNode(org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode) QName(org.opendaylight.yangtools.yang.common.QName) MapEntryNode(org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode) YangInstanceIdentifier(org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier) AugmentationNode(org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode)

Aggregations

QName (org.opendaylight.yangtools.yang.common.QName)3 YangInstanceIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier)3 AugmentationNode (org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode)3 HashSet (java.util.HashSet)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 AugmentationIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.AugmentationIdentifier)1 NodeIdentifier (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier)1 NodeIdentifierWithPredicates (org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates)1 ChoiceNode (org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode)1 ContainerNode (org.opendaylight.yangtools.yang.data.api.schema.ContainerNode)1 MapEntryNode (org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode)1 MapNode (org.opendaylight.yangtools.yang.data.api.schema.MapNode)1 OrderedMapNode (org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode)1 UnkeyedListEntryNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode)1 UnkeyedListNode (org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode)1