Fix checkstyle
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / RTCClientRouteCache.java
1 /*
2  * Copyright (c) 2018 AT&T Intellectual Property. 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 package org.opendaylight.protocol.bgp.rib.impl;
9
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;
18
19 public final class RTCClientRouteCache implements ClientRouteTargetContrainCache, RTCCache {
20     @GuardedBy("this")
21     private final List<RouteTargetConstrainRoute> rtCache = new ArrayList<>();
22
23     @Override
24     public synchronized void cacheRoute(final Route route) {
25         if (!(route instanceof RouteTargetConstrainRoute)) {
26             return;
27         }
28         this.rtCache.add((RouteTargetConstrainRoute) route);
29     }
30
31     @Override
32     public synchronized void uncacheRoute(final Route route) {
33         if (!(route instanceof RouteTargetConstrainRoute)) {
34             return;
35         }
36         this.rtCache.remove(route);
37     }
38
39     @Override
40     public synchronized List<Route> getClientRouteTargetContrainCache() {
41         return ImmutableList.copyOf(this.rtCache);
42     }
43 }