commonMain.com.copperleaf.ballast.navigation.internal.EnumRoutingTable.kt Maven / Gradle / Ivy
package com.copperleaf.ballast.navigation.internal
import com.copperleaf.ballast.navigation.routing.Destination
import com.copperleaf.ballast.navigation.routing.Route
import com.copperleaf.ballast.navigation.routing.RoutingTable
import com.copperleaf.ballast.navigation.routing.UnmatchedDestination
import com.copperleaf.ballast.navigation.routing.asMismatchedDestination
import com.copperleaf.ballast.navigation.routing.matchDestinationOrNull
/**
* A RoutingTable with a statically-defined list of routes, ordered by matcher weight.
*/
internal data class EnumRoutingTable(
private val routes: List,
) : RoutingTable where T : Enum, T : Route {
override fun findMatch(
unmatchedDestination: UnmatchedDestination
): Destination {
return routes
.firstNotNullOfOrNull { it.matcher.matchDestinationOrNull(it, unmatchedDestination) }
?: unmatchedDestination.asMismatchedDestination()
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy