- private List<Ipv4Prefix> extractPrefixes(final Collection<MapEntryNode> routes) {
- final List<Ipv4Prefix> prefs = new ArrayList<>(routes.size());
- for (final MapEntryNode ipv4Route : routes) {
- final String prefix = (String) ipv4Route.getChild(this.routeKeyLeaf).get().getValue();
- prefs.add(new Ipv4Prefix(prefix));
- }
- return prefs;
+ private List<Nlri> extractNlris(final Collection<MapEntryNode> routes) {
+ return routes.stream().map(ipv4Route -> new NlriBuilder().setPrefix(new Ipv4Prefix(extractPrefix(ipv4Route)))
+ .setPathId(extractPathId(ipv4Route)).build()).collect(Collectors.toList());
+ }
+
+ private List<WithdrawnRoutes> extractWithdrawnRoutes(final Collection<MapEntryNode> routes) {
+ return routes.stream().map(ipv4Route -> new WithdrawnRoutesBuilder()
+ .setPrefix(new Ipv4Prefix(extractPrefix(ipv4Route))).setPathId(extractPathId(ipv4Route)).build())
+ .collect(Collectors.toList());
+ }
+
+ private String extractPrefix(final MapEntryNode ipv4Route) {
+ return (String) ipv4Route.getChild(this.routeKeyPrefixLeaf).get().getValue();
+ }
+
+ private PathId extractPathId(final MapEntryNode ipv4Route) {
+ final Optional<DataContainerChild<? extends PathArgument, ?>> pathId = ipv4Route
+ .getChild(this.routeKeyPathIdLeaf);
+ return pathId.map(dataContainerChild -> new PathId((Long) dataContainerChild.getValue())).orElse(null);
+ }
+
+ public void close() {
+ this.registerDataTreeChangeListener.close();
+ }
+
+ boolean isMpSupported() {
+ return this.mpSupport;
+ }
+
+ @Override
+ public long getPrefixesSentCount() {
+ return this.prefixesSentCounter.longValue();