🔀 Merge branch 'release-79'
[Sone.git] / src / main / kotlin / net / pterodactylus / sone / utils / Objects.kt
index 36e530c..6d1d413 100644 (file)
@@ -1,3 +1,7 @@
 package net.pterodactylus.sone.utils
 
-fun <T> T?.asList() = this?.let(::listOf) ?: emptyList<T>()
+fun <T> T?.asList() = this?.let(::listOf) ?: emptyList()
+val Any?.unit get() = Unit
+
+fun <T> T?.throwOnNullIf(throwCondition: Boolean, exception: () -> Throwable) =
+               if (this == null && throwCondition) throw exception() else this