151 lines
3.3 KiB
Java
151 lines
3.3 KiB
Java
/*
|
|
* 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.TimeUnit;
|
|
|
|
final class VoidChannelPromise implements ChannelFuture.Unsafe, ChannelPromise {
|
|
|
|
private final Channel channel;
|
|
|
|
/**
|
|
* Creates a new instance.
|
|
*
|
|
* @param channel the {@link Channel} associated with this future
|
|
*/
|
|
public VoidChannelPromise(Channel channel) {
|
|
if (channel == null) {
|
|
throw new NullPointerException("channel");
|
|
}
|
|
this.channel = channel;
|
|
}
|
|
|
|
@Override
|
|
public ChannelPromise addListener(final ChannelFutureListener listener) {
|
|
fail();
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public ChannelPromise addListeners(final ChannelFutureListener... listeners) {
|
|
fail();
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public ChannelPromise removeListener(ChannelFutureListener listener) {
|
|
// NOOP
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public ChannelPromise removeListeners(ChannelFutureListener... listeners) {
|
|
// NOOP
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public ChannelPromise await() throws InterruptedException {
|
|
if (Thread.interrupted()) {
|
|
throw new InterruptedException();
|
|
}
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public boolean await(long timeout, TimeUnit unit) {
|
|
fail();
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean await(long timeoutMillis) {
|
|
fail();
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public ChannelPromise 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 isSuccess() {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public Throwable cause() {
|
|
return null;
|
|
}
|
|
|
|
@Override
|
|
public ChannelPromise sync() {
|
|
fail();
|
|
return this;
|
|
}
|
|
|
|
@Override
|
|
public ChannelPromise syncUninterruptibly() {
|
|
fail();
|
|
return this;
|
|
}
|
|
@Override
|
|
public void setFailure(Throwable cause) {
|
|
}
|
|
|
|
@Override
|
|
public void setSuccess() {
|
|
}
|
|
|
|
@Override
|
|
public boolean tryFailure(Throwable cause) {
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public boolean trySuccess() {
|
|
return false;
|
|
}
|
|
|
|
private static void fail() {
|
|
throw new IllegalStateException("void future");
|
|
}
|
|
}
|