ru.astrainteractive.gradleplugin.property.extension.PrimitivePropertyValueExt.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of convention Show documentation
Show all versions of convention Show documentation
GradlePlugin for my kotlin projects
package ru.astrainteractive.gradleplugin.property.extension
import ru.astrainteractive.gradleplugin.property.PropertyValue
object PrimitivePropertyValueExt {
// String
val PropertyValue.stringOrNull: String?
get() = value.getOrNull()
val PropertyValue.stringOrEmpty: String
get() = stringOrNull.orEmpty()
val PropertyValue.requireString: String
get() = value.getOrThrow()
// Integer
val PropertyValue.int: Result
get() = value.mapCatching { it.toInt() }
val PropertyValue.intOrNull: Int?
get() = int.getOrNull()
val PropertyValue.requireInt: Int
get() = int.getOrThrow()
}