Przeglądaj źródła

Rename some config classes.

Change-Id: Ieaa7897a5e0bf1168e5c2b4405585558e108ee52
Reviewed-on: http://gerrit.dmdirc.com/2781
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
tags/0.8rc1
Chris Smith 10 lat temu
rodzic
commit
0b69247ea1

src/com/dmdirc/config/ConfigSource.java → src/com/dmdirc/config/BaseConfigProvider.java Wyświetl plik

@@ -40,22 +40,22 @@ import java.util.List;
40 40
 import javax.inject.Provider;
41 41
 
42 42
 /**
43
- * Defines methods to get options from a config source in various forms.
44
- * <p>
45
- * This implementation supports the idea of optional/disabled settings.
43
+ * Defines methods to get options from a config provider in various forms.
44
+ *
45
+ * <p>This implementation supports the idea of optional/disabled settings.
46 46
  * This is where values may be prefixed with the strings <code>true:</code>
47 47
  * or <code>false:</code>, where the former has no effect on the value of
48 48
  * the setting, and the latter indicates that the user wishes to disable
49 49
  * the setting.
50
- * <p>
51
- * Disabled settings allow for optional settings to have default values; a
50
+ *
51
+ * <p>Disabled settings allow for optional settings to have default values; a
52 52
  * value can be added with the <code>false:</code> prefix which effectively
53 53
  * disables the default value and makes the setting act as though it does not
54 54
  * have a value. Note that for this sort of behaviour to make sense, it requires
55 55
  * an implementation that takes values from multiple sources, such as a
56 56
  * {@link ConfigManager}.
57 57
  */
58
-public abstract class ConfigSource implements ReadOnlyConfigProvider {
58
+public abstract class BaseConfigProvider implements ReadOnlyConfigProvider {
59 59
 
60 60
     /** A permissive validator to use when callers don't specify one. */
61 61
     private static final Validator<String> PERMISSIVE_VALIDATOR
@@ -77,7 +77,7 @@ public abstract class ConfigSource implements ReadOnlyConfigProvider {
77 77
      *
78 78
      * @param colourManager The colour manager to use to convert colours.
79 79
      */
80
-    public ConfigSource(final Provider<ColourManager> colourManager) {
80
+    public BaseConfigProvider(final Provider<ColourManager> colourManager) {
81 81
         this.colourManager = colourManager;
82 82
     }
83 83
 
@@ -88,7 +88,7 @@ public abstract class ConfigSource implements ReadOnlyConfigProvider {
88 88
      * @deprecated Should pass in a {@link ColourManager}.
89 89
      */
90 90
     @Deprecated
91
-    public ConfigSource() {
91
+    public BaseConfigProvider() {
92 92
         this(ColourManager.getColourManagerProvider());
93 93
     }
94 94
 

src/com/dmdirc/config/Identity.java → src/com/dmdirc/config/ConfigFileBackedConfigProvider.java Wyświetl plik

@@ -45,14 +45,10 @@ import java.util.Set;
45 45
 import lombok.extern.slf4j.Slf4j;
46 46
 
47 47
 /**
48
- * An identity is a group of settings that are applied to a connection, server,
49
- * network or channel. Identities may be automatically applied in certain
50
- * cases, or the user may manually apply them.
51
- * <p>
52
- * Note: this class has a natural ordering that is inconsistent with equals.
48
+ * Provides configuration settings from a {@link ConfigFile}.
53 49
  */
54 50
 @Slf4j
55
-public class Identity extends ConfigSource implements ConfigProvider {
51
+public class ConfigFileBackedConfigProvider extends BaseConfigProvider implements ConfigProvider {
56 52
 
57 53
     /** The domain used for identity settings. */
58 54
     private static final String DOMAIN = "identity";
@@ -84,7 +80,7 @@ public class Identity extends ConfigSource implements ConfigProvider {
84 80
      * @throws InvalidIdentityFileException Missing required properties
85 81
      * @throws IOException Input/output exception
86 82
      */
87
-    public Identity(final File file, final boolean forceDefault) throws IOException,
83
+    public ConfigFileBackedConfigProvider(final File file, final boolean forceDefault) throws IOException,
88 84
             InvalidIdentityFileException {
89 85
         super();
90 86
 
@@ -107,7 +103,7 @@ public class Identity extends ConfigSource implements ConfigProvider {
107 103
      * @throws InvalidIdentityFileException Missing required properties
108 104
      * @throws IOException Input/output exception
109 105
      */
110
-    public Identity(final InputStream stream, final boolean forceDefault) throws IOException,
106
+    public ConfigFileBackedConfigProvider(final InputStream stream, final boolean forceDefault) throws IOException,
111 107
             InvalidIdentityFileException {
112 108
         super();
113 109
 
@@ -127,7 +123,7 @@ public class Identity extends ConfigSource implements ConfigProvider {
127 123
      * @param configFile The config file to use
128 124
      * @param target The target of this identity
129 125
      */
130
-    public Identity(final ConfigFile configFile, final ConfigTarget target) {
126
+    public ConfigFileBackedConfigProvider(final ConfigFile configFile, final ConfigTarget target) {
131 127
         super();
132 128
 
133 129
         this.file = configFile;
@@ -546,9 +542,9 @@ public class Identity extends ConfigSource implements ConfigProvider {
546 542
     /** {@inheritDoc} */
547 543
     @Override
548 544
     public boolean equals(final Object obj) {
549
-        return obj instanceof Identity
550
-                && getName().equals(((Identity) obj).getName())
551
-                && getTarget() == ((Identity) obj).getTarget();
545
+        return obj instanceof ConfigFileBackedConfigProvider
546
+                && getName().equals(((ConfigFileBackedConfigProvider) obj).getName())
547
+                && getTarget() == ((ConfigFileBackedConfigProvider) obj).getTarget();
552 548
     }
553 549
 
554 550
 }

+ 1
- 1
src/com/dmdirc/config/ConfigManager.java Wyświetl plik

@@ -46,7 +46,7 @@ import lombok.extern.slf4j.Slf4j;
46 46
  */
47 47
 @Slf4j
48 48
 @SuppressWarnings("PMD.UnusedPrivateField")
49
-public class ConfigManager extends ConfigSource implements ConfigChangeListener,
49
+public class ConfigManager extends BaseConfigProvider implements ConfigChangeListener,
50 50
         ConfigProviderListener, AggregateConfigProvider {
51 51
 
52 52
     /** Temporary map for lookup stats. */

+ 7
- 7
src/com/dmdirc/config/IdentityManager.java Wyświetl plik

@@ -143,7 +143,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
143 143
         addonSettings.put("name", "Addon defaults");
144 144
         addonConfigFile.addDomain("identity", addonSettings);
145 145
 
146
-        addonConfig = new Identity(addonConfigFile, target);
146
+        addonConfig = new ConfigFileBackedConfigProvider(addonConfigFile, target);
147 147
         addConfigProvider(addonConfig);
148 148
 
149 149
         if (!getGlobalConfiguration().hasOptionString("identity", "defaultsversion")) {
@@ -294,7 +294,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
294 294
     private void loadIdentity(final File file) {
295 295
         synchronized (identities) {
296 296
             for (ConfigProvider identity : getAllIdentities()) {
297
-                if ((identity instanceof Identity) && ((Identity) identity).isFile(file)) {
297
+                if ((identity instanceof ConfigFileBackedConfigProvider) && ((ConfigFileBackedConfigProvider) identity).isFile(file)) {
298 298
                     // TODO: This manager should keep a list of files->identities instead of
299 299
                     //       relying on the identities remembering.
300 300
                     try {
@@ -313,7 +313,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
313 313
         }
314 314
 
315 315
         try {
316
-            addConfigProvider(new Identity(file, false));
316
+            addConfigProvider(new ConfigFileBackedConfigProvider(file, false));
317 317
         } catch (InvalidIdentityFileException ex) {
318 318
             Logger.userError(ErrorLevel.MEDIUM,
319 319
                     "Invalid identity file: " + file.getAbsolutePath()
@@ -359,7 +359,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
359 359
     @Override
360 360
     public void loadVersionIdentity() {
361 361
         try {
362
-            versionConfig = new Identity(IdentityManager.class.getResourceAsStream("/com/dmdirc/version.config"), false);
362
+            versionConfig = new ConfigFileBackedConfigProvider(IdentityManager.class.getResourceAsStream("/com/dmdirc/version.config"), false);
363 363
             addConfigProvider(versionConfig);
364 364
         } catch (IOException | InvalidIdentityFileException ex) {
365 365
             Logger.appError(ErrorLevel.FATAL, "Unable to load version information", ex);
@@ -380,7 +380,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
380 380
                 file.createNewFile();
381 381
             }
382 382
 
383
-            config = new Identity(file, true);
383
+            config = new ConfigFileBackedConfigProvider(file, true);
384 384
             config.setOption("identity", "name", "Global config");
385 385
             addConfigProvider(config);
386 386
         } catch (IOException ex) {
@@ -670,7 +670,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
670 670
      * @throws InvalidIdentityFileException If the settings are invalid
671 671
      * @since 0.6.3m1
672 672
      */
673
-    protected Identity createIdentity(final Map<String, Map<String, String>> settings)
673
+    protected ConfigFileBackedConfigProvider createIdentity(final Map<String, Map<String, String>> settings)
674 674
             throws IOException, InvalidIdentityFileException {
675 675
         if (!settings.containsKey(IDENTITY_DOMAIN) || !settings.get(IDENTITY_DOMAIN).containsKey("name")
676 676
                 || settings.get(IDENTITY_DOMAIN).get("name").isEmpty()) {
@@ -697,7 +697,7 @@ public class IdentityManager implements IdentityFactory, IdentityController {
697 697
 
698 698
         configFile.write();
699 699
 
700
-        final Identity identity = new Identity(file, false);
700
+        final ConfigFileBackedConfigProvider identity = new ConfigFileBackedConfigProvider(file, false);
701 701
         addConfigProvider(identity);
702 702
 
703 703
         return identity;

+ 2
- 2
src/com/dmdirc/plugins/PluginInfo.java Wyświetl plik

@@ -24,7 +24,7 @@ package com.dmdirc.plugins;
24 24
 
25 25
 import com.dmdirc.actions.ActionManager;
26 26
 import com.dmdirc.actions.CoreActionType;
27
-import com.dmdirc.config.Identity;
27
+import com.dmdirc.config.ConfigFileBackedConfigProvider;
28 28
 import com.dmdirc.config.IdentityManager;
29 29
 import com.dmdirc.config.InvalidIdentityFileException;
30 30
 import com.dmdirc.interfaces.config.ConfigProvider;
@@ -243,7 +243,7 @@ public class PluginInfo implements Comparable<PluginInfo>, ServiceProvider {
243 243
 
244 244
                 synchronized (configProviders) {
245 245
                     try {
246
-                        final ConfigProvider configProvider = new Identity(stream, false);
246
+                        final ConfigProvider configProvider = new ConfigFileBackedConfigProvider(stream, false);
247 247
                         IdentityManager.getIdentityManager().addConfigProvider(configProvider);
248 248
                         configProviders.add(configProvider);
249 249
                     } catch (final InvalidIdentityFileException ex) {

+ 2
- 2
src/com/dmdirc/ui/themes/ThemeIdentity.java Wyświetl plik

@@ -22,7 +22,7 @@
22 22
 
23 23
 package com.dmdirc.ui.themes;
24 24
 
25
-import com.dmdirc.config.Identity;
25
+import com.dmdirc.config.ConfigFileBackedConfigProvider;
26 26
 import com.dmdirc.config.InvalidIdentityFileException;
27 27
 import com.dmdirc.util.validators.Validator;
28 28
 
@@ -33,7 +33,7 @@ import java.io.InputStream;
33 33
  * An identity that only claims to know about settings under the UI domain,
34 34
  * for use with themes.
35 35
  */
36
-public class ThemeIdentity extends Identity {
36
+public class ThemeIdentity extends ConfigFileBackedConfigProvider {
37 37
 
38 38
     /**
39 39
      * A version number for this class. It should be changed whenever the class

+ 6
- 6
test/com/dmdirc/config/IdentityTest.java Wyświetl plik

@@ -38,7 +38,7 @@ import static org.mockito.Mockito.*;
38 38
 
39 39
 public class IdentityTest {
40 40
 
41
-    private Identity myIdent;
41
+    private ConfigFileBackedConfigProvider myIdent;
42 42
     private ConfigTarget target;
43 43
 
44 44
     @Before
@@ -46,7 +46,7 @@ public class IdentityTest {
46 46
         target = new ConfigTarget();
47 47
         target.setChannel("#unittest@unittest");
48 48
 
49
-        myIdent = new Identity(new ConfigFile(getClass().getResourceAsStream("identity2")), target);
49
+        myIdent = new ConfigFileBackedConfigProvider(new ConfigFile(getClass().getResourceAsStream("identity2")), target);
50 50
     }
51 51
 
52 52
     @Test
@@ -134,7 +134,7 @@ public class IdentityTest {
134 134
 
135 135
         myIdent.save();
136 136
 
137
-        myIdent = new Identity(myIdent.file.getFile(), false);
137
+        myIdent = new ConfigFileBackedConfigProvider(myIdent.file.getFile(), false);
138 138
 
139 139
         assertEquals("baz!", myIdent.getOption("foo", "bar"));
140 140
     }
@@ -147,17 +147,17 @@ public class IdentityTest {
147 147
 
148 148
     @Test(expected=InvalidIdentityFileException.class)
149 149
     public void testNoName() throws IOException, InvalidIdentityFileException {
150
-        new Identity(getClass().getResourceAsStream("identity1"), false);
150
+        new ConfigFileBackedConfigProvider(getClass().getResourceAsStream("identity1"), false);
151 151
     }
152 152
 
153 153
     @Test(expected=InvalidIdentityFileException.class)
154 154
     public void testNoTarget() throws IOException, InvalidIdentityFileException {
155
-        new Identity(getClass().getResourceAsStream("identity2"), false);
155
+        new ConfigFileBackedConfigProvider(getClass().getResourceAsStream("identity2"), false);
156 156
     }
157 157
 
158 158
     @Test
159 159
     public void testMigrate() throws IOException, InvalidIdentityFileException {
160
-        final Identity id = new Identity(getClass().getResourceAsStream("identity3"), false);
160
+        final ConfigFileBackedConfigProvider id = new ConfigFileBackedConfigProvider(getClass().getResourceAsStream("identity3"), false);
161 161
 
162 162
         assertTrue(id.file.isKeyDomain("identity"));
163 163
         assertTrue(id.file.isKeyDomain("meep"));

+ 2
- 2
test/com/dmdirc/harness/TestConfigSource.java Wyświetl plik

@@ -22,12 +22,12 @@
22 22
 
23 23
 package com.dmdirc.harness;
24 24
 
25
-import com.dmdirc.config.ConfigSource;
25
+import com.dmdirc.config.BaseConfigProvider;
26 26
 import com.dmdirc.util.validators.Validator;
27 27
 
28 28
 import java.util.Map;
29 29
 
30
-public class TestConfigSource extends ConfigSource {
30
+public class TestConfigSource extends BaseConfigProvider {
31 31
 
32 32
     @Override
33 33
     public boolean hasOption(String domain, String option, Validator<String> validator) {

Ładowanie…
Anuluj
Zapisz