Suppose that I am developing some utility classes that build upon ProviderFactory
. Something like
abstract class MyProviderFactory @Inject constructor(private val providers: ProviderFactory) {
fun which(tool: String): Provider<String> {
// Do something with providers.exec() here - impl not important
}
}
The question is how I can use this MyProviderFactory
that I have created - would I be obligated to use an ObjectFactory
to explicitly create an object, or is it possible to have it be injected directly? It seems something like this:
abstract class MyTask @Inject constructor(private val objects: ObjectFactory): DefaultTask() {
private val myProviders = objects.newInstance(MyProviderFactory::class.java)
// Rest of task goes here
}
seems to be a bit verbose and repetitive, but I’m not sure if
abstract class MyTask @Inject constructor(private val myProviders: MyProviderFactory): DefaultTask() {
// Rest of task goes there
}
will actually do the same thing.
Any advice would be appreciated.