Added test for pcep-impl-config modules, added and fixed modules's validations.
[bgpcep.git] / pcep / impl-config / src / main / java / org / opendaylight / controller / config / yang / pcep / impl / PCEPSessionProposalFactoryImplModule.java
1 /**
2  * Generated file
3
4  * Generated from: yang module name: pcep-impl  yang module local name: pcep-session-proposal-factory-impl
5  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
6  * Generated at: Wed Nov 06 13:16:39 CET 2013
7  *
8  * Do not modify this file unless it is present under src/main directory
9  */
10 package org.opendaylight.controller.config.yang.pcep.impl;
11
12 import java.net.InetSocketAddress;
13
14 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
15 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
16 import org.opendaylight.protocol.pcep.impl.PCEPSessionProposalFactoryImpl;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
20
21 /**
22 *
23 */
24 public final class PCEPSessionProposalFactoryImplModule
25                 extends
26                 org.opendaylight.controller.config.yang.pcep.impl.AbstractPCEPSessionProposalFactoryImplModule {
27         
28         private static final Logger logger = LoggerFactory.getLogger(PCEPSessionProposalFactoryImplModule.class);
29
30         public PCEPSessionProposalFactoryImplModule(
31                         org.opendaylight.controller.config.api.ModuleIdentifier name,
32                         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
33                 super(name, dependencyResolver);
34         }
35
36         public PCEPSessionProposalFactoryImplModule(
37                         org.opendaylight.controller.config.api.ModuleIdentifier name,
38                         org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
39                         PCEPSessionProposalFactoryImplModule oldModule,
40                         java.lang.AutoCloseable oldInstance) {
41                 super(name, dependencyResolver, oldModule, oldInstance);
42         }
43
44         @Override
45         public void validate() {
46                 super.validate();
47                 JmxAttributeValidationException.checkNotNull(getActive(),
48                                 "value is not set.", activeJmxAttribute);
49                 JmxAttributeValidationException.checkNotNull(getVersioned(),
50                                 "value is not set.", versionedJmxAttribute);
51                 JmxAttributeValidationException.checkNotNull(getTimeout(),
52                                 "value is not set.", timeoutJmxAttribute);
53                 JmxAttributeValidationException.checkNotNull(getInstantiated(),
54                                 "value is not set.", instantiatedJmxAttribute);
55                 JmxAttributeValidationException.checkNotNull(getDeadTimerValue(),
56                                 "value is not set.", deadTimerValueJmxAttribute);
57                 JmxAttributeValidationException.checkNotNull(getKeepAliveTimerValue(),
58                                 "value is not set.", keepAliveTimerValueJmxAttribute);
59                 if (getKeepAliveTimerValue() != 0) {
60                         JmxAttributeValidationException.checkCondition(
61                                         getKeepAliveTimerValue() >= 1, "minimum value is 1.",
62                                         keepAliveTimerValueJmxAttribute);
63                         if (getDeadTimerValue() != 0 && (getDeadTimerValue() / getKeepAliveTimerValue() == 4)) {
64                                 logger.warn("DeadTimerValue should be 4 times greater than KeepAliveTimerValue");
65                         }
66                 }
67                 if ((getActive() || getVersioned() || getTimeout() > 0)
68                                 && !getStateful())
69                         setStateful(true);
70                 JmxAttributeValidationException.checkNotNull(getStateful(),
71                                 "value is not set.", statefulJmxAttribute);
72         }
73
74         @Override
75         public java.lang.AutoCloseable createInstance() {
76                 PCEPSessionProposalFactoryImpl inner = new PCEPSessionProposalFactoryImpl(
77                                 getDeadTimerValue(), getKeepAliveTimerValue(), getStateful(),
78                                 getActive(), getVersioned(), getInstantiated(), getTimeout());
79                 return new PCEPSessionProposalFactoryCloseable(inner);
80         }
81
82         private static final class PCEPSessionProposalFactoryCloseable implements
83                         PCEPSessionProposalFactory, AutoCloseable {
84
85                 private PCEPSessionProposalFactoryImpl inner;
86
87                 public PCEPSessionProposalFactoryCloseable(
88                                 PCEPSessionProposalFactoryImpl inner) {
89                         this.inner = inner;
90                 }
91
92                 @Override
93                 public void close() throws Exception {
94                 }
95
96                 @Override
97                 public Open getSessionProposal(InetSocketAddress inetSocketAddress,
98                                 int i) {
99                         return inner.getSessionProposal(inetSocketAddress, i);
100                 }
101         }
102 }