Skip to content

Commit

Permalink
refactor(model): Inline a referenceFor() overload function
Browse files Browse the repository at this point in the history
Only the version that takes a `rootIndex` is directly used.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Oct 2, 2024
1 parent ed4a537 commit 7b4177d
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions model/src/main/kotlin/DependencyGraphNavigator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -101,22 +101,16 @@ class DependencyGraphNavigator(
return dependencies
}

/**
* Resolve a [DependencyGraphNode] in the [DependencyGraph] for the specified [package manager][manager] with the
* given [pkgIndex] and [fragment]. Throw an exception if no such node can be found.
*/
private fun referenceFor(manager: String, pkgIndex: Int, fragment: Int): DependencyGraphNode =
requireNotNull(graphDependencyRefMappings[manager])[pkgIndex].find { it.fragment == fragment }
?: throw IllegalArgumentException(
"Could not resolve a DependencyReference for index = $pkgIndex and fragment $fragment."
)

/**
* Resolve a [DependencyGraphNode] in the [DependencyGraph] for the specified [package manager][manager] that
* corresponds to the given [rootIndex]. Throw an exception if no such reference can be found.
*/
private fun referenceFor(manager: String, rootIndex: RootDependencyIndex): DependencyGraphNode =
referenceFor(manager, rootIndex.root, rootIndex.fragment)
requireNotNull(graphDependencyRefMappings[manager])[rootIndex.root].find { it.fragment == rootIndex.fragment }
?: throw IllegalArgumentException(
"Could not resolve a DependencyReference for index = ${rootIndex.root} and fragment " +
"${rootIndex.fragment}."
)
}

/**
Expand Down

0 comments on commit 7b4177d

Please sign in to comment.