projects
/
Sone.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
🚧 Add first-start notification handler
[Sone.git]
/
src
/
main
/
kotlin
/
net
/
pterodactylus
/
sone
/
utils
/
Objects.kt
diff --git
a/src/main/kotlin/net/pterodactylus/sone/utils/Objects.kt
b/src/main/kotlin/net/pterodactylus/sone/utils/Objects.kt
index
cd36ec9
..
d9ec162
100644
(file)
--- a/
src/main/kotlin/net/pterodactylus/sone/utils/Objects.kt
+++ b/
src/main/kotlin/net/pterodactylus/sone/utils/Objects.kt
@@
-1,4
+1,13
@@
package net.pterodactylus.sone.utils
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
val Any?.unit get() = Unit
+
+fun <T> T?.throwOnNullIf(throwCondition: Boolean, exception: () -> Throwable) =
+ if (this == null && throwCondition) throw exception() else this
+
+fun <T> T?.onNull(block: () -> Unit) = this.also {
+ if (this == null) {
+ block()
+ }
+}