blob: 60ae20bc8ce577af2416b96c4295da213f2212cb [file] [log] [blame] [raw]
package li.cil.oc.util
import li.cil.oc.api.network.Component
import li.cil.oc.api.network.Node
import li.cil.oc.server.component.UpgradeDatabase
object DatabaseAccess {
def withDatabase(node: Node, address: String, f: UpgradeDatabase => Array[AnyRef]): Array[AnyRef] = {
node.network.node(address) match {
case component: Component => component.host match {
case database: UpgradeDatabase => f(database)
case _ => throw new IllegalArgumentException("not a database")
}
case _ => throw new IllegalArgumentException("no such component")
}
}
}