Fix checkstyle warnings in netty-timer-config
[controller.git] / opendaylight / config / netty-timer-config / src / main / java / org / opendaylight / controller / config / yang / netty / timer / HashedWheelTimerModule.java
1 /*
2  * Copyright (c) 2013 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
9 /**
10  * Generated file
11
12  * Generated from: yang module name: netty-event-executor  yang module local name: netty-hashed-wheel-timer
13  * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
14  * Generated at: Tue Nov 19 12:49:59 CET 2013
15  *
16  * Do not modify this file unless it is present under src/main directory
17  */
18 package org.opendaylight.controller.config.yang.netty.timer;
19
20 import io.netty.util.HashedWheelTimer;
21 import io.netty.util.Timeout;
22 import io.netty.util.Timer;
23 import io.netty.util.TimerTask;
24 import java.util.Set;
25 import java.util.concurrent.TimeUnit;
26 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
27
28 /**
29 *
30 */
31 public final class HashedWheelTimerModule extends
32         org.opendaylight.controller.config.yang.netty.timer.AbstractHashedWheelTimerModule {
33
34     public HashedWheelTimerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
35             org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
36         super(identifier, dependencyResolver);
37     }
38
39     public HashedWheelTimerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
40             org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
41             HashedWheelTimerModule oldModule, java.lang.AutoCloseable oldInstance) {
42         super(identifier, dependencyResolver, oldModule, oldInstance);
43     }
44
45     @Override
46     public void validate() {
47         super.validate();
48         if (getTickDuration() != null) {
49             JmxAttributeValidationException.checkCondition(getTickDuration() > 0, "value must be greater than 0",
50                     tickDurationJmxAttribute);
51         }
52         if (getTicksPerWheel() != null) {
53             JmxAttributeValidationException.checkCondition(getTicksPerWheel() > 0, "value must be greater than 0",
54                     ticksPerWheelJmxAttribute);
55         }
56     }
57
58     @Override
59     public java.lang.AutoCloseable createInstance() {
60         TimeUnit unit = TimeUnit.MILLISECONDS;
61         if (getTickDuration() != null && getThreadFactoryDependency() == null && getTicksPerWheel() == null) {
62             return new HashedWheelTimerCloseable(new HashedWheelTimer(getTickDuration(), unit));
63         }
64         if (getTickDuration() != null && getThreadFactoryDependency() == null && getTicksPerWheel() != null) {
65             return new HashedWheelTimerCloseable(new HashedWheelTimer(getTickDuration(), unit, getTicksPerWheel()));
66         }
67         if (getTickDuration() == null && getThreadFactoryDependency() != null && getTicksPerWheel() == null) {
68             return new HashedWheelTimerCloseable(new HashedWheelTimer(getThreadFactoryDependency()));
69         }
70         if (getTickDuration() != null && getThreadFactoryDependency() != null && getTicksPerWheel() == null) {
71             return new HashedWheelTimerCloseable(new HashedWheelTimer(getThreadFactoryDependency(), getTickDuration(),
72                     unit));
73         }
74         if (getTickDuration() != null && getThreadFactoryDependency() != null && getTicksPerWheel() != null) {
75             return new HashedWheelTimerCloseable(new HashedWheelTimer(getThreadFactoryDependency(), getTickDuration(),
76                     unit, getTicksPerWheel()));
77         }
78         return new HashedWheelTimerCloseable(new HashedWheelTimer());
79     }
80
81     static final private class HashedWheelTimerCloseable implements AutoCloseable, Timer {
82
83         private final Timer timer;
84
85         public HashedWheelTimerCloseable(Timer timer) {
86             this.timer = timer;
87         }
88
89         @Override
90         public void close() throws Exception {
91             stop();
92         }
93
94         @Override
95         public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) {
96             return this.timer.newTimeout(task, delay, unit);
97         }
98
99         @Override
100         public Set<Timeout> stop() {
101             return this.timer.stop();
102         }
103
104     }
105 }