Merge "Bug 2938: register serializers for all augmentations"
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / protocol / bgp / rib / impl / IPv4RIBSupport.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.Ipv4RoutesCase;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.prefixes.DestinationIpv4;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.prefixes.destination.ipv4.Ipv4Prefixes;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.Ipv4Routes;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
16 import org.opendaylight.yangtools.yang.common.QName;
17 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
18 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
19 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
20 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
21
22 /**
23  * Class supporting IPv4 unicast RIBs.
24  */
25 final class IPv4RIBSupport extends AbstractIPRIBSupport {
26     private final static QName PREFIX_QNAME = QName.cachedReference(QName.create(Ipv4Route.QNAME, "prefix"));
27     private static final IPv4RIBSupport SINGLETON = new IPv4RIBSupport();
28     private final ChoiceNode emptyRoutes = Builders.choiceBuilder()
29             .withNodeIdentifier(new NodeIdentifier(Routes.QNAME))
30             .addChild(Builders.containerBuilder()
31                 .withNodeIdentifier(new NodeIdentifier(Ipv4Routes.QNAME))
32                 .withChild(ImmutableNodes.mapNodeBuilder(Ipv4Route.QNAME).build()).build()).build();
33     private final NodeIdentifier destination = new NodeIdentifier(DestinationIpv4.QNAME);
34     private final NodeIdentifier route = new NodeIdentifier(Ipv4Route.QNAME);
35     private final NodeIdentifier nlriRoutesList = new NodeIdentifier(Ipv4Prefixes.QNAME);
36     private final NodeIdentifier routeKeyKeaf = new NodeIdentifier(PREFIX_QNAME);
37
38     private IPv4RIBSupport() {
39         super(Ipv4RoutesCase.class, Ipv4Routes.class, Ipv4Route.class);
40     }
41
42     static IPv4RIBSupport getInstance() {
43         return SINGLETON;
44     }
45
46     @Override
47     public ChoiceNode emptyRoutes() {
48         return this.emptyRoutes;
49     }
50
51     @Override
52     protected NodeIdentifier destinationContainerIdentifier() {
53         return this.destination;
54     }
55
56     @Override
57     protected NodeIdentifier routeIdentifier() {
58         return this.route;
59     }
60
61     @Override
62     protected NodeIdentifier routeKeyLeafIdentifier() {
63         return routeKeyKeaf;
64     }
65
66     @Override
67     protected NodeIdentifier nlriRoutesListIdentifier() {
68         return this.nlriRoutesList;
69     }
70
71     @Override
72     protected QName keyLeafQName() {
73         return PREFIX_QNAME;
74     }
75
76     @Override
77     protected QName routeQName() {
78         return Ipv4Route.QNAME;
79     }
80 }