// 
// Decompiled by Procyon v0.6.0
// 

package io.netty.channel;

import io.netty.buffer.ByteBufAllocator;
import java.net.SocketAddress;
import io.netty.util.AttributeMap;

public interface Channel extends AttributeMap, ChannelOutboundInvoker, Comparable<Channel>
{
    ChannelId id();
    
    EventLoop eventLoop();
    
    Channel parent();
    
    ChannelConfig config();
    
    boolean isOpen();
    
    boolean isRegistered();
    
    boolean isActive();
    
    ChannelMetadata metadata();
    
    SocketAddress localAddress();
    
    SocketAddress remoteAddress();
    
    ChannelFuture closeFuture();
    
    default boolean isWritable() {
        final ChannelOutboundBuffer buf = this.unsafe().outboundBuffer();
        return buf != null && buf.isWritable();
    }
    
    default long bytesBeforeUnwritable() {
        final ChannelOutboundBuffer buf = this.unsafe().outboundBuffer();
        return (buf != null) ? buf.bytesBeforeUnwritable() : 0L;
    }
    
    default long bytesBeforeWritable() {
        final ChannelOutboundBuffer buf = this.unsafe().outboundBuffer();
        return (buf != null) ? buf.bytesBeforeWritable() : Long.MAX_VALUE;
    }
    
    Unsafe unsafe();
    
    ChannelPipeline pipeline();
    
    default ByteBufAllocator alloc() {
        return this.config().getAllocator();
    }
    
    default <T> T getOption(final ChannelOption<T> option) {
        return this.config().getOption(option);
    }
    
    default <T> boolean setOption(final ChannelOption<T> option, final T value) {
        return this.config().setOption(option, value);
    }
    
    default Channel read() {
        this.pipeline().read();
        return this;
    }
    
    default Channel flush() {
        this.pipeline().flush();
        return this;
    }
    
    default ChannelFuture writeAndFlush(final Object msg) {
        return this.pipeline().writeAndFlush(msg);
    }
    
    default ChannelFuture writeAndFlush(final Object msg, final ChannelPromise promise) {
        return this.pipeline().writeAndFlush(msg, promise);
    }
    
    default ChannelFuture write(final Object msg, final ChannelPromise promise) {
        return this.pipeline().write(msg, promise);
    }
    
    default ChannelFuture write(final Object msg) {
        return this.pipeline().write(msg);
    }
    
    default ChannelFuture deregister(final ChannelPromise promise) {
        return this.pipeline().deregister(promise);
    }
    
    default ChannelFuture close(final ChannelPromise promise) {
        return this.pipeline().close(promise);
    }
    
    default ChannelFuture disconnect(final ChannelPromise promise) {
        return this.pipeline().disconnect(promise);
    }
    
    default ChannelFuture connect(final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) {
        return this.pipeline().connect(remoteAddress, localAddress, promise);
    }
    
    default ChannelFuture connect(final SocketAddress remoteAddress, final ChannelPromise promise) {
        return this.pipeline().connect(remoteAddress, promise);
    }
    
    default ChannelFuture bind(final SocketAddress localAddress, final ChannelPromise promise) {
        return this.pipeline().bind(localAddress, promise);
    }
    
    default ChannelFuture deregister() {
        return this.pipeline().deregister();
    }
    
    default ChannelFuture close() {
        return this.pipeline().close();
    }
    
    default ChannelFuture disconnect() {
        return this.pipeline().disconnect();
    }
    
    default ChannelFuture connect(final SocketAddress remoteAddress, final SocketAddress localAddress) {
        return this.pipeline().connect(remoteAddress, localAddress);
    }
    
    default ChannelFuture connect(final SocketAddress remoteAddress) {
        return this.pipeline().connect(remoteAddress);
    }
    
    default ChannelFuture bind(final SocketAddress localAddress) {
        return this.pipeline().bind(localAddress);
    }
    
    default ChannelPromise newPromise() {
        return this.pipeline().newPromise();
    }
    
    default ChannelProgressivePromise newProgressivePromise() {
        return this.pipeline().newProgressivePromise();
    }
    
    default ChannelFuture newSucceededFuture() {
        return this.pipeline().newSucceededFuture();
    }
    
    default ChannelFuture newFailedFuture(final Throwable cause) {
        return this.pipeline().newFailedFuture(cause);
    }
    
    default ChannelPromise voidPromise() {
        return this.pipeline().voidPromise();
    }
    
    public interface Unsafe
    {
        RecvByteBufAllocator.Handle recvBufAllocHandle();
        
        SocketAddress localAddress();
        
        SocketAddress remoteAddress();
        
        void register(final EventLoop p0, final ChannelPromise p1);
        
        void bind(final SocketAddress p0, final ChannelPromise p1);
        
        void connect(final SocketAddress p0, final SocketAddress p1, final ChannelPromise p2);
        
        void disconnect(final ChannelPromise p0);
        
        void close(final ChannelPromise p0);
        
        void closeForcibly();
        
        void deregister(final ChannelPromise p0);
        
        void beginRead();
        
        void write(final Object p0, final ChannelPromise p1);
        
        void flush();
        
        ChannelPromise voidPromise();
        
        ChannelOutboundBuffer outboundBuffer();
    }
}
