From: David ‘Bombe’ Roden Date: Wed, 13 Nov 2024 21:40:02 +0000 (+0100) Subject: 🚸 Add method that turns any object into a java.util.Optional X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=f8983b304759df4bf128876b25a887e7b63bcff8;p=rhynodge.git 🚸 Add method that turns any object into a java.util.Optional --- diff --git a/src/main/kotlin/net/pterodactylus/rhynodge/utils/Optionals.kt b/src/main/kotlin/net/pterodactylus/rhynodge/utils/Optionals.kt index 00e9fea..e51b36d 100644 --- a/src/main/kotlin/net/pterodactylus/rhynodge/utils/Optionals.kt +++ b/src/main/kotlin/net/pterodactylus/rhynodge/utils/Optionals.kt @@ -4,3 +4,4 @@ import com.google.common.base.Optional fun T?.asOptional(): Optional = Optional.fromNullable(this) fun String?.asOptional(): Optional = if ((this == null) || (this.isEmpty())) Optional.absent() else Optional.of(this) +fun String?.toOptional(): java.util.Optional = java.util.Optional.ofNullable(this)