Class BuilderUtils


  • public final class BuilderUtils
    extends java.lang.Object
    Utilities which are used for builders.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void closeAndRethrowUnchecked​(java.io.Closeable closable)
      Call Closeable.close() and re-throw an unchecked exception if a checked exception is thrown.
      static java.lang.Class<? extends io.netty.channel.socket.DatagramChannel> datagramChannel​(io.netty.channel.EventLoopGroup group)
      Returns the correct Class to use with the given EventLoopGroup.
      static java.lang.String formatCanonicalAddress​(java.net.SocketAddress address)
      Format an address into a canonical numeric format.
      static java.lang.Class<? extends io.netty.channel.ServerChannel> serverChannel​(io.netty.channel.EventLoopGroup group, java.lang.Class<? extends java.net.SocketAddress> addressClass)
      Returns the correct Class to use with the given EventLoopGroup.
      static io.netty.channel.Channel socketChannel​(io.netty.channel.EventLoopGroup group, FileDescriptorSocketAddress address)
      Returns the correct Channel that wraps the given filedescriptor or null if not supported.
      static java.lang.Class<? extends io.netty.channel.Channel> socketChannel​(io.netty.channel.EventLoopGroup group, java.lang.Class<? extends java.net.SocketAddress> addressClass)
      Returns the correct Class to use with the given EventLoopGroup.
      static java.net.SocketAddress toNettyAddress​(java.lang.Object address)
      If address if a ServiceTalk specific address it is unwrapped into a Netty address.
      static java.net.InetSocketAddress toResolvedInetSocketAddress​(HostAndPort resolvedAddress)
      Converts HostAndPort that contains a resolved address into InetSocketAddress.
      static boolean useEpoll​(io.netty.channel.EventLoopGroup group)
      Returns true if native epoll transport should be used.
      static boolean useKQueue​(io.netty.channel.EventLoopGroup group)
      Returns true if native kqueue transport should be used.
      • Methods inherited from class java.lang.Object

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

      • useEpoll

        public static boolean useEpoll​(io.netty.channel.EventLoopGroup group)
        Returns true if native epoll transport should be used.
        Parameters:
        group - the used EventLoopGroup
        Returns:
        true if native transport should be used
      • useKQueue

        public static boolean useKQueue​(io.netty.channel.EventLoopGroup group)
        Returns true if native kqueue transport should be used.
        Parameters:
        group - the used EventLoopGroup
        Returns:
        true if native transport should be used
      • serverChannel

        public static java.lang.Class<? extends io.netty.channel.ServerChannel> serverChannel​(io.netty.channel.EventLoopGroup group,
                                                                                              java.lang.Class<? extends java.net.SocketAddress> addressClass)
        Returns the correct Class to use with the given EventLoopGroup.
        Parameters:
        group - the EventLoopGroup for which the class is needed
        addressClass - The class of the address that the server socket will be bound to.
        Returns:
        the class that should be used for bootstrapping
      • socketChannel

        public static java.lang.Class<? extends io.netty.channel.Channel> socketChannel​(io.netty.channel.EventLoopGroup group,
                                                                                        java.lang.Class<? extends java.net.SocketAddress> addressClass)
        Returns the correct Class to use with the given EventLoopGroup.
        Parameters:
        group - the EventLoopGroup for which the class is needed
        addressClass - The class of the address that to connect to.
        Returns:
        the class that should be used for bootstrapping
      • socketChannel

        @Nullable
        public static io.netty.channel.Channel socketChannel​(io.netty.channel.EventLoopGroup group,
                                                             FileDescriptorSocketAddress address)
        Returns the correct Channel that wraps the given filedescriptor or null if not supported.
        Parameters:
        group - the EventLoopGroup for which the class is needed
        address - the filedescriptor to wrap.
        Returns:
        the class that should be used for bootstrapping
      • toNettyAddress

        public static java.net.SocketAddress toNettyAddress​(java.lang.Object address)
        If address if a ServiceTalk specific address it is unwrapped into a Netty address.
        Parameters:
        address - the address to convert.
        Returns:
        an address that Netty understands.
      • toResolvedInetSocketAddress

        public static java.net.InetSocketAddress toResolvedInetSocketAddress​(HostAndPort resolvedAddress)
        Converts HostAndPort that contains a resolved address into InetSocketAddress.
        Parameters:
        resolvedAddress - the resolved address to convert.
        Returns:
        InetSocketAddress from the passed resolved HostAndPort.
      • datagramChannel

        public static java.lang.Class<? extends io.netty.channel.socket.DatagramChannel> datagramChannel​(io.netty.channel.EventLoopGroup group)
        Returns the correct Class to use with the given EventLoopGroup.
        Parameters:
        group - the EventLoopGroup for which the class is needed
        Returns:
        the class that should be used for bootstrapping
      • formatCanonicalAddress

        public static java.lang.String formatCanonicalAddress​(java.net.SocketAddress address)
        Format an address into a canonical numeric format.
        Parameters:
        address - socket address
        Returns:
        formatted address
      • closeAndRethrowUnchecked

        public static void closeAndRethrowUnchecked​(@Nullable
                                                    java.io.Closeable closable)
        Call Closeable.close() and re-throw an unchecked exception if a checked exception is thrown.
        Parameters:
        closable - The object to close.