package com.correx.infrastructure.tools

import com.correx.core.tools.contract.Tool
import com.correx.core.tools.registry.ToolRegistry

class DefaultToolRegistry private constructor(
    private val tools: Map<String, Tool>,
) : ToolRegistry {
    override fun resolve(name: String): Tool? = tools[name]
    override fun all(): List<Tool> = tools.values.toList()

    companion object {
        fun build(vararg tools: Tool): ToolRegistry =
            DefaultToolRegistry(tools.associateBy { it.name })

        fun build(tools: List<Tool>): ToolRegistry =
            DefaultToolRegistry(tools.associateBy { it.name })
    }
}
