242534f6ef998c0f709eadfac0b7c41850cd8e62
[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.Nonnull;
14 import javax.annotation.Nullable;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.PathArgument;
16 import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
17
18 /**
19  * Interface implemented to be extended by RibSupport.
20  * This interface exposes methods to access to Add Path information
21  * By default we implement non supported Multiple Path therefore
22  * 0 Path Id is returned and null PathArgument
23  */
24 interface AddPathRibSupport {
25     /**
26      * Extract PathId from route change received.
27      *
28      * @param normalizedNode Path Id Container
29      * @return pathId  The path identifier value
30      */
31     default Long extractPathId(@Nonnull NormalizedNode<?, ?> normalizedNode) {
32         return NON_PATH_ID;
33     }
34
35     /**
36      * Construct a PathArgument to an AddPathRoute.
37      *
38      * @param pathId  The path identifier
39      * @param routeId PathArgument leaf path
40      * @return routeId PathArgument + pathId or Null in case Add-path is not supported
41      */
42     @Nullable
43     default PathArgument getRouteIdAddPath(long pathId, @Nonnull PathArgument routeId) {
44         return null;
45     }
46
47     /**
48      * Create a new Path Argument for route Key removing remove Path Id from key.
49      * For non extension which doesnt support Multiple Path this step is not required.
50      *
51      * @param routeKeyPathArgument routeKey Path Argument
52      * @return new route Key
53      */
54     default @Nonnull PathArgument createRouteKeyPathArgument(@Nonnull PathArgument routeKeyPathArgument) {
55         return routeKeyPathArgument;
56     }
57 }