Enum Class NettyTransport

java.lang.Object
java.lang.Enum<NettyTransport>
eu.cloudnetservice.driver.impl.network.netty.NettyTransport
All Implemented Interfaces:
Serializable, Comparable<NettyTransport>, Constable

public enum NettyTransport extends Enum<NettyTransport>
Holds all supported transport types and functionality to retrieve model instances for servers/clients construction.
Since:
4.0
  • Enum Constant Details

  • Field Details

    • name

      private final String name
    • available

      private final boolean available
    • nativeTransport

      private final boolean nativeTransport
    • ioHandlerFactory

      private final Supplier<io.netty5.channel.IoHandlerFactory> ioHandlerFactory
    • clientChannelFactory

      private final io.netty5.channel.ChannelFactory<? extends io.netty5.channel.Channel> clientChannelFactory
    • serverChannelFactory

      private final io.netty5.channel.ServerChannelFactory<? extends io.netty5.channel.ServerChannel> serverChannelFactory
  • Constructor Details

    • NettyTransport

      private NettyTransport(@NonNull @NonNull String name, boolean available, boolean nativeTransport, @NonNull @NonNull Supplier<io.netty5.channel.IoHandlerFactory> ioHandlerFactory, @NonNull @NonNull io.netty5.channel.ChannelFactory<? extends io.netty5.channel.Channel> clientChannelFactory, @NonNull @NonNull io.netty5.channel.ServerChannelFactory<? extends io.netty5.channel.ServerChannel> serverChannelFactory)
      Constructs a new netty transport instance.
      Parameters:
      name - the display name of the transport.
      available - if the transport is available.
      nativeTransport - if the transport is native.
      ioHandlerFactory - the factory for io handlers.
      clientChannelFactory - the factory for client channels.
      serverChannelFactory - the factory for server channels.
      Throws:
      NullPointerException - if one of the given parameters is null.
  • Method Details

    • values

      public static NettyTransport[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static NettyTransport valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • availableTransport

      @NonNull public static @NonNull NettyTransport availableTransport(boolean noNative)
      Selects and returns the first available transport. If this method should not return native transports, it currently only returns nio.
      Parameters:
      noNative - if no native transport should get included into the selection.
      Returns:
      the first available transport.
      Throws:
      IllegalStateException - if no transport is available, should normally never happen.
    • createEventLoopGroup

      @NonNull public @NonNull io.netty5.channel.EventLoopGroup createEventLoopGroup(int threads, @Nullable @Nullable ThreadFactory threadFactory)
      Creates a new event loop group of the current selected transport with the supplied amount of threads.
      Parameters:
      threads - the amount of threads.
      threadFactory - the thread factory to use for event loop threads, null to use the default factory.
      Returns:
      a new event loop group for this transport.
      Throws:
      IllegalArgumentException - if the given number of threads is negative.
    • displayName

      @NonNull public @NonNull String displayName()
      Get the display name of the transport.
      Returns:
      the display name.
    • nativeTransport

      public boolean nativeTransport()
      Get if this transport type is native.
      Returns:
      if this transport type is native.
    • clientChannelFactory

      @NonNull public @NonNull io.netty5.channel.ChannelFactory<? extends io.netty5.channel.Channel> clientChannelFactory()
      Get the factory for client channels of this transport.
      Returns:
      the factory for client channels of this transport.
    • serverChannelFactory

      @NonNull public @NonNull io.netty5.channel.ServerChannelFactory<? extends io.netty5.channel.ServerChannel> serverChannelFactory()
      Get the factory for server channels of this transport.
      Returns:
      the factory for server channels of this transport.