2f7bd6ee05fd8df63c9079441d08e57bc8b89e0f
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / utils / Objects.kt
1 package net.pterodactylus.sone.utils
2
3 fun <T> T?.asList() = this?.let(::listOf) ?: emptyList<T>()
4 val Any?.unit get() = Unit
5
6 fun <T> T?.throwOnNullIf(throwCondition: Boolean, exception: () -> Throwable) =
7                 if (this == null && throwCondition) throw exception() else this