X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fconfig%2Fnetty-timer-config%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fconfig%2Fyang%2Fnetty%2Ftimer%2FHashedWheelTimerCloseable.java;h=b519af1b99581306e7d5418bd2de820db5659ef1;hb=refs%2Fchanges%2F11%2F80211%2F6;hp=4b23af11a7d2fbe263b3d455b0571cebcd8f1667;hpb=9832745f5d61833705269a0004a83b39e81bddce;p=controller.git diff --git a/opendaylight/config/netty-timer-config/src/main/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerCloseable.java b/opendaylight/config/netty-timer-config/src/main/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerCloseable.java index 4b23af11a7..b519af1b99 100644 --- a/opendaylight/config/netty-timer-config/src/main/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerCloseable.java +++ b/opendaylight/config/netty-timer-config/src/main/java/org/opendaylight/controller/config/yang/netty/timer/HashedWheelTimerCloseable.java @@ -14,23 +14,23 @@ import io.netty.util.TimerTask; import java.util.Set; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; -import javax.annotation.Nullable; +import org.eclipse.jdt.annotation.Nullable; public final class HashedWheelTimerCloseable implements AutoCloseable, Timer { private final Timer timer; - private HashedWheelTimerCloseable(Timer timer) { + private HashedWheelTimerCloseable(final Timer timer) { this.timer = timer; } @Override - public void close() throws Exception { + public void close() { stop(); } @Override - public Timeout newTimeout(TimerTask task, long delay, TimeUnit unit) { + public Timeout newTimeout(final TimerTask task, final long delay, final TimeUnit unit) { return this.timer.newTimeout(task, delay, unit); } @@ -39,27 +39,32 @@ public final class HashedWheelTimerCloseable implements AutoCloseable, Timer { return this.timer.stop(); } - public static HashedWheelTimerCloseable newInstance(@Nullable ThreadFactory threadFactory, - @Nullable Long duration, @Nullable Integer ticksPerWheel) { + public static HashedWheelTimerCloseable newInstance(final @Nullable Long duration, + final @Nullable Integer ticksPerWheel) { + return newInstance(null, duration, ticksPerWheel); + } + + public static HashedWheelTimerCloseable newInstance(final @Nullable ThreadFactory threadFactory, + final @Nullable Long duration, final @Nullable Integer ticksPerWheel) { TimeUnit unit = TimeUnit.MILLISECONDS; - if(!nullOrNonZero(duration) && threadFactory == null && nullOrNonZero(ticksPerWheel)) { + if(!nullOrNonPositive(duration) && threadFactory == null && nullOrNonPositive(ticksPerWheel)) { return new HashedWheelTimerCloseable(new HashedWheelTimer(duration, unit)); } - if(!nullOrNonZero(duration) && threadFactory == null && !nullOrNonZero(ticksPerWheel)) { + if(!nullOrNonPositive(duration) && threadFactory == null && !nullOrNonPositive(ticksPerWheel)) { return new HashedWheelTimerCloseable(new HashedWheelTimer(duration, unit, ticksPerWheel)); } - if(nullOrNonZero(duration) && threadFactory != null && nullOrNonZero(ticksPerWheel)) { + if(nullOrNonPositive(duration) && threadFactory != null && nullOrNonPositive(ticksPerWheel)) { return new HashedWheelTimerCloseable(new HashedWheelTimer(threadFactory)); } - if(!nullOrNonZero(duration) && threadFactory != null && nullOrNonZero(ticksPerWheel)) { + if(!nullOrNonPositive(duration) && threadFactory != null && nullOrNonPositive(ticksPerWheel)) { return new HashedWheelTimerCloseable( new HashedWheelTimer(threadFactory, duration, unit)); } - if(!nullOrNonZero(duration) && threadFactory != null && !nullOrNonZero(ticksPerWheel)) { + if(!nullOrNonPositive(duration) && threadFactory != null && !nullOrNonPositive(ticksPerWheel)) { return new HashedWheelTimerCloseable( new HashedWheelTimer(threadFactory, duration, unit, ticksPerWheel)); } @@ -67,7 +72,7 @@ public final class HashedWheelTimerCloseable implements AutoCloseable, Timer { return new HashedWheelTimerCloseable(new HashedWheelTimer()); } - private static boolean nullOrNonZero(Number n) { + private static boolean nullOrNonPositive(final Number n) { return n == null || n.longValue() <= 0; } -} \ No newline at end of file +}