Remove unneeded slf4j-api dependencies from APIs
[bgpcep.git] / bgp / extensions / flowspec / src / main / java / org / opendaylight / protocol / bgp / flowspec / l3vpn / ipv6 / FlowspecL3vpnIpv6RIBSupport.java
1 /*
2  * Copyright (c) 2016 Brocade Communications 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 package org.opendaylight.protocol.bgp.flowspec.l3vpn.ipv6;
9
10 import static com.google.common.base.Verify.verify;
11
12 import java.util.Collections;
13 import java.util.List;
14 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
15 import org.opendaylight.protocol.bgp.flowspec.SimpleFlowspecExtensionProviderContext;
16 import org.opendaylight.protocol.bgp.flowspec.l3vpn.AbstractFlowspecL3vpnRIBSupport;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCase;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.bgp.rib.rib.loc.rib.tables.routes.FlowspecL3vpnIpv6RoutesCaseBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.destination.ipv6.DestinationFlowspecL3vpnIpv6;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRoute;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteBuilder;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.route.FlowspecL3vpnRouteKey;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6Routes;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329.flowspec.l3vpn.ipv6.routes.FlowspecL3vpnIpv6RoutesBuilder;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.PathId;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.path.attributes.Attributes;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.Ipv6AddressFamily;
29
30 public final class FlowspecL3vpnIpv6RIBSupport
31         extends AbstractFlowspecL3vpnRIBSupport<FlowspecL3vpnIpv6NlriParser,
32         FlowspecL3vpnIpv6RoutesCase,
33         FlowspecL3vpnIpv6Routes,
34         FlowspecL3vpnRoute,
35         FlowspecL3vpnRouteKey> {
36     private static final FlowspecL3vpnIpv6Routes EMPTY_CONTAINER
37             = new FlowspecL3vpnIpv6RoutesBuilder().setFlowspecL3vpnRoute(Collections.emptyList()).build();
38     private static final FlowspecL3vpnIpv6RoutesCase EMPTY_CASE = new FlowspecL3vpnIpv6RoutesCaseBuilder()
39             .setFlowspecL3vpnIpv6Routes(EMPTY_CONTAINER).build();
40     private static FlowspecL3vpnIpv6RIBSupport SINGLETON;
41
42     private FlowspecL3vpnIpv6RIBSupport(
43             final SimpleFlowspecExtensionProviderContext context,
44             final BindingNormalizedNodeSerializer mappingService) {
45         super(
46                 mappingService,
47                 FlowspecL3vpnIpv6RoutesCase.class,
48                 FlowspecL3vpnIpv6Routes.class,
49                 FlowspecL3vpnRoute.class,
50                 DestinationFlowspecL3vpnIpv6.QNAME,
51                 Ipv6AddressFamily.class,
52                 new FlowspecL3vpnIpv6NlriParser(context
53                         .getFlowspecTypeRegistry(SimpleFlowspecExtensionProviderContext.AFI.IPV6,
54                                 SimpleFlowspecExtensionProviderContext.SAFI.FLOWSPEC_VPN))
55         );
56     }
57
58     public static synchronized FlowspecL3vpnIpv6RIBSupport getInstance(
59             final SimpleFlowspecExtensionProviderContext context,
60             final BindingNormalizedNodeSerializer mappingService) {
61         if (SINGLETON == null) {
62             SINGLETON = new FlowspecL3vpnIpv6RIBSupport(context, mappingService);
63         }
64         return SINGLETON;
65     }
66
67     @Override
68     public FlowspecL3vpnRouteKey createRouteListKey(final PathId pathId, final String routeKey) {
69         return new FlowspecL3vpnRouteKey(pathId, routeKey);
70     }
71
72     @Override
73     public FlowspecL3vpnRoute createRoute(final FlowspecL3vpnRoute route, final FlowspecL3vpnRouteKey key,
74             final Attributes attributes) {
75         final FlowspecL3vpnRouteBuilder builder;
76         if (route != null) {
77             builder = new FlowspecL3vpnRouteBuilder(route);
78         } else {
79             builder = new FlowspecL3vpnRouteBuilder();
80         }
81         return builder.withKey(key).setAttributes(attributes).build();
82     }
83
84     @Override
85     public FlowspecL3vpnIpv6Routes emptyRoutesContainer() {
86         return EMPTY_CONTAINER;
87     }
88
89     @Override
90     public PathId extractPathId(final FlowspecL3vpnRouteKey routeListKey) {
91         return routeListKey.getPathId();
92     }
93
94     @Override
95     public String extractRouteKey(final FlowspecL3vpnRouteKey routeListKey) {
96         return routeListKey.getRouteKey();
97     }
98
99     @Override
100     public List<FlowspecL3vpnRoute> extractAdjRibInRoutes(final Routes routes) {
101         verify(routes instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
102             .bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecL3vpnIpv6RoutesCase, "Unrecognized routes %s", routes);
103         return ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.flowspec.rev180329
104                 .bgp.rib.rib.peer.adj.rib.in.tables.routes.FlowspecL3vpnIpv6RoutesCase) routes)
105                 .getFlowspecL3vpnIpv6Routes().nonnullFlowspecL3vpnRoute();
106     }
107 }