invirt.utils.enum.kt Maven / Gradle / Ivy
package invirt.utils
inline fun > valueOfOrNull(name: String): E? {
return enumValues().firstOrNull { it.name == name }
}
/**
* Parses a comma separated string of enum names into a list of enum values
*/
inline fun > String?.toEnumValues(): List {
if (this.isNullOrBlank()) {
return emptyList()
}
return this.split(",")
.map { it.trim() }
.map { enumValueOf(it) }
}