Top Description Fields Constructors Methods
io.netty5.channel

public abstract Class SimpleUserEventChannelHandler<I>

extends Object
implements ChannelHandler
Class Inheritance
All Implemented Interfaces
io.netty5.channel.ChannelHandler
Imports
io.netty5.util.Resource, io.netty5.util.internal.TypeParameterMatcher

ChannelHandler which allows to conveniently only handle a specific type of user events. For example, here is an implementation which only handle String user events.
    public class StringEventHandler extends
            SimpleUserEventChannelHandler<String> {

        @Override
        protected void eventReceived(ChannelHandlerContext ctx, String evt)
                throws Exception {
            System.out.println(evt);
        }
    }
Be aware that depending of the constructor parameters it will release all handled events by passing them to Resource#dispose(Object).

Field Summary

Modifier and TypeField and Description
private final boolean
private final TypeParameterMatcher

Constructor Summary

AccessConstructor and Description
protected
protected
SimpleUserEventChannelHandler(boolean
true if handled events should be released automatically by passing them to Resource#dispose(Object).
autoRelease
)

Create a new instance which will try to detect the types to match out of the type parameter of the class.

protected
SimpleUserEventChannelHandler(Class<? extends I> eventType)

see SimpleUserEventChannelHandler(Class, boolean) with true as boolean value.

protected
SimpleUserEventChannelHandler(Class<? extends I>
The type of events to match
eventType
,
boolean
true if handled events should be released automatically by passing them to Resource#dispose(Object).
autoRelease
)

Create a new instance

Method Summary

Modifier and TypeMethod and Description
protected boolean
acceptEvent(Object evt)

Returns true if the given user event should be handled.

public final void
channelInboundEvent(ChannelHandlerContext ctx, Object evt)

Overrides default io.netty5.channel.ChannelHandler.channelInboundEvent.

Gets called if a custom inbound event happened.
protected abstract void
eventReceived(ChannelHandlerContext ctx, I
the user event to handle
evt
)

Is called for each user event triggered of type I.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

autoReleaseback to summary
private final boolean autoRelease
matcherback to summary
private final TypeParameterMatcher matcher

Constructor Detail

SimpleUserEventChannelHandlerback to summary
protected SimpleUserEventChannelHandler()

see SimpleUserEventChannelHandler(boolean) with true as boolean parameter.

SimpleUserEventChannelHandlerback to summary
protected SimpleUserEventChannelHandler(boolean autoRelease)

Create a new instance which will try to detect the types to match out of the type parameter of the class.

Parameters
autoRelease:boolean

true if handled events should be released automatically by passing them to Resource#dispose(Object).

SimpleUserEventChannelHandlerback to summary
protected SimpleUserEventChannelHandler(Class<? extends I> eventType)

see SimpleUserEventChannelHandler(Class, boolean) with true as boolean value.

SimpleUserEventChannelHandlerback to summary
protected SimpleUserEventChannelHandler(Class<? extends I> eventType, boolean autoRelease)

Create a new instance

Parameters
eventType:Class<? extends I>

The type of events to match

autoRelease:boolean

true if handled events should be released automatically by passing them to Resource#dispose(Object).

Method Detail

acceptEventback to summary
protected boolean acceptEvent(Object evt) throws Exception

Returns true if the given user event should be handled. If false it will be passed to the next ChannelHandler in the ChannelPipeline.

channelInboundEventback to summary
public final void channelInboundEvent(ChannelHandlerContext ctx, Object evt) throws Exception

Overrides default io.netty5.channel.ChannelHandler.channelInboundEvent.

Doc from io.netty5.channel.ChannelHandler.channelInboundEvent.

Gets called if a custom inbound event happened.

Annotations
@Override
eventReceivedback to summary
protected abstract void eventReceived(ChannelHandlerContext ctx, I evt) throws Exception

Is called for each user event triggered of type I.

Parameters
ctx:ChannelHandlerContext

the ChannelHandlerContext which this SimpleUserEventChannelHandler belongs to

evt:I

the user event to handle

Exceptions
Exception:
is thrown if an error occurred