673baa487516bc9714a47a9e8068880c125d2cf2
[bgpcep.git] / bgp / path-selection-mode / src / main / java / org / opendaylight / protocol / bgp / mode / impl / add / n / paths / SimpleRouteEntry.java
1 /*
2  * Copyright (c) 2015 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 package org.opendaylight.protocol.bgp.mode.impl.add.n.paths;
9
10 import com.google.common.primitives.UnsignedInteger;
11 import org.opendaylight.protocol.bgp.mode.api.BestPath;
12 import org.opendaylight.protocol.bgp.mode.impl.add.RouteKey;
13 import org.opendaylight.protocol.bgp.mode.spi.RouteEntryUtil;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
16 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
17 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
18
19 final class SimpleRouteEntry extends AbstractNPathsRouteEntry {
20     SimpleRouteEntry(final Long npaths) {
21         super(npaths);
22     }
23
24     @Override
25     public boolean removeRoute(final UnsignedInteger routerId, final Long remotePathId) {
26         final RouteKey key = new RouteKey(routerId, remotePathId);
27         return removeRoute(key, getOffsets().offsetOf(key));
28     }
29
30     @Override
31     public MapEntryNode createValue(final PathArgument routeId, final BestPath path) {
32         return RouteEntryUtil.createSimpleRouteValue(routeId, path);
33     }
34
35     @Override
36     public int addRoute(final UnsignedInteger routerId, final Long remotePathId,
37             final NodeIdentifier attributesIdentifier, final NormalizedNode<?, ?> data) {
38         return addRoute(new RouteKey(routerId, remotePathId), attributesIdentifier, data);
39     }
40 }