BUG-5844: Fix ComplexRouteEntry creation
[bgpcep.git] / bgp / path-selection-mode / src / main / java / org / opendaylight / protocol / bgp / mode / impl / add / all / paths / SimpleRouteEntry.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.protocol.bgp.mode.impl.add.all.paths;
10
11 import com.google.common.primitives.UnsignedInteger;
12 import org.opendaylight.protocol.bgp.mode.api.BestPath;
13 import org.opendaylight.protocol.bgp.mode.impl.add.RouteKey;
14 import org.opendaylight.protocol.bgp.mode.spi.RouteEntryUtil;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
17 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
18 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
19
20 final class SimpleRouteEntry extends AbstractAllPathsRouteEntry {
21     @Override
22     public boolean removeRoute(final UnsignedInteger routerId, final Long remotePathId) {
23         final RouteKey key = new RouteKey(routerId, remotePathId);
24         return removeRoute(key, getOffsets().offsetOf(key));
25     }
26
27     @Override
28     public MapEntryNode createValue(final YangInstanceIdentifier.PathArgument routeId, final BestPath path) {
29         return RouteEntryUtil.createSimpleRouteValue(routeId, path);
30     }
31
32     @Override
33     public int addRoute(final UnsignedInteger routerId, final Long remotePathId, final NodeIdentifier attII, final NormalizedNode<?, ?> data) {
34         return addRoute(new RouteKey(routerId, remotePathId), attII, data);
35     }
36 }