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