netty5/transport/src/main/java/io/netty/channel/VoidChannelFuture.java

179 lines
4.0 KiB
Java
Raw Normal View History

2012-06-04 13:31:44 -07:00
/*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.channel;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
class VoidChannelFuture implements ChannelFuture.Unsafe {
private final Channel channel;
/**
* Creates a new instance.
*
* @param channel the {@link Channel} associated with this future
*/
public VoidChannelFuture(Channel channel) {
if (channel == null) {
throw new NullPointerException("channel");
}
this.channel = channel;
}
@Override
public ChannelFuture addListener(final ChannelFutureListener listener) {
fail();
return this;
}
@Override
public ChannelFuture addListeners(final ChannelFutureListener... listeners) {
fail();
return this;
}
@Override
public ChannelFuture removeListener(ChannelFutureListener listener) {
// NOOP
return this;
}
@Override
public ChannelFuture removeListeners(ChannelFutureListener... listeners) {
// NOOP
return this;
}
@Override
public ChannelFuture await() throws InterruptedException {
if (Thread.interrupted()) {
throw new InterruptedException();
}
return this;
}
@Override
public boolean await(long timeout, TimeUnit unit) throws InterruptedException {
fail();
return false;
}
@Override
public boolean await(long timeoutMillis) throws InterruptedException {
fail();
return false;
}
@Override
public ChannelFuture awaitUninterruptibly() {
fail();
return this;
}
@Override
public boolean awaitUninterruptibly(long timeout, TimeUnit unit) {
fail();
return false;
}
@Override
public boolean awaitUninterruptibly(long timeoutMillis) {
fail();
return false;
}
@Override
public Channel channel() {
return channel;
}
@Override
public boolean isDone() {
return false;
}
@Override
public boolean isCancelled() {
return false;
}
@Override
public boolean isSuccess() {
return false;
}
@Override
public Throwable cause() {
return null;
}
@Override
public ChannelFuture sync() throws InterruptedException {
fail();
return this;
}
@Override
public ChannelFuture syncUninterruptibly() {
fail();
return this;
}
@Override
public Void get() throws InterruptedException, ExecutionException {
fail();
return null;
}
@Override
public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException,
TimeoutException {
fail();
return null;
}
@Override
public boolean setProgress(long amount, long current, long total) {
return false;
}
@Override
public boolean setFailure(Throwable cause) {
return false;
}
@Override
public boolean setSuccess() {
return false;
}
@Override
public boolean cancel() {
return false;
}
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return false;
}
private static void fail() {
throw new IllegalStateException("void future");
}
}