Class SocketOptionUtils


  • public final class SocketOptionUtils
    extends java.lang.Object
    Utilities to convert SocketOptions.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> void addOption​(java.util.Map<io.netty.channel.ChannelOption,​java.lang.Object> channelOpts, java.net.SocketOption<T> option, java.lang.Object value)
      Convert and add the given SocketOption and value to the ChannelOptions Map.
      static <T> T getOption​(java.net.SocketOption<T> option, io.netty.channel.ChannelConfig config, java.lang.Long idleTimeoutMs)
      Get a SocketOption value from ChannelConfig.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • addOption

        public static <T> void addOption​(java.util.Map<io.netty.channel.ChannelOption,​java.lang.Object> channelOpts,
                                         java.net.SocketOption<T> option,
                                         java.lang.Object value)
        Convert and add the given SocketOption and value to the ChannelOptions Map.
        Type Parameters:
        T - the type of the SocketOption value
        Parameters:
        channelOpts - the Map into which add the converted SocketOption
        option - the SocketOption to convert and add
        value - the value to add
        Throws:
        java.lang.IllegalArgumentException - if the specified SocketOption is not supported
      • getOption

        @Nullable
        public static <T> T getOption​(java.net.SocketOption<T> option,
                                      io.netty.channel.ChannelConfig config,
                                      @Nullable
                                      java.lang.Long idleTimeoutMs)
        Get a SocketOption value from ChannelConfig.
        Type Parameters:
        T - the type of the SocketOption value
        Parameters:
        option - the SocketOption to get
        config - the ChannelConfig to get the SocketOption from
        idleTimeoutMs - value for IDLE_TIMEOUT socket option
        Returns:
        a value of the SocketOption of type T or null if the ChannelConfig does not have a value for requested SocketOption
        Throws:
        java.lang.IllegalArgumentException - if the specified SocketOption is not supported