2 * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
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
9 package org.opendaylight.protocol.bgp.rib.spi.entry;
11 import static com.google.common.base.Verify.verifyNotNull;
12 import static org.opendaylight.protocol.bgp.parser.spi.PathIdUtil.NON_PATH_ID_VALUE;
14 import org.eclipse.jdt.annotation.NonNull;
15 import org.opendaylight.protocol.bgp.rib.spi.RIBSupport;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.PeerId;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.Tables;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
21 import org.opendaylight.yangtools.yang.binding.ChildOf;
22 import org.opendaylight.yangtools.yang.binding.ChoiceIn;
23 import org.opendaylight.yangtools.yang.binding.DataObject;
24 import org.opendaylight.yangtools.yang.binding.Identifiable;
25 import org.opendaylight.yangtools.yang.binding.Identifier;
28 * Preexistent routes to be advertized before process any route advertized by the peer.
30 * @author Claudio D. Gasparini
32 public abstract class AbstractAdvertizedRoute<C extends Routes & DataObject & ChoiceIn<Tables>,
33 S extends ChildOf<? super C>,
34 R extends Route & ChildOf<? super S> & Identifiable<I>,
35 I extends Identifier<R>> implements RouteKeyIdentifier<R,I> {
36 private final PeerId fromPeerId;
37 private final R route;
38 private final Attributes attributes;
39 private final I nonAddPathRouteKeyIdentifier;
40 private final I addPathRouteKeyIdentifier;
41 private final boolean depreferenced;
43 AbstractAdvertizedRoute(final RIBSupport<C, S, R, I> ribSupport, final R route, final PeerId fromPeerId,
44 final Attributes attributes, final boolean depreferenced) {
45 this.fromPeerId = fromPeerId;
47 this.attributes = attributes;
48 this.depreferenced = depreferenced;
50 final @NonNull String routeKey = verifyNotNull(route.getRouteKey());
51 this.nonAddPathRouteKeyIdentifier = ribSupport.createRouteListKey(NON_PATH_ID_VALUE, routeKey);
52 this.addPathRouteKeyIdentifier = ribSupport.createRouteListKey(route.getPathId().getValue(), routeKey);
55 public final PeerId getFromPeerId() {
56 return this.fromPeerId;
59 public final R getRoute() {
63 public final Attributes getAttributes() {
67 public final boolean isDepreferenced() {
72 public final I getNonAddPathRouteKeyIdentifier() {
73 return this.nonAddPathRouteKeyIdentifier;
77 public final I getAddPathRouteKeyIdentifier() {
78 return this.addPathRouteKeyIdentifier;