2 * Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.protocol.bgp.mode.spi;
11 import org.opendaylight.protocol.bgp.mode.api.BestPath;
12 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
13 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
14 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
15 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
16 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeAttrBuilder;
18 public final class RouteEntryUtil {
19 private RouteEntryUtil() {
20 throw new UnsupportedOperationException();
23 public static MapEntryNode createSimpleRouteValue(final PathArgument routeId, final BestPath path) {
24 final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> b = Builders.mapEntryBuilder();
25 b.withNodeIdentifier((NodeIdentifierWithPredicates) routeId);
26 b.addChild(path.getAttributes());
30 public static MapEntryNode createComplexRouteValue(final PathArgument routeId, final BestPath path,
31 final MapEntryNode mapValues) {
32 final DataContainerNodeAttrBuilder<NodeIdentifierWithPredicates, MapEntryNode> mapEntryBuilder
33 = Builders.mapEntryBuilder();
34 mapEntryBuilder.withNodeIdentifier((NodeIdentifierWithPredicates) routeId);
35 mapEntryBuilder.addChild(path.getAttributes());
36 mapValues.getValue().forEach(mapEntryBuilder::addChild);
37 return mapEntryBuilder.build();