BUG-2383 : split ipv4/6 to separate model
[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.ipv4.routes.Ipv4Routes;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.ipv4.routes.ipv4.routes.Ipv4Route;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev150305.update.path.attributes.mp.reach.nlri.advertized.routes.destination.type.DestinationIpv4Case;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.rib.rev130925.rib.tables.Routes;
14 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
15 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
16 import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
17 import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNodes;
18
19 /**
20  * Class supporting IPv4 unicast RIBs.
21  */
22 final class IPv4RIBSupport extends AbstractIPRIBSupport {
23     private static final IPv4RIBSupport SINGLETON = new IPv4RIBSupport();
24     private final ChoiceNode emptyRoutes = Builders.choiceBuilder()
25             .withNodeIdentifier(new NodeIdentifier(Routes.QNAME))
26             .addChild(Builders.containerBuilder()
27                 .withNodeIdentifier(new NodeIdentifier(Ipv4Routes.QNAME))
28                 .withChild(ImmutableNodes.mapNodeBuilder(Ipv4Route.QNAME).build()).build()).build();
29     private final NodeIdentifier destination = new NodeIdentifier(DestinationIpv4Case.QNAME);
30     private final NodeIdentifier route = new NodeIdentifier(Ipv4Route.QNAME);
31
32     private IPv4RIBSupport() {
33         super(Ipv4Routes.QNAME);
34     }
35
36     static IPv4RIBSupport getInstance() {
37         return SINGLETON;
38     }
39
40     @Override
41     public ChoiceNode emptyRoutes() {
42         return this.emptyRoutes;
43     }
44
45     @Override
46     protected NodeIdentifier destinationContainerIdentifier() {
47         return this.destination;
48     }
49
50     @Override
51     protected NodeIdentifier routeIdentifier() {
52         return this.route;
53     }
54 }