val defaultInjector: (T) -> Unit // DaggerのInjector ) { fun inject(target: T) { val injector = injectorDelegateMap[targetClass] ?: defaultInjector injector.invoke(target) } companion object { private val injectorDelegateMap = mutableMapOf<Class<*>, (Any) -> Unit>() // Test用のInjector @VisibleForTesting fun <T> setDelegate(targetClass: Class<T>, injector: (T) -> Unit) { @Suppress("UNCHECKED_CAST") injectorDelegateMap[targetClass] = { injector.invoke(it as T) } } } } テストInjectorあれば使う、無いならデフォルトの使う