use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode in project bgpcep by opendaylight.
the class EvpnNlriParserTest method testExtractEvpnDestination.
@Test
public void testExtractEvpnDestination() throws BGPParsingException {
final DataContainerNodeAttrBuilder<NodeIdentifier, UnkeyedListEntryNode> evpnBI = ImmutableUnkeyedListEntryNodeBuilder.create();
evpnBI.withNodeIdentifier(EVPN_NID);
evpnBI.withChild(createMACIpAdvChoice());
evpnBI.withChild(createValueBuilder(RD_MODEL, RD_NID).build());
final EvpnDestination destResult = EvpnNlriParser.extractEvpnDestination(evpnBI.build());
final EvpnDestination expected = new EvpnDestinationBuilder().setRouteDistinguisher(RD).setEvpnChoice(MACIpAdvRParserTest.createdExpectedResult()).build();
assertEquals(expected, destResult);
}
use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createDscpsLengths.
private static List<Dscps> createDscpsLengths(final UnkeyedListNode dscpLengthsData) {
final List<Dscps> dscpsLengths = new ArrayList<>();
for (final UnkeyedListEntryNode node : dscpLengthsData.getValue()) {
final DscpsBuilder dscpsLengthsBuilder = new DscpsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
dscpsLengthsBuilder.setOp(NumericOneByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
dscpsLengthsBuilder.setValue(new Dscp((Short) valueNode.get().getValue()));
}
dscpsLengths.add(dscpsLengthsBuilder.build());
}
return dscpsLengths;
}
use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createSourcePorts.
private static List<SourcePorts> createSourcePorts(final UnkeyedListNode sourcePortsData) {
final List<SourcePorts> sourcePorts = new ArrayList<>();
for (final UnkeyedListEntryNode node : sourcePortsData.getValue()) {
final SourcePortsBuilder sourcePortsBuilder = new SourcePortsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
sourcePortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
sourcePortsBuilder.setValue((Integer) valueNode.get().getValue());
}
sourcePorts.add(sourcePortsBuilder.build());
}
return sourcePorts;
}
use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method createDestinationPorts.
private static List<DestinationPorts> createDestinationPorts(final UnkeyedListNode destinationPortsData) {
final List<DestinationPorts> destinationPorts = new ArrayList<>();
for (final UnkeyedListEntryNode node : destinationPortsData.getValue()) {
final DestinationPortsBuilder destPortsBuilder = new DestinationPortsBuilder();
final Optional<DataContainerChild<? extends PathArgument, ?>> opValue = node.getChild(OP_NID);
if (opValue.isPresent()) {
destPortsBuilder.setOp(NumericTwoByteOperandParser.INSTANCE.create((Set<String>) opValue.get().getValue()));
}
final Optional<DataContainerChild<? extends PathArgument, ?>> valueNode = node.getChild(VALUE_NID);
if (valueNode.isPresent()) {
destPortsBuilder.setValue((Integer) valueNode.get().getValue());
}
destinationPorts.add(destPortsBuilder.build());
}
return destinationPorts;
}
use of org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode in project bgpcep by opendaylight.
the class AbstractFlowspecNlriParser method extractFlowspec.
public final List<Flowspec> extractFlowspec(final DataContainerNode<?> route) {
requireNonNull(route, "Cannot extract flowspec from null route.");
final List<Flowspec> fsList = new ArrayList<>();
final Optional<DataContainerChild<? extends PathArgument, ?>> flowspecs = route.getChild(FLOWSPEC_NID);
if (flowspecs.isPresent()) {
for (final UnkeyedListEntryNode flowspec : ((UnkeyedListNode) flowspecs.get()).getValue()) {
final FlowspecBuilder fsBuilder = new FlowspecBuilder();
final Optional<DataContainerChild<?, ?>> flowspecType = flowspec.getChild(FLOWSPEC_TYPE_NID);
if (flowspecType.isPresent()) {
final ChoiceNode fsType = (ChoiceNode) flowspecType.get();
processFlowspecType(fsType, fsBuilder);
}
fsList.add(fsBuilder.build());
}
}
return fsList;
}
Aggregations