From 0c76c610bde09b752c6366f9f6c2d04b6ec7b4e4 Mon Sep 17 00:00:00 2001 From: Graham Date: Mon, 27 Apr 2020 21:49:19 +0100 Subject: [PATCH] Convert Guice modules to objects Signed-off-by: Graham --- bundler/src/main/java/dev/openrs2/bundler/BundleCommand.kt | 2 +- bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt | 4 ++-- conf/src/main/java/dev/openrs2/conf/ConfigModule.kt | 4 ++-- crypto/src/main/java/dev/openrs2/crypto/CryptoModule.kt | 2 +- .../main/java/dev/openrs2/deob/processor/NameMapProcessor.kt | 2 +- game/src/main/java/dev/openrs2/game/GameCommand.kt | 2 +- game/src/main/java/dev/openrs2/game/GameModule.kt | 2 +- yaml/src/main/java/dev/openrs2/yaml/YamlModule.kt | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bundler/src/main/java/dev/openrs2/bundler/BundleCommand.kt b/bundler/src/main/java/dev/openrs2/bundler/BundleCommand.kt index 5d7a74f8..2a85d945 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/BundleCommand.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/BundleCommand.kt @@ -8,7 +8,7 @@ fun main(args: Array) = BundleCommand().main(args) class BundleCommand : CliktCommand(name = "bundle") { override fun run() { - val injector = Guice.createInjector(BundlerModule()) + val injector = Guice.createInjector(BundlerModule) val bundler = injector.getInstance(Bundler::class.java) bundler.run(Paths.get("nonfree/lib"), Paths.get("nonfree/var/cache/bundle"), Paths.get("etc/loader.p12")) } diff --git a/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt b/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt index c08d9f51..ceee5b6f 100644 --- a/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt +++ b/bundler/src/main/java/dev/openrs2/bundler/BundlerModule.kt @@ -3,8 +3,8 @@ package dev.openrs2.bundler import com.google.inject.AbstractModule import dev.openrs2.crypto.CryptoModule -class BundlerModule : AbstractModule() { +object BundlerModule : AbstractModule() { override fun configure() { - install(CryptoModule()) + install(CryptoModule) } } diff --git a/conf/src/main/java/dev/openrs2/conf/ConfigModule.kt b/conf/src/main/java/dev/openrs2/conf/ConfigModule.kt index b1be1fbe..e68c7fc6 100644 --- a/conf/src/main/java/dev/openrs2/conf/ConfigModule.kt +++ b/conf/src/main/java/dev/openrs2/conf/ConfigModule.kt @@ -4,9 +4,9 @@ import com.google.inject.AbstractModule import com.google.inject.Scopes import dev.openrs2.yaml.YamlModule -class ConfigModule : AbstractModule() { +object ConfigModule : AbstractModule() { override fun configure() { - install(YamlModule()) + install(YamlModule) bind(Config::class.java) .toProvider(ConfigProvider::class.java) diff --git a/crypto/src/main/java/dev/openrs2/crypto/CryptoModule.kt b/crypto/src/main/java/dev/openrs2/crypto/CryptoModule.kt index 2d904342..47cbce1a 100644 --- a/crypto/src/main/java/dev/openrs2/crypto/CryptoModule.kt +++ b/crypto/src/main/java/dev/openrs2/crypto/CryptoModule.kt @@ -4,7 +4,7 @@ import com.google.inject.AbstractModule import com.google.inject.Scopes import org.bouncycastle.crypto.params.RSAPrivateCrtKeyParameters -class CryptoModule : AbstractModule() { +object CryptoModule : AbstractModule() { override fun configure() { bind(RSAPrivateCrtKeyParameters::class.java) .toProvider(RsaKeyProvider::class.java) diff --git a/deob-processor/src/main/java/dev/openrs2/deob/processor/NameMapProcessor.kt b/deob-processor/src/main/java/dev/openrs2/deob/processor/NameMapProcessor.kt index 9e98a182..0003d9bd 100644 --- a/deob-processor/src/main/java/dev/openrs2/deob/processor/NameMapProcessor.kt +++ b/deob-processor/src/main/java/dev/openrs2/deob/processor/NameMapProcessor.kt @@ -46,7 +46,7 @@ class NameMapProcessor : AbstractProcessor() { private lateinit var localScanner: LocalVariableScanner init { - val injector = Guice.createInjector(YamlModule()) + val injector = Guice.createInjector(YamlModule) mapper = injector.getInstance(ObjectMapper::class.java) } diff --git a/game/src/main/java/dev/openrs2/game/GameCommand.kt b/game/src/main/java/dev/openrs2/game/GameCommand.kt index 101e2a64..766dbc57 100644 --- a/game/src/main/java/dev/openrs2/game/GameCommand.kt +++ b/game/src/main/java/dev/openrs2/game/GameCommand.kt @@ -7,7 +7,7 @@ fun main(args: Array) = GameCommand().main(args) class GameCommand : CliktCommand(name = "game") { override fun run() { - val injector = Guice.createInjector(GameModule()) + val injector = Guice.createInjector(GameModule) val server = injector.getInstance(GameServer::class.java) server.run() } diff --git a/game/src/main/java/dev/openrs2/game/GameModule.kt b/game/src/main/java/dev/openrs2/game/GameModule.kt index bd1324ce..1dac9697 100644 --- a/game/src/main/java/dev/openrs2/game/GameModule.kt +++ b/game/src/main/java/dev/openrs2/game/GameModule.kt @@ -2,7 +2,7 @@ package dev.openrs2.game import com.google.inject.AbstractModule -class GameModule : AbstractModule() { +object GameModule : AbstractModule() { override fun configure() { // empty } diff --git a/yaml/src/main/java/dev/openrs2/yaml/YamlModule.kt b/yaml/src/main/java/dev/openrs2/yaml/YamlModule.kt index 2623ad3c..f534687d 100644 --- a/yaml/src/main/java/dev/openrs2/yaml/YamlModule.kt +++ b/yaml/src/main/java/dev/openrs2/yaml/YamlModule.kt @@ -6,7 +6,7 @@ import com.google.inject.AbstractModule import com.google.inject.Scopes import com.google.inject.multibindings.Multibinder -class YamlModule : AbstractModule() { +object YamlModule : AbstractModule() { override fun configure() { Multibinder.newSetBinder(binder(), Module::class.java)