BUG-2383 : RIBSupport exposes Route classes rather than QNAME
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / IPv6RIBSupport.java
1 /*
2  * Copyright (c) 2015 Cisco 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.rib.impl;
9
10 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.bgp.rib.rib.loc.rib.tables.routes.Ipv6RoutesCase;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.prefixes.DestinationIpv6;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.routes.Ipv6Routes;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv6.routes.ipv6.routes.Ipv6Route;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
15 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
16 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
17 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
18 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
19
20 /**
21  * Class supporting IPv6 unicast RIBs.
22  */
23 final class IPv6RIBSupport extends AbstractIPRIBSupport {
24     private static final IPv6RIBSupport SINGLETON = new IPv6RIBSupport();
25     private final ChoiceNode emptyRoutes = Builders.choiceBuilder()
26             .withNodeIdentifier(new NodeIdentifier(Routes.QNAME))
27             .addChild(Builders.containerBuilder()
28                 .withNodeIdentifier(new NodeIdentifier(Ipv6Routes.QNAME))
29                 .withChild(ImmutableNodes.mapNodeBuilder(Ipv6Route.QNAME).build()).build()).build();
30     private final NodeIdentifier destination = new NodeIdentifier(DestinationIpv6.QNAME);
31     private final NodeIdentifier route = new NodeIdentifier(Ipv6Route.QNAME);
32
33     private IPv6RIBSupport() {
34         super(Ipv6RoutesCase.class, Ipv6Routes.class, Ipv6Route.class);
35     }
36
37     static IPv6RIBSupport getInstance() {
38         return SINGLETON;
39     }
40
41     @Override
42     public ChoiceNode emptyRoutes() {
43         return this.emptyRoutes;
44     }
45
46     @Override
47     protected NodeIdentifier destinationContainerIdentifier() {
48         return this.destination;
49     }
50
51     @Override
52     protected NodeIdentifier routeIdentifier() {
53         return this.route;
54     }
55 }