use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createTcpFlags.
private static List<TcpFlags> createTcpFlags(final UnkeyedListNode tcpFlagsData) {
final List<TcpFlags> tcpFlags = new ArrayList<>();
for (final UnkeyedListEntryNode node : tcpFlagsData.getValue()) {
final TcpFlagsBuilder tcpFlagsBuilder = new TcpFlagsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
tcpFlagsBuilder.setOp(BitmaskOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
tcpFlagsBuilder.setValue((Integer) valueNode.get().getValue());
}
tcpFlags.add(tcpFlagsBuilder.build());
}
return tcpFlags;
}
use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode in project bgpcep by opendaylight.
the class FlowspecIpv4NlriParserHelper method createProtocolsIps.
private static List<ProtocolIps> createProtocolsIps(final UnkeyedListNode protocolIpsData) {
final List<ProtocolIps> protocolIps = new ArrayList<>();
for (final UnkeyedListEntryNode node : protocolIpsData.getValue()) {
final ProtocolIpsBuilder ipsBuilder = new ProtocolIpsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(AbstractFlowspecNlriParser.OP_NID);
if (opValue.isPresent()) {
ipsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(AbstractFlowspecNlriParser.VALUE_NID);
if (valueNode.isPresent()) {
ipsBuilder.setValue((Short) valueNode.get().getValue());
}
protocolIps.add(ipsBuilder.build());
}
return protocolIps;
}
use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode 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();
}
use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode in project controller by opendaylight.
the class TestModel method createBaseTestContainerBuilder.
public static DataContainerNodeAttrBuilder<NodeIdentifier, ContainerNode> createBaseTestContainerBuilder() {
// Create a list of shoes
// This is to test leaf list entry
final LeafSetEntryNode<Object> nike = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new NodeWithValue<>(SHOE_QNAME, "nike")).withValue("nike").build();
final LeafSetEntryNode<Object> puma = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new NodeWithValue<>(SHOE_QNAME, "puma")).withValue("puma").build();
final LeafSetNode<Object> shoes = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(SHOE_QNAME)).withChild(nike).withChild(puma).build();
// Test a leaf-list where each entry contains an identity
final LeafSetEntryNode<Object> cap1 = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "capability"), DESC_QNAME)).withValue(DESC_QNAME).build();
final LeafSetNode<Object> capabilities = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "capability"))).withChild(cap1).build();
ContainerNode switchFeatures = ImmutableContainerNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(SWITCH_FEATURES_QNAME)).withChild(capabilities).build();
// Create a leaf list with numbers
final LeafSetEntryNode<Object> five = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 5)).withValue(5).build();
final LeafSetEntryNode<Object> fifteen = ImmutableLeafSetEntryNodeBuilder.create().withNodeIdentifier(new NodeWithValue<>(QName.create(TEST_QNAME, "number"), 15)).withValue(15).build();
final LeafSetNode<Object> numbers = ImmutableLeafSetNodeBuilder.create().withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "number"))).withChild(five).withChild(fifteen).build();
// Create augmentations
MapEntryNode augMapEntry = createAugmentedListEntry(1, "First Test");
// Create a bits leaf
NormalizedNodeAttrBuilder<NodeIdentifier, Object, LeafNode<Object>> myBits = Builders.leafBuilder().withNodeIdentifier(new NodeIdentifier(QName.create(TEST_QNAME, "my-bits"))).withValue(ImmutableSet.of("foo", "bar"));
// Create unkeyed list entry
UnkeyedListEntryNode unkeyedListEntry = Builders.unkeyedListEntryBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME)).withChild(ImmutableNodes.leafNode(NAME_QNAME, "unkeyed-entry-name")).build();
// Create YangInstanceIdentifier with all path arg types.
YangInstanceIdentifier instanceID = YangInstanceIdentifier.create(new NodeIdentifier(QName.create(TEST_QNAME, "qname")), new NodeIdentifierWithPredicates(QName.create(TEST_QNAME, "list-entry"), QName.create(TEST_QNAME, "key"), 10), new AugmentationIdentifier(ImmutableSet.of(QName.create(TEST_QNAME, "aug1"), QName.create(TEST_QNAME, "aug2"))), new NodeWithValue<>(QName.create(TEST_QNAME, "leaf-list-entry"), "foo"));
Map<QName, Object> keyValues = new HashMap<>();
keyValues.put(CHILDREN_QNAME, FIRST_CHILD_NAME);
// Create the document
return ImmutableContainerNodeBuilder.create().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TEST_QNAME)).withChild(myBits.build()).withChild(ImmutableNodes.leafNode(DESC_QNAME, DESC)).withChild(ImmutableNodes.leafNode(BOOLEAN_LEAF_QNAME, ENABLED)).withChild(ImmutableNodes.leafNode(SHORT_LEAF_QNAME, SHORT_ID)).withChild(ImmutableNodes.leafNode(BYTE_LEAF_QNAME, BYTE_ID)).withChild(ImmutableNodes.leafNode(TestModel.BIGINTEGER_LEAF_QNAME, BigInteger.valueOf(100))).withChild(ImmutableNodes.leafNode(TestModel.BIGDECIMAL_LEAF_QNAME, BigDecimal.valueOf(1.2))).withChild(ImmutableNodes.leafNode(SOME_REF_QNAME, instanceID)).withChild(ImmutableNodes.leafNode(MYIDENTITY_QNAME, DESC_QNAME)).withChild(Builders.unkeyedListBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(UNKEYED_LIST_QNAME)).withChild(unkeyedListEntry).build()).withChild(Builders.choiceBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(TWO_THREE_QNAME)).withChild(ImmutableNodes.leafNode(TWO_QNAME, "two")).build()).withChild(Builders.orderedMapBuilder().withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(ORDERED_LIST_QNAME)).withValue(ImmutableList.<MapEntryNode>builder().add(mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "1").build(), mapEntryBuilder(ORDERED_LIST_QNAME, ORDERED_LIST_ENTRY_QNAME, "2").build()).build()).build()).withChild(shoes).withChild(numbers).withChild(switchFeatures).withChild(mapNodeBuilder(AUGMENTED_LIST_QNAME).withChild(augMapEntry).build()).withChild(mapNodeBuilder(OUTER_LIST_QNAME).withChild(mapEntry(OUTER_LIST_QNAME, ID_QNAME, ONE_ID)).withChild(BAR_NODE).build());
}
use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createPorts.
private static List<Ports> createPorts(final UnkeyedListNode portsData) {
final List<Ports> ports = new ArrayList<>();
for (final UnkeyedListEntryNode node : portsData.getValue()) {
final PortsBuilder portsBuilder = new PortsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
portsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
portsBuilder.setValue((Integer) valueNode.get().getValue());
}
ports.add(portsBuilder.build());
}
return ports;
}
Aggregations