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

package io.netty.handler.codec.http3;

import java.net.SocketAddress;
import io.netty.channel.ChannelPromise;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelOutboundHandler;

class Http3FrameTypeDuplexValidationHandler<T extends Http3Frame> extends Http3FrameTypeInboundValidationHandler<T> implements ChannelOutboundHandler
{
    Http3FrameTypeDuplexValidationHandler(final Class<T> frameType) {
        super(frameType);
    }
    
    @Override
    public final void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) {
        final T frame = Http3FrameValidationUtils.validateFrameWritten(this.frameType, msg);
        if (frame != null) {
            this.write(ctx, frame, promise);
        }
        else {
            this.writeFrameDiscarded(msg, promise);
        }
    }
    
    void write(final ChannelHandlerContext ctx, final T msg, final ChannelPromise promise) {
        ctx.write(msg, promise);
    }
    
    void writeFrameDiscarded(final Object discardedFrame, final ChannelPromise promise) {
        Http3FrameValidationUtils.frameTypeUnexpected(promise, discardedFrame);
    }
    
    @Override
    public void flush(final ChannelHandlerContext ctx) {
        ctx.flush();
    }
    
    @Override
    public void bind(final ChannelHandlerContext ctx, final SocketAddress localAddress, final ChannelPromise promise) {
        ctx.bind(localAddress, promise);
    }
    
    @Override
    public void connect(final ChannelHandlerContext ctx, final SocketAddress remoteAddress, final SocketAddress localAddress, final ChannelPromise promise) throws Exception {
        ctx.connect(remoteAddress, localAddress, promise);
    }
    
    @Override
    public void disconnect(final ChannelHandlerContext ctx, final ChannelPromise promise) {
        ctx.disconnect(promise);
    }
    
    @Override
    public void close(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception {
        ctx.close(promise);
    }
    
    @Override
    public void deregister(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception {
        ctx.deregister(promise);
    }
    
    @Override
    public void read(final ChannelHandlerContext ctx) throws Exception {
        ctx.read();
    }
}
