compile group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib'
compile group: 'net.pterodactylus', name: 'utils', version: '0.12.4'
- compile group: 'com.google.inject', name: 'guice', version: '3.0'
+ compile group: 'com.google.inject', name: 'guice', version: '4.2.2'
compile group: 'com.google.guava', name: 'guava', version: '27.0.1-android'
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.9.1'
compile group: 'com.fasterxml.jackson.dataformat', name: 'jackson-dataformat-yaml', version: '2.9.1'
import freenet.client.HighLevelSimpleClient
import freenet.node.Node
import freenet.pluginmanager.PluginRespirator
+import javax.inject.Provider
import javax.inject.Singleton
/**
class FreenetModule(private val pluginRespirator: PluginRespirator): Module {
override fun configure(binder: Binder): Unit = binder.run {
- bind(PluginRespirator::class.java).toProvider { pluginRespirator }
- pluginRespirator.node!!.let { node -> bind(Node::class.java).toProvider { node } }
- bind(HighLevelSimpleClient::class.java).toProvider { pluginRespirator.hlSimpleClient!! }
+ bind(PluginRespirator::class.java).toProvider(Provider<PluginRespirator> { pluginRespirator })
+ pluginRespirator.node!!.let { node -> bind(Node::class.java).toProvider(Provider<Node> { node }) }
+ bind(HighLevelSimpleClient::class.java).toProvider(Provider<HighLevelSimpleClient> { pluginRespirator.hlSimpleClient!! })
}
@Provides @Singleton
import javax.inject.Provider
import kotlin.reflect.KClass
-fun <T : Any> KClass<T>.isProvidedBy(instance: T) = Module { it.bind(this.java).toProvider { instance } }
+fun <T : Any> KClass<T>.isProvidedBy(instance: T) = Module { it.bind(this.java).toProvider(Provider<T> { instance }) }
fun <T : Any> KClass<T>.isProvidedBy(provider: com.google.inject.Provider<T>) = Module { it.bind(this.java).toProvider(provider) }
fun <T : Any> KClass<T>.isProvidedBy(provider: KClass<out Provider<T>>) = Module { it.bind(this.java).toProvider(provider.java) }
-inline fun <reified T : Any> KClass<T>.isProvidedByMock() = Module { it.bind(this.java).toProvider { mock() } }
+inline fun <reified T : Any> KClass<T>.isProvidedByMock() = Module { it.bind(this.java).toProvider(Provider<T> { mock() }) }
inline fun <reified T : Any> Injector.getInstance() = getInstance(T::class.java)!!
fun <T : Any> supply(javaClass: Class<T>): Source<T> = object : Source<T> {
override fun fromInstance(instance: T) = Module { it.bind(javaClass).toInstance(instance) }
- override fun byInstance(instance: T) = Module { it.bind(javaClass).toProvider { instance } }
+ override fun byInstance(instance: T) = Module { it.bind(javaClass).toProvider(Provider<T> { instance }) }
override fun byProvider(provider: com.google.inject.Provider<T>) = Module { it.bind(javaClass).toProvider(provider) }
override fun byProvider(provider: Class<Provider<T>>) = Module { it.bind(javaClass).toProvider(provider) }
}