Skip to content

Commit 578fb58

Browse files
committed
chore(TransportType): sealed -> enum
1 parent e4a09eb commit 578fb58

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

src/main/kotlin/net/ccbluex/netty/http/util/TransportDetector.kt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,48 +30,48 @@ import io.netty.channel.kqueue.KQueueServerSocketChannel
3030
import io.netty.channel.nio.NioEventLoopGroup
3131
import io.netty.channel.socket.nio.NioServerSocketChannel
3232

33-
internal sealed interface TransportType {
34-
val isAvailable: Boolean
35-
36-
fun newParentGroup(): EventLoopGroup
37-
38-
fun newChildGroup(): EventLoopGroup
39-
40-
fun newServerChannel(): ServerChannel
41-
42-
object Nio : TransportType {
33+
internal enum class TransportType {
34+
Nio {
4335
override val isAvailable get() = true
4436

4537
override fun newParentGroup() = NioEventLoopGroup(1)
4638

4739
override fun newChildGroup() = NioEventLoopGroup()
4840

4941
override fun newServerChannel() = NioServerSocketChannel()
50-
}
42+
},
5143

52-
object Epoll : TransportType {
44+
Epoll {
5345
override val isAvailable get() = try {
5446
io.netty.channel.epoll.Epoll.isAvailable()
55-
} catch (t: Throwable) { false }
47+
} catch (_: Throwable) { false }
5648

5749
override fun newParentGroup() = EpollEventLoopGroup(1)
5850

5951
override fun newChildGroup() = EpollEventLoopGroup()
6052

6153
override fun newServerChannel() = EpollServerSocketChannel()
62-
}
54+
},
6355

64-
object KQueue : TransportType {
56+
KQueue {
6557
override val isAvailable get() = try {
6658
io.netty.channel.kqueue.KQueue.isAvailable()
67-
} catch (t: Throwable) { false }
59+
} catch (_: Throwable) { false }
6860

6961
override fun newParentGroup() = KQueueEventLoopGroup(1)
7062

7163
override fun newChildGroup() = KQueueEventLoopGroup()
7264

7365
override fun newServerChannel() = KQueueServerSocketChannel()
74-
}
66+
};
67+
68+
abstract val isAvailable: Boolean
69+
70+
abstract fun newParentGroup(): EventLoopGroup
71+
72+
abstract fun newChildGroup(): EventLoopGroup
73+
74+
abstract fun newServerChannel(): ServerChannel
7575

7676
companion object {
7777
private val available by lazy {

0 commit comments

Comments
 (0)