commonMain.com.copperleaf.ballast.navigation.routing.RouteMatcher.kt Maven / Gradle / Ivy
package com.copperleaf.ballast.navigation.routing
import com.copperleaf.ballast.navigation.internal.RouteParser
public interface RouteMatcher {
public val routeFormat: String
public val path: List
public val query: List
public val weight: Double
public fun match(
originalRoute: T,
unmatchedDestination: UnmatchedDestination,
): MatchResult
public sealed interface MatchResult {
public val originalRoute: T
/**
* Neither the path not the query parameters matched this route.
*/
public data class NoMatch(
override val originalRoute: T,
) : MatchResult
/**
* A partial match, where the path was fully matched against the input destination URL, but the query parameters
* do not match (either missing required query parameters, or extras were provided in the URL that could not be
* matched to this route).
*/
public data class PartialMatch(
override val originalRoute: T,
val parsedPathParameters: Map>,
) : MatchResult
/**
* A complete match, both the path and query are fully matched against the input destination URL
*/
public data class CompleteMatch(
override val originalRoute: T,
val parsedPathParameters: Map>,
val parsedQueryParameters: Map>,
) : MatchResult
}
public companion object {
public fun create(
routeFormat: String,
computeWeight: (List, List) -> Double = RouteParser::computeWeight,
): RouteMatcher = RouteParser.parseRoute(routeFormat, computeWeight)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy