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.impl;
11 import com.google.common.collect.ImmutableList;
12 import java.util.ArrayList;
13 import java.util.List;
14 import javax.annotation.concurrent.GuardedBy;
15 import org.opendaylight.protocol.bgp.rib.spi.policy.RTCCache;
16 import org.opendaylight.protocol.bgp.route.targetcontrain.spi.ClientRouteTargetContrainCache;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.Route;
18 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;
20 public final class RTCClientRouteCache implements ClientRouteTargetContrainCache, RTCCache {
22 private final List<RouteTargetConstrainRoute> rtCache = new ArrayList<>();
25 public synchronized void cacheRoute(final Route route) {
26 if (!(route instanceof RouteTargetConstrainRoute)) {
29 this.rtCache.add((RouteTargetConstrainRoute) route);
33 public synchronized void uncacheRoute(final Route route) {
34 if (!(route instanceof RouteTargetConstrainRoute)) {
37 this.rtCache.remove(route);
41 public synchronized List<Route> getClientRouteTargetContrainCache() {
42 return ImmutableList.copyOf(this.rtCache);