KOptional.orNull
This commit is contained in:
parent
3384ffebd0
commit
7a344ceece
@ -4,7 +4,7 @@ kotlin.code.style=official
|
|||||||
specifyKotlinAsDependency=false
|
specifyKotlinAsDependency=false
|
||||||
|
|
||||||
projectGroup=ru.dbotthepony.kommons
|
projectGroup=ru.dbotthepony.kommons
|
||||||
projectVersion=2.9.24
|
projectVersion=2.9.25
|
||||||
|
|
||||||
guavaDepVersion=33.0.0
|
guavaDepVersion=33.0.0
|
||||||
gsonDepVersion=2.8.9
|
gsonDepVersion=2.8.9
|
||||||
|
@ -94,6 +94,14 @@ class KOptional<T> private constructor(private val _value: T, val isPresent: Boo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun orNull(): T? {
|
||||||
|
if (isPresent) {
|
||||||
|
return value
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun valueEquals(other: Any?): Boolean {
|
fun valueEquals(other: Any?): Boolean {
|
||||||
if (isPresent) {
|
if (isPresent) {
|
||||||
return _value == other
|
return _value == other
|
||||||
|
Loading…
Reference in New Issue
Block a user