Ver código fonte

Move aliases DI code into its own module.

Change-Id: Ifafbf427cd1a1f6ac0a1635c72b065a5f911c8fe
Reviewed-on: http://gerrit.dmdirc.com/3525
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
pull/1/head
Chris Smith 10 anos atrás
pai
commit
9e9984e280

+ 8
- 11
src/com/dmdirc/ClientModule.java Ver arquivo

@@ -32,8 +32,7 @@ import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
32 32
 import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
33 33
 import com.dmdirc.commandline.CommandLineParser;
34 34
 import com.dmdirc.commandparser.CommandManager;
35
-import com.dmdirc.commandparser.aliases.AliasStore;
36
-import com.dmdirc.commandparser.aliases.YamlAliasStore;
35
+import com.dmdirc.commandparser.aliases.AliasesModule;
37 36
 import com.dmdirc.commandparser.commands.CommandModule;
38 37
 import com.dmdirc.config.IdentityManager;
39 38
 import com.dmdirc.config.InvalidIdentityFileException;
@@ -87,7 +86,12 @@ import dagger.Provides;
87 86
  */
88 87
 @Module(
89 88
         injects = {Main.class, CommandLineParser.class},
90
-        includes = {CommandLineOptionsModule.class, CommandModule.class, UpdaterModule.class},
89
+        includes = {
90
+            AliasesModule.class,
91
+            CommandLineOptionsModule.class,
92
+            CommandModule.class,
93
+            UpdaterModule.class
94
+        },
91 95
         library = true)
92 96
 public class ClientModule {
93 97
 
@@ -129,8 +133,7 @@ public class ClientModule {
129 133
         }
130 134
 
131 135
         if (commandLineParser.getDisableReporting()) {
132
-            identityManager.getUserSettings()
133
-                    .setOption("temp", "noerrorreporting", true);
136
+            identityManager.getUserSettings().setOption("temp", "noerrorreporting", true);
134 137
         }
135 138
 
136 139
         return identityManager;
@@ -306,12 +309,6 @@ public class ClientModule {
306 309
         return new EventBus();
307 310
     }
308 311
 
309
-    @Provides
310
-    @Singleton
311
-    public AliasStore getAliasStore(final YamlAliasStore store) {
312
-        return store;
313
-    }
314
-
315 312
     /**
316 313
      * Sets the object graph that will be injected. Must be called before any provider method.
317 314
      *

+ 42
- 0
src/com/dmdirc/commandparser/aliases/AliasesModule.java Ver arquivo

@@ -0,0 +1,42 @@
1
+/*
2
+ * Copyright (c) 2006-2014 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.commandparser.aliases;
24
+
25
+import javax.inject.Singleton;
26
+
27
+import dagger.Module;
28
+import dagger.Provides;
29
+
30
+/**
31
+ * Dagger module for aliases.
32
+ */
33
+@Module(library = true, complete = false)
34
+public class AliasesModule {
35
+
36
+    @Provides
37
+    @Singleton
38
+    public AliasStore getAliasStore(final YamlAliasStore store) {
39
+        return store;
40
+    }
41
+
42
+}

Carregando…
Cancelar
Salvar