me.jakejmattson.kutils.api.dsl.command.GenericContainers.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of KUtils Show documentation
Show all versions of KUtils Show documentation
A Discord bot framework for Kotlin.
package me.jakejmattson.kutils.api.dsl.command
open class GenericContainer
class NoArgs : GenericContainer()
data class Args1(val first: T) : GenericContainer()
data class Args2(val first: A, val second: B) : GenericContainer()
data class Args3(val first: A, val second: B, val third: C) : GenericContainer()
data class Args4(val first: A, val second: B, val third: C, val fourth: D) : GenericContainer()
data class Args5(val first: A, val second: B, val third: C, val fourth: D, val fifth: E) : GenericContainer()
internal fun bundleToArgContainer(arguments: List) =
when (arguments.size) {
0 -> NoArgs()
1 -> Args1(arguments[0])
2 -> Args2(arguments[0], arguments[1])
3 -> Args3(arguments[0], arguments[1], arguments[2])
4 -> Args4(arguments[0], arguments[1], arguments[2], arguments[3])
5 -> Args5(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4])
else -> throw IllegalArgumentException("Cannot handle (${arguments.size}) arguments.")
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy