Cleanup deprecation warnings in bgp/extensions/l3vpn
[bgpcep.git] / bgp / extensions / l3vpn / src / main / java / org / opendaylight / protocol / bgp / l3vpn / unicast / ipv6 / VpnIpv6RIBSupport.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.l3vpn.unicast.ipv6;
9
10 import static com.google.common.base.Verify.verify;
11
12 import java.util.List;
13 import java.util.Map;
14 import org.opendaylight.mdsal.binding.dom.codec.api.BindingNormalizedNodeSerializer;
15 import org.opendaylight.protocol.bgp.l3vpn.unicast.AbstractVpnRIBSupport;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
17 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Prefix;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.destination.DestinationType;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev180329.rib.tables.Routes;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev200120.Ipv6AddressFamily;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.bgp.rib.rib.loc.rib.tables.routes.VpnIpv6RoutesCase;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.destination.VpnIpv6Destination;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.destination.VpnIpv6DestinationBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.routes.VpnIpv6Routes;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.l3vpn.ipv6.routes.VpnIpv6RoutesBuilder;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.destination.type.VpnDestination;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.route.VpnRoute;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.rev180329.l3vpn.ip.route.VpnRouteKey;
29
30 public final class VpnIpv6RIBSupport extends AbstractVpnRIBSupport<VpnIpv6RoutesCase, VpnIpv6Routes> {
31     private static final VpnIpv6Routes EMPTY_CONTAINER = new VpnIpv6RoutesBuilder().build();
32     private static VpnIpv6RIBSupport SINGLETON;
33
34     /**
35      * Default constructor. Requires the QName of the container augmented under the routes choice
36      * node in instantiations of the rib grouping. It is assumed that this container is defined by
37      * the same model which populates it with route grouping instantiation, and by extension with
38      * the route attributes container.
39      */
40     private VpnIpv6RIBSupport(final BindingNormalizedNodeSerializer mappingService) {
41         super(mappingService,
42                 VpnIpv6RoutesCase.class,
43                 VpnIpv6Routes.class,
44                 Ipv6AddressFamily.class,
45                 VpnIpv6Destination.QNAME);
46     }
47
48     public static synchronized VpnIpv6RIBSupport getInstance(final BindingNormalizedNodeSerializer mappingService) {
49         if (SINGLETON == null) {
50             SINGLETON = new VpnIpv6RIBSupport(mappingService);
51         }
52         return SINGLETON;
53     }
54
55     @Override
56     protected IpPrefix createPrefix(final String prefix) {
57         return new IpPrefix(new Ipv6Prefix(prefix));
58     }
59
60     @Override
61     protected DestinationType getAdvertisedDestinationType(final List<VpnDestination> dests) {
62         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
63                 .attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationVpnIpv6CaseBuilder()
64                 .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
65     }
66
67     @Override
68     protected DestinationType getWithdrawnDestinationType(final List<VpnDestination> dests) {
69         return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329.update
70                 .attributes.mp.unreach.nlri.withdrawn.routes.destination.type.DestinationVpnIpv6CaseBuilder()
71                 .setVpnIpv6Destination(new VpnIpv6DestinationBuilder().setVpnDestination(dests).build()).build();
72     }
73
74     @Override
75     public VpnIpv6Routes emptyRoutesContainer() {
76         return EMPTY_CONTAINER;
77     }
78
79     @Override
80     public Map<VpnRouteKey, VpnRoute> extractAdjRibInRoutes(final Routes routes) {
81         verify(routes instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329
82             .bgp.rib.rib.peer.adj.rib.in.tables.routes.VpnIpv6RoutesCase, "Unrecognized routes %s", routes);
83         return ((org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.vpn.ipv6.rev180329
84                 .bgp.rib.rib.peer.adj.rib.in.tables.routes.VpnIpv6RoutesCase) routes).getVpnIpv6Routes()
85                 .nonnullVpnRoute();
86     }
87 }