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