Class BuilderUtils
java.lang.Object
io.servicetalk.transport.netty.internal.BuilderUtils
Utilities which are used for builders.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcloseAndRethrowUnchecked(Closeable closable) CallCloseable.close()and re-throw an unchecked exception if a checked exception is thrown.static Class<? extends io.netty.channel.socket.DatagramChannel>datagramChannel(io.netty.channel.EventLoopGroup group) Returns the correctClassto use with the givenEventLoopGroup.static StringformatCanonicalAddress(SocketAddress address) Format an address into a canonical numeric format.static SocketAddressfromNettyAddress(SocketAddress address) Ifaddressof a Netty specific type it is converted into a corresponding ServiceTalk address type.static Class<? extends io.netty.channel.ServerChannel>serverChannel(io.netty.channel.EventLoopGroup group, Class<? extends SocketAddress> addressClass) Returns the correctClassto use with the givenEventLoopGroup.static io.netty.channel.ChannelsocketChannel(io.netty.channel.EventLoopGroup group, FileDescriptorSocketAddress address) Returns the correct Channel that wraps the given filedescriptor ornullif not supported.static Class<? extends io.netty.channel.Channel>socketChannel(io.netty.channel.EventLoopGroup group, Class<? extends SocketAddress> addressClass) Returns the correctClassto use with the givenEventLoopGroup.static SocketAddresstoNettyAddress(Object address) Ifaddressof a ServiceTalk specific type it is converted into a corresponding Netty address type.static InetSocketAddresstoResolvedInetSocketAddress(HostAndPort resolvedAddress) ConvertsHostAndPortthat contains a resolved address intoInetSocketAddress.
-
Method Details
-
serverChannel
public static Class<? extends io.netty.channel.ServerChannel> serverChannel(io.netty.channel.EventLoopGroup group, Class<? extends SocketAddress> addressClass) Returns the correctClassto use with the givenEventLoopGroup.- Parameters:
group- theEventLoopGroupfor which the class is neededaddressClass- 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 Class<? extends io.netty.channel.Channel> socketChannel(io.netty.channel.EventLoopGroup group, Class<? extends SocketAddress> addressClass) Returns the correctClassto use with the givenEventLoopGroup.- Parameters:
group- theEventLoopGroupfor which the class is neededaddressClass- 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 ornullif not supported.- Parameters:
group- theEventLoopGroupfor which the class is neededaddress- the filedescriptor to wrap.- Returns:
- the class that should be used for bootstrapping
-
toNettyAddress
Ifaddressof a ServiceTalk specific type it is converted into a corresponding Netty address type.- Parameters:
address- the address to convert.- Returns:
- an address that Netty understands.
-
fromNettyAddress
Ifaddressof a Netty specific type it is converted into a corresponding ServiceTalk address type.- Parameters:
address- the address to convert.- Returns:
- an address that ServiceTalk public API expects.
-
toResolvedInetSocketAddress
ConvertsHostAndPortthat contains a resolved address intoInetSocketAddress.- Parameters:
resolvedAddress- the resolved address to convert.- Returns:
InetSocketAddressfrom the passed resolvedHostAndPort.
-
datagramChannel
public static Class<? extends io.netty.channel.socket.DatagramChannel> datagramChannel(io.netty.channel.EventLoopGroup group) Returns the correctClassto use with the givenEventLoopGroup.- Parameters:
group- theEventLoopGroupfor which the class is needed- Returns:
- the class that should be used for bootstrapping
-
formatCanonicalAddress
Format an address into a canonical numeric format.- Parameters:
address- socket address- Returns:
- formatted address
-
closeAndRethrowUnchecked
CallCloseable.close()and re-throw an unchecked exception if a checked exception is thrown.- Parameters:
closable- The object to close.
-