Fix duplicate dependency warnings
[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
25 import java.util.Set;
26 import java.util.concurrent.TimeUnit;
27
28 import org.opendaylight.controller.config.api.JmxAttributeValidationException;
29
30 /**
31 *
32 */
33 public final class HashedWheelTimerModule extends
34         org.opendaylight.controller.config.yang.netty.timer.AbstractHashedWheelTimerModule {
35
36     public HashedWheelTimerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
37             org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
38         super(identifier, dependencyResolver);
39     }
40
41     public HashedWheelTimerModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
42             org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
43             HashedWheelTimerModule oldModule, java.lang.AutoCloseable oldInstance) {
44         super(identifier, dependencyResolver, oldModule, oldInstance);
45     }
46
47     @Override
48     public void validate() {
49         super.validate();
50         if (getTickDuration() != null) {
51             JmxAttributeValidationException.checkCondition(getTickDuration() > 0, "value must be greater than 0",
52                     tickDurationJmxAttribute);
53         }
54         if (getTicksPerWheel() != null) {
55             JmxAttributeValidationException.checkCondition(getTicksPerWheel() > 0, "value must be greater than 0",
56                     ticksPerWheelJmxAttribute);
57         }
58     }
59
60     @Override
61     public java.lang.AutoCloseable createInstance() {
62         TimeUnit unit = TimeUnit.MILLISECONDS;
63         if (getTickDuration() != null && getThreadFactoryDependency() == null && getTicksPerWheel() == null) {
64             return new HashedWheelTimerCloseable(new HashedWheelTimer(getTickDuration(), unit));
65         }
66         if (getTickDuration() != null && getThreadFactoryDependency() == null && getTicksPerWheel() != null) {
67             return new HashedWheelTimerCloseable(new HashedWheelTimer(getTickDuration(), unit, getTicksPerWheel()));
68         }
69         if (getTickDuration() == null && getThreadFactoryDependency() != null && getTicksPerWheel() == null) {
70             return new HashedWheelTimerCloseable(new HashedWheelTimer(getThreadFactoryDependency()));
71         }
72         if (getTickDuration() != null && getThreadFactoryDependency() != null && getTicksPerWheel() == null) {
73             return new HashedWheelTimerCloseable(new HashedWheelTimer(getThreadFactoryDependency(), getTickDuration(),
74                     unit));
75         }
76         if (getTickDuration() != null && getThreadFactoryDependency() != null && getTicksPerWheel() != null) {
77             return new HashedWheelTimerCloseable(new HashedWheelTimer(getThreadFactoryDependency(), getTickDuration(),
78                     unit, getTicksPerWheel()));
79         }
80         return new HashedWheelTimerCloseable(new HashedWheelTimer());
81     }
82
83     static final private class HashedWheelTimerCloseable implements AutoCloseable, Timer {
84
85         private final Timer timer;
86
87         public HashedWheelTimerCloseable(Timer timer) {
88             this.timer = timer;
89         }
90
91         @Override
92         public void close() throws Exception {
93             stop();
94         }
95
96         @Override
97         public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) {
98             return this.timer.newTimeout(task, delay, unit);
99         }
100
101         @Override
102         public Set<Timeout> stop() {
103             return this.timer.stop();
104         }
105
106     }
107 }