jvmMain.definitions.RaptorGraphArgumentDelegate.kt Maven / Gradle / Ivy
The newest version!
package io.fluidsonic.raptor
import io.fluidsonic.stdlib.*
import kotlin.properties.*
public interface RaptorGraphArgumentDelegate : PropertyDelegateProvider> {
@RaptorDsl
public fun map(
// TODO rn to transform?
transform: RaptorGraphInputScope.(value: Type) -> TransformedType,
): RaptorGraphArgumentDelegate
}
@RaptorDsl
public fun RaptorGraphArgumentDelegate>.mapValue(
transform: RaptorGraphInputScope.(value: Type) -> TransformedType,
): RaptorGraphArgumentDelegate> =
map { maybe -> maybe.map { transform(it) } }
@RaptorDsl
public fun RaptorGraphArgumentDelegate>.mapValueIfNotNull(
transform: RaptorGraphInputScope.(value: Type) -> TransformedType?,
): RaptorGraphArgumentDelegate> =
map { maybe -> maybe.mapIfNotNull { transform(it) } }
@RaptorDsl
public fun RaptorGraphArgumentDelegate.validate(
validate: RaptorGraphInputScope.(value: Type) -> Unit,
): RaptorGraphArgumentDelegate =
map { value -> value.also { validate(it) } }
@RaptorDsl
public fun RaptorGraphArgumentDelegate.validateIfNotNull(
validate: RaptorGraphInputScope.(value: Type) -> Unit,
): RaptorGraphArgumentDelegate =
validate { if (it != null) validate(it) }
@RaptorDsl
public fun RaptorGraphArgumentDelegate>.validateValue(
validate: RaptorGraphInputScope.(value: Type) -> Unit,
): RaptorGraphArgumentDelegate> =
validate { if (it.hasValue()) validate(it.get()) }
@RaptorDsl
public fun RaptorGraphArgumentDelegate>.validateValueIfNotNull(
validate: RaptorGraphInputScope.(value: Type) -> Unit,
): RaptorGraphArgumentDelegate> =
validateValue { if (it != null) validate(it) }