Rib support refactoring II
[bgpcep.git] / bgp / rib-spi / src / main / java / org / opendaylight / protocol / bgp / rib / spi / AddPathRibSupport.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.rib.spi;
10
11 import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID;
12
13 import javax.annotation.Nullable;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
15 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
16
17 /**
18  * Interface implemented to be extended by RibSupport.
19  * This interface exposes methods to access to Add Path information
20  * By default we implement non supported Multiple Path therefore
21  * 0 Path Id is returned and null PathArgument
22  */
23 interface AddPathRibSupport {
24     /**
25      * Extract PathId from route change received
26      *
27      * @param normalizedNode Path Id Container
28      * @return pathId  The path identifier value
29      */
30     default Long extractPathId(NormalizedNode<?, ?> normalizedNode) {
31         return NON_PATH_ID;
32     }
33
34     /**
35      * Construct a PathArgument to an AddPathRoute
36      *
37      * @param pathId  The path identifier
38      * @param routeId PathArgument leaf path
39      * @return routeId PathArgument + pathId or Null in case Add-path is not supported
40      */
41     @Nullable default PathArgument getRouteIdAddPath(long pathId, PathArgument routeId) {
42         return null;
43     }
44 }