io.smooth.constraint.Utils.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of constraints Show documentation
Show all versions of constraints Show documentation
A suite of libraries made to help ease developer's life
The newest version!
package io.smooth.constraint
import io.smooth.constraint.resolution.ConstraintResolution
suspend fun > Pair>.getDetails() =
second.getDetails(first)
suspend fun > Pair>.resolve() =
second.resolve(first)
data class ConstraintResolutionDetails(
val constraint: Constraint<*>,
val resolution: ConstraintResolution, *>,
val details: Any
){
suspend fun resolve(){
resolution.resolve(constraint)
}
}
suspend fun Pair, List, *>>>.resolutionDetails() =
second.mapNotNull {
val details = it.getDetails(first)
if (details != null) ConstraintResolutionDetails(first, it, details)
else null
}
suspend fun ConstraintsNotMet.resolutionDetails() =
getResolutions().map {
it.resolutionDetails()
}.flatten()
suspend fun ConstraintsNotMet.getResolutions(): List, List, *>>>> {
val service = ConstraintsService.getInstance()
return blockingConstraints.mapNotNull {
it to (service.getConstraintResolutions(it::class)?.map {
it.get() as ConstraintResolution, *>
} ?: arrayListOf())
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy