BUG-4827: Path Selection mode Config Subsystem integration
[bgpcep.git] / bgp / rib-impl / src / main / java / org / opendaylight / controller / config / yang / bgp / rib / impl / AddPathImplModule.java
1 /*
2  * Copyright (c) 2016 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.controller.config.yang.bgp.rib.impl;
9
10 import com.google.common.base.Preconditions;
11 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.BgpTableType;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.SendReceive;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev130919.open.bgp.parameters.optional.capabilities.c.parameters.add.path.capability.AddressFamilies;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.AddressFamily;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.SubsequentAddressFamily;
17 import org.opendaylight.yangtools.yang.binding.Augmentation;
18 import org.opendaylight.yangtools.yang.binding.DataContainer;
19
20 public final class AddPathImplModule extends AbstractAddPathImplModule {
21     public AddPathImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
22         super(identifier, dependencyResolver);
23     }
24
25     public AddPathImplModule(final org.opendaylight.controller.config.api.ModuleIdentifier identifier, final org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, final org.opendaylight.controller.config.yang.bgp.rib.impl.AddPathImplModule oldModule, final java.lang.AutoCloseable oldInstance) {
26         super(identifier, dependencyResolver, oldModule, oldInstance);
27     }
28
29     @Override
30     public void customValidation() {
31         JmxAttributeValidationException.checkNotNull(getSendReceive(), "value is not set.", sendReceiveJmxAttribute);
32         JmxAttributeValidationException.checkNotNull(getAddressFamily(), "value is not set.", addressFamilyJmxAttribute);
33     }
34
35     @Override
36     public java.lang.AutoCloseable createInstance() {
37         return new AutoCloseableAddPath(getAddressFamilyDependency(), getSendReceive());
38     }
39
40     private static final class AutoCloseableAddPath implements AutoCloseable, AddressFamilies {
41         private final BgpTableType family;
42         private final SendReceive sendReceiveMode;
43
44         public AutoCloseableAddPath(final BgpTableType addressFamilyDependency, final SendReceive sendReceive) {
45             this.family = Preconditions.checkNotNull(addressFamilyDependency);
46             this.sendReceiveMode = Preconditions.checkNotNull(sendReceive);
47         }
48
49         @Override
50         public String toString() {
51             final StringBuilder builder = new StringBuilder();
52             builder.append("AutoCloseableAddPath [family=");
53             builder.append(this.family.toString());
54             builder.append(", sendReceiveMode=");
55             builder.append(this.sendReceiveMode);
56             builder.append("]");
57             return builder.toString();
58         }
59
60         @Override
61         public Class<? extends DataContainer> getImplementedInterface() {
62             return AddressFamilies.class;
63         }
64
65         @Override
66         public void close() throws Exception {
67         }
68
69         @Override
70         public <E extends Augmentation<AddressFamilies>> E getAugmentation(final Class<E> arg0) {
71             return null;
72         }
73
74         @Override
75         public Class<? extends AddressFamily> getAfi() {
76             return this.family.getAfi();
77         }
78
79         @Override
80         public Class<? extends SubsequentAddressFamily> getSafi() {
81             return this.family.getSafi();
82         }
83
84         @Override
85         public SendReceive getSendReceive() {
86             return this.sendReceiveMode;
87         }
88     }
89
90 }