🎨 Extract asOptional() into its own file
[rhynodge.git] / src / main / kotlin / net / pterodactylus / rhynodge / utils / Optionals.kt
1 package net.pterodactylus.rhynodge.utils
2
3 import com.google.common.base.Optional
4
5 fun <T> T?.asOptional(): Optional<T> = Optional.fromNullable(this)
6 fun String?.asOptional(): Optional<String> = if ((this == null) || (this.isEmpty())) Optional.absent() else Optional.of(this)