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
8 package org.opendaylight.protocol.bgp.rib.impl;
10 import com.google.common.collect.ImmutableList;
11 import java.util.ArrayList;
12 import java.util.List;
13 import org.checkerframework.checker.lock.qual.GuardedBy;
14 import org.opendaylight.protocol.bgp.rib.spi.policy.RTCCache;
15 import org.opendaylight.protocol.bgp.route.targetcontrain.spi.ClientRouteTargetContrainCache;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.route.target.constrain.rev180618.route.target.constrain.routes.route.target.constrain.routes.RouteTargetConstrainRoute;
19 public final class RTCClientRouteCache implements ClientRouteTargetContrainCache, RTCCache {
21 private final List<RouteTargetConstrainRoute> rtCache = new ArrayList<>();
24 public synchronized void cacheRoute(final Route route) {
25 if (!(route instanceof RouteTargetConstrainRoute)) {
28 this.rtCache.add((RouteTargetConstrainRoute) route);
32 public synchronized void uncacheRoute(final Route route) {
33 if (!(route instanceof RouteTargetConstrainRoute)) {
36 this.rtCache.remove(route);
40 public synchronized List<Route> getClientRouteTargetContrainCache() {
41 return ImmutableList.copyOf(this.rtCache);