Переглянути джерело

Assorted tidying.

pull/652/head
Chris Smith 8 роки тому
джерело
коміт
18cb00a6bc

+ 1
- 1
src/com/dmdirc/Channel.java Переглянути файл

@@ -263,7 +263,7 @@ public class Channel extends FrameContainer implements GroupChat {
263 263
         // Needs to be published synchronously so that nicklists are cleared before the parser
264 264
         // is disconnected (which happens synchronously after this method returns).
265 265
         getEventBus().publish(
266
-                new NickListClientsChangedEvent(this, Collections.<GroupChatUser>emptyList()));
266
+                new NickListClientsChangedEvent(this, Collections.emptyList()));
267 267
     }
268 268
 
269 269
     @Override

+ 2
- 2
src/com/dmdirc/FrameContainer.java Переглянути файл

@@ -83,7 +83,7 @@ public class FrameContainer implements WindowModel {
83 83
     /** The connection associated with this model. */
84 84
     private Optional<Connection> connection = Optional.empty();
85 85
     /** The ID for this window. */
86
-    @Nullable private String id = null;
86
+    @Nullable private String id;
87 87
 
88 88
     /**
89 89
      * Instantiate new frame container.
@@ -119,7 +119,7 @@ public class FrameContainer implements WindowModel {
119 119
 
120 120
     @Override
121 121
     public String getId() {
122
-        if (this.id == null) {
122
+        if (id == null) {
123 123
             throw new IllegalStateException("ID has not been set");
124 124
         }
125 125
         return id;

+ 1
- 1
src/com/dmdirc/commandline/CommandLineParser.java Переглянути файл

@@ -388,7 +388,7 @@ public class CommandLineParser {
388 388
             }
389 389
 
390 390
             System.out.print("   -" + arg[0] + needsArg);
391
-            System.out.println(" --" + desc + needsArg + " " + arg[2]);
391
+            System.out.println(" --" + desc + needsArg + ' ' + arg[2]);
392 392
             System.out.println();
393 393
         }
394 394
 

+ 1
- 1
src/com/dmdirc/commandparser/CommandArguments.java Переглянути файл

@@ -194,7 +194,7 @@ public class CommandArguments {
194 194
     public String getWordsAsString(final int start, final int end) {
195 195
         checkPositionIndex(start, end);
196 196
 
197
-        final Pattern pattern = Pattern.compile("(\\S+\\s+){" + start + "}"
197
+        final Pattern pattern = Pattern.compile("(\\S+\\s+){" + start + '}'
198 198
                 + "((\\S+\\s+){" + Math.max(0, end - start) + "}\\S+(\\s+$)?).*?");
199 199
         final Matcher matcher = pattern.matcher(line);
200 200
 

+ 1
- 1
src/com/dmdirc/commandparser/commands/PreviousCommand.java Переглянути файл

@@ -61,7 +61,7 @@ public final class PreviousCommand {
61 61
             return false;
62 62
         }
63 63
         final PreviousCommand other = (PreviousCommand) obj;
64
-        return Objects.equals(this.line, other.line) && this.time == other.time;
64
+        return Objects.equals(line, other.line) && time == other.time;
65 65
     }
66 66
 
67 67
 }

+ 2
- 2
src/com/dmdirc/commandparser/commands/flags/CommandFlag.java Переглянути файл

@@ -98,7 +98,7 @@ public class CommandFlag {
98 98
      * @param enabled The flags which will be enabled
99 99
      */
100 100
     public void addEnabled(final CommandFlag... enabled) {
101
-        this.enables.addAll(Arrays.asList(enabled));
101
+        enables.addAll(Arrays.asList(enabled));
102 102
     }
103 103
 
104 104
     /**
@@ -107,7 +107,7 @@ public class CommandFlag {
107 107
      * @param disabled The flags which will be disabled
108 108
      */
109 109
     public void addDisabled(final CommandFlag... disabled) {
110
-        this.disables.addAll(Arrays.asList(disabled));
110
+        disables.addAll(Arrays.asList(disabled));
111 111
     }
112 112
 
113 113
     /**

+ 1
- 1
src/com/dmdirc/commandparser/commands/server/Umode.java Переглянути файл

@@ -70,7 +70,7 @@ public class Umode extends Command {
70 70
 
71 71
         connection.getParser().get().sendRawMessage("MODE "
72 72
                 + connection.getParser().get().getLocalClient().getNickname()
73
-                + " " + args.getArgumentsAsString());
73
+                + ' ' + args.getArgumentsAsString());
74 74
     }
75 75
 
76 76
 }

+ 0
- 1
src/com/dmdirc/commandparser/parsers/QueryCommandParser.java Переглянути файл

@@ -23,7 +23,6 @@
23 23
 package com.dmdirc.commandparser.parsers;
24 24
 
25 25
 import com.dmdirc.DMDircMBassador;
26
-import com.dmdirc.Query;
27 26
 import com.dmdirc.commandparser.CommandArguments;
28 27
 import com.dmdirc.commandparser.CommandInfo;
29 28
 import com.dmdirc.commandparser.CommandType;

+ 3
- 3
src/com/dmdirc/config/ConfigFileBackedConfigProvider.java Переглянути файл

@@ -107,7 +107,7 @@ public class ConfigFileBackedConfigProvider implements ConfigProvider {
107 107
             final boolean forceDefault) throws IOException, InvalidIdentityFileException {
108 108
         this.identityManager = null;
109 109
         this.file = new ConfigFile(stream);
110
-        this.file.setAutomake(true);
110
+        file.setAutomake(true);
111 111
         initFile(forceDefault);
112 112
         myTarget = getTarget(forceDefault);
113 113
     }
@@ -123,7 +123,7 @@ public class ConfigFileBackedConfigProvider implements ConfigProvider {
123 123
             final ConfigFile configFile, final ConfigTarget target) {
124 124
         this.identityManager = identityManager;
125 125
         this.file = configFile;
126
-        this.file.setAutomake(true);
126
+        file.setAutomake(true);
127 127
         this.myTarget = target;
128 128
     }
129 129
 
@@ -181,7 +181,7 @@ public class ConfigFileBackedConfigProvider implements ConfigProvider {
181 181
     private void initFile(final boolean forceDefault)
182 182
             throws InvalidIdentityFileException, IOException {
183 183
         try {
184
-            this.file.read();
184
+            file.read();
185 185
         } catch (InvalidConfigFileException ex) {
186 186
             throw new InvalidIdentityFileException(ex);
187 187
         }

+ 3
- 3
src/com/dmdirc/config/prefs/PreferencesSetting.java Переглянути файл

@@ -33,6 +33,7 @@ import java.util.ArrayList;
33 33
 import java.util.Collection;
34 34
 import java.util.HashMap;
35 35
 import java.util.Map;
36
+import java.util.Objects;
36 37
 
37 38
 /**
38 39
  * Represents a single setting.
@@ -315,8 +316,7 @@ public class PreferencesSetting {
315 316
      * Dismisses changes to this setting.
316 317
      */
317 318
     public void dismiss() {
318
-        if (original != null && original.equals(value)
319
-                || original == null && value == null) {
319
+        if (Objects.equals(original, value)) {
320 320
             return;
321 321
         }
322 322
 
@@ -333,7 +333,7 @@ public class PreferencesSetting {
333 333
      * @return true iif the setting will be changed if saved
334 334
      */
335 335
     public boolean needsSaving() {
336
-        return (value == null || !value.equals(original))
336
+        return (!Objects.equals(value, original))
337 337
                 && (value != null || original != null)
338 338
                 && (validator == null || !validator.validate(value).isFailure());
339 339
     }

+ 0
- 1
src/com/dmdirc/interfaces/Connection.java Переглянути файл

@@ -32,7 +32,6 @@ import com.dmdirc.parser.interfaces.Parser;
32 32
 
33 33
 import java.net.URI;
34 34
 import java.util.Collection;
35
-import java.util.Date;
36 35
 import java.util.Optional;
37 36
 
38 37
 import javax.annotation.Nonnull;

+ 3
- 8
src/com/dmdirc/ui/core/about/CoreAboutDialogModel.java Переглянути файл

@@ -22,13 +22,11 @@
22 22
 
23 23
 package com.dmdirc.ui.core.about;
24 24
 
25
-import com.dmdirc.ClientModule.GlobalConfig;
26 25
 import com.dmdirc.DMDircMBassador;
27
-import com.dmdirc.commandline.CommandLineOptionsModule;
28 26
 import com.dmdirc.commandline.CommandLineOptionsModule.Directory;
27
+import com.dmdirc.commandline.CommandLineOptionsModule.DirectoryType;
29 28
 import com.dmdirc.commandline.CommandLineParser;
30 29
 import com.dmdirc.events.ClientInfoRequestEvent;
31
-import com.dmdirc.interfaces.config.AggregateConfigProvider;
32 30
 import com.dmdirc.interfaces.ui.AboutDialogModel;
33 31
 import com.dmdirc.plugins.PluginManager;
34 32
 import com.dmdirc.util.ClientInfo;
@@ -56,24 +54,21 @@ import org.slf4j.LoggerFactory;
56 54
 public class CoreAboutDialogModel implements AboutDialogModel {
57 55
 
58 56
     private static final Logger LOGGER = LoggerFactory.getLogger(CoreAboutDialogModel.class);
59
-    private final AggregateConfigProvider globalConfig;
60 57
     private final Path baseDirectory;
61 58
     private final ClientInfo clientInfo;
62 59
     private final DMDircMBassador eventBus;
63 60
     private final PluginManager pluginManager;
61
+    private final CommandLineParser commandLineParser;
64 62
     private String about;
65 63
     private List<Developer> mainDevelopers;
66 64
     private List<Developer> otherDevelopers;
67 65
     private List<InfoItem> info;
68 66
     private List<LicensedComponent> licences;
69
-    private CommandLineParser commandLineParser;
70 67
 
71 68
     @Inject
72
-    public CoreAboutDialogModel(@GlobalConfig final AggregateConfigProvider globalConfig,
73
-            @Directory(CommandLineOptionsModule.DirectoryType.BASE) final Path baseDirectory,
69
+    public CoreAboutDialogModel(@Directory(DirectoryType.BASE) final Path baseDirectory,
74 70
             final ClientInfo clientInfo, final DMDircMBassador eventBus,
75 71
             final PluginManager pluginManager, final CommandLineParser commandLineParser) {
76
-        this.globalConfig = globalConfig;
77 72
         this.baseDirectory = baseDirectory;
78 73
         this.clientInfo = clientInfo;
79 74
         this.eventBus = eventBus;

+ 2
- 2
src/com/dmdirc/ui/core/aliases/CoreAliasDialogModel.java Переглянути файл

@@ -148,14 +148,14 @@ public class CoreAliasDialogModel implements AliasDialogModel {
148 148
         final Alias alias = aliases.get(name);
149 149
         aliases.remove(name);
150 150
         if (getSelectedAlias().isPresent() && getSelectedAlias().get().equals(alias)) {
151
-            setSelectedAlias(Optional.<Alias>empty());
151
+            setSelectedAlias(Optional.empty());
152 152
         }
153 153
         listeners.getCallable(AliasDialogModelListener.class).aliasRemoved(alias);
154 154
     }
155 155
 
156 156
     @Override
157 157
     public void save() {
158
-        setSelectedAlias(Optional.<Alias>empty());
158
+        setSelectedAlias(Optional.empty());
159 159
         aliasManager.getAliases().forEach(aliasManager::removeAlias);
160 160
         aliases.values().forEach(aliasManager::addAlias);
161 161
     }

+ 7
- 7
src/com/dmdirc/ui/messages/Formatter.java Переглянути файл

@@ -66,26 +66,26 @@ public final class Formatter {
66 66
 
67 67
         final String res = config.hasOptionString("formatter", messageType)
68 68
                 ? config.getOption("formatter", messageType).replace("%-1$", "%"
69
-                        + arguments.length + "$") : null;
69
+                        + arguments.length + '$') : null;
70 70
 
71 71
         if (res == null) {
72
-            return "<No format string for message type " + messageType + ">";
72
+            return "<No format string for message type " + messageType + '>';
73 73
         } else {
74 74
             try {
75 75
                 final Object[] newArgs = castArguments(res, arguments);
76 76
                 return String.format(res.replaceAll("(%[0-9]+\\$)u", "$1s"), newArgs);
77 77
             } catch (IllegalFormatConversionException ex) {
78 78
                 return "<Invalid format string for message type " + messageType
79
-                        + "; Error: Illegal format conversion: " + ex.getMessage() + ">";
79
+                        + "; Error: Illegal format conversion: " + ex.getMessage() + '>';
80 80
             } catch (UnknownFormatConversionException ex) {
81 81
                 return "<Invalid format string for message type " + messageType
82
-                        + "; Error: Unknown format conversion: " + ex.getMessage() + ">";
82
+                        + "; Error: Unknown format conversion: " + ex.getMessage() + '>';
83 83
             } catch (MissingFormatArgumentException ex) {
84 84
                 return "<Invalid format string for message type " + messageType
85
-                        + "; Error: Missing format argument: " + ex.getMessage() + ">";
85
+                        + "; Error: Missing format argument: " + ex.getMessage() + '>';
86 86
             } catch (NumberFormatException ex) {
87 87
                 return "<Invalid format string for message type " + messageType
88
-                        + "; Error: Invalid number conversion: " + ex.getMessage() + ">";
88
+                        + "; Error: Invalid number conversion: " + ex.getMessage() + '>';
89 89
             }
90 90
         }
91 91
     }
@@ -181,7 +181,7 @@ public final class Formatter {
181 181
         final Character[] types = new Character[args.length];
182 182
 
183 183
         for (int i = 0; i < args.length; i++) {
184
-            final int index = format.indexOf("%" + (i + 1) + "$");
184
+            final int index = format.indexOf("%" + (i + 1) + '$');
185 185
 
186 186
             if (index > -1) {
187 187
                 types[i] = format.charAt(index + 3);

+ 2
- 2
src/com/dmdirc/ui/messages/IRCTextAttribute.java Переглянути файл

@@ -45,7 +45,7 @@ public final class IRCTextAttribute extends Attribute {
45 45
      */
46 46
     protected IRCTextAttribute(final String name) {
47 47
         super(name);
48
-        if (this.getClass() == IRCTextAttribute.class) {
48
+        if (getClass() == IRCTextAttribute.class) {
49 49
             INSTANCE_MAP.put(name, this);
50 50
         }
51 51
     }
@@ -60,7 +60,7 @@ public final class IRCTextAttribute extends Attribute {
60 60
      */
61 61
     @Override
62 62
     protected Object readResolve() throws InvalidObjectException {
63
-        if (this.getClass() != IRCTextAttribute.class) {
63
+        if (getClass() != IRCTextAttribute.class) {
64 64
             throw new InvalidObjectException("subclass didn't correctly implement readResolve");
65 65
         }
66 66
 

+ 6
- 6
src/com/dmdirc/updater/Version.java Переглянути файл

@@ -74,16 +74,16 @@ public class Version implements Comparable<Version> {
74 74
 
75 75
     @Override
76 76
     public int compareTo(@Nonnull final Version o) {
77
-        if (o.intVersion > Integer.MIN_VALUE && this.intVersion > Integer.MIN_VALUE) {
78
-            return this.intVersion - o.intVersion;
79
-        } else if (o.strVersion == null && this.strVersion == null) {
77
+        if (o.intVersion > Integer.MIN_VALUE && intVersion > Integer.MIN_VALUE) {
78
+            return intVersion - o.intVersion;
79
+        } else if (o.strVersion == null && strVersion == null) {
80 80
             return 0;
81
-        } else if (o.strVersion == null && this.strVersion != null) {
81
+        } else if (o.strVersion == null && strVersion != null) {
82 82
             return 1;
83
-        } else if (o.strVersion != null && this.strVersion == null) {
83
+        } else if (o.strVersion != null && strVersion == null) {
84 84
             return -1;
85 85
         } else {
86
-            final String[] myParts = this.strVersion.split("-");
86
+            final String[] myParts = strVersion.split("-");
87 87
             final String[] thParts = o.strVersion.split("-");
88 88
 
89 89
             final String[] myFirstParts = myParts[0].split("\\.|(?=a|b|rc|m)");

+ 4
- 7
src/com/dmdirc/updater/manager/DMDircUpdateManager.java Переглянути файл

@@ -70,13 +70,10 @@ public class DMDircUpdateManager extends CachingUpdateManagerImpl {
70 70
                 new LinkedBlockingQueue<>(), new NamedThreadFactory()),
71 71
                 consolidator, updatePolicy);
72 72
 
73
-        checkStrategies.forEach(DMDircUpdateManager.this::addCheckStrategy);
74
-
75
-        retrievalStrategies.forEach(DMDircUpdateManager.this::addRetrievalStrategy);
76
-
77
-        installationStrategies.forEach(DMDircUpdateManager.this::addInstallationStrategy);
78
-
79
-        components.forEach(DMDircUpdateManager.this::addComponent);
73
+        checkStrategies.forEach(this::addCheckStrategy);
74
+        retrievalStrategies.forEach(this::addRetrievalStrategy);
75
+        installationStrategies.forEach(this::addInstallationStrategy);
76
+        components.forEach(this::addComponent);
80 77
     }
81 78
 
82 79
     /**

+ 8
- 8
src/com/dmdirc/updater/manager/UpdateManagerImpl.java Переглянути файл

@@ -97,28 +97,28 @@ public class UpdateManagerImpl implements UpdateManager {
97 97
     @Override
98 98
     public void addCheckStrategy(final UpdateCheckStrategy strategy) {
99 99
         LOG.trace("Adding new check strategy: {}", strategy);
100
-        this.checkers.add(strategy);
100
+        checkers.add(strategy);
101 101
     }
102 102
 
103 103
     @Override
104 104
     public void addRetrievalStrategy(final UpdateRetrievalStrategy strategy) {
105 105
         LOG.trace("Adding new retrieval strategy: {}", strategy);
106 106
         strategy.addUpdateRetrievalListener(retrievalListener);
107
-        this.retrievers.add(strategy);
107
+        retrievers.add(strategy);
108 108
     }
109 109
 
110 110
     @Override
111 111
     public void addInstallationStrategy(final UpdateInstallationStrategy strategy) {
112 112
         LOG.trace("Adding new installation strategy: {}", strategy);
113 113
         strategy.addUpdateInstallationListener(installationListener);
114
-        this.installers.add(strategy);
114
+        installers.add(strategy);
115 115
     }
116 116
 
117 117
     @Override
118 118
     public void addComponent(final UpdateComponent component) {
119 119
         LOG.trace("Adding new component: {}", component);
120 120
         synchronized (componentsLock) {
121
-            this.components.put(component.getName(), component);
121
+            components.put(component.getName(), component);
122 122
         }
123 123
     }
124 124
 
@@ -126,17 +126,17 @@ public class UpdateManagerImpl implements UpdateManager {
126 126
     public void removeComponent(final UpdateComponent component) {
127 127
         LOG.trace("Removing component: {}", component);
128 128
         synchronized (componentsLock) {
129
-            this.components.remove(component.getName());
129
+            components.remove(component.getName());
130 130
         }
131 131
 
132
-        this.checkResults.remove(component);
133
-        this.retrievalResults.remove(component);
132
+        checkResults.remove(component);
133
+        retrievalResults.remove(component);
134 134
     }
135 135
 
136 136
     @Override
137 137
     public Collection<UpdateComponent> getComponents() {
138 138
         synchronized (componentsLock) {
139
-            return Collections.unmodifiableCollection(this.components.values());
139
+            return Collections.unmodifiableCollection(components.values());
140 140
         }
141 141
     }
142 142
 

+ 2
- 2
src/com/dmdirc/util/resourcemanager/ResourceManager.java Переглянути файл

@@ -90,7 +90,7 @@ public abstract class ResourceManager {
90 90
         } else if (url.startsWith("jar://") || url.startsWith("zip://")) {
91 91
             return new ZipResourceManager(url.substring(6));
92 92
         } else {
93
-            throw new IllegalArgumentException("Unknown resource manager type (" + url + ")");
93
+            throw new IllegalArgumentException("Unknown resource manager type (" + url + ')');
94 94
         }
95 95
     }
96 96
 
@@ -134,7 +134,7 @@ public abstract class ResourceManager {
134 134
 
135 135
         if (usePath && resourceName.indexOf('/') > -1) {
136 136
             newDir = new File(directory,
137
-                    resourceName.substring(0, resourceName.lastIndexOf('/')) + "/");
137
+                    resourceName.substring(0, resourceName.lastIndexOf('/')) + '/');
138 138
         } else {
139 139
             newDir = new File(directory);
140 140
         }

+ 2
- 2
src/com/dmdirc/util/resourcemanager/ZipResourceManager.java Переглянути файл

@@ -146,8 +146,8 @@ public final class ZipResourceManager extends ResourceManager {
146 146
     @Override
147 147
     public URL getResourceURL(final String resource) throws MalformedURLException {
148 148
         if (resourceExists(resource)) {
149
-            return new URL("jar:file:/" + zipFile.getName() + "!"
150
-                    + (resource.charAt(0) == '/' ? resource : "/" + resource));
149
+            return new URL("jar:file:/" + zipFile.getName() + '!'
150
+                    + (resource.charAt(0) == '/' ? resource : '/' + resource));
151 151
         } else {
152 152
             return null;
153 153
         }

+ 2
- 5
test/com/dmdirc/ui/core/about/CoreAboutDialogModelTest.java Переглянути файл

@@ -24,7 +24,6 @@ package com.dmdirc.ui.core.about;
24 24
 
25 25
 import com.dmdirc.DMDircMBassador;
26 26
 import com.dmdirc.commandline.CommandLineParser;
27
-import com.dmdirc.interfaces.config.AggregateConfigProvider;
28 27
 import com.dmdirc.plugins.PluginInfo;
29 28
 import com.dmdirc.plugins.PluginManager;
30 29
 import com.dmdirc.plugins.PluginMetaData;
@@ -51,7 +50,6 @@ import static org.mockito.Mockito.when;
51 50
 public class CoreAboutDialogModelTest {
52 51
 
53 52
     @Mock private ClientInfo clientInfo;
54
-    @Mock private AggregateConfigProvider globalConfig;
55 53
     @Mock private Path path;
56 54
     @Mock private DMDircMBassador eventBus;
57 55
     @Mock private PluginManager pluginManager;
@@ -69,7 +67,6 @@ public class CoreAboutDialogModelTest {
69 67
         when(clientInfo.getVersionInformation()).thenReturn("DMDirc Version");
70 68
         when(clientInfo.getOperatingSystemInformation()).thenReturn("OS Version");
71 69
         when(clientInfo.getJavaInformation()).thenReturn("Java Version");
72
-        when(globalConfig.getOption("identity", "modealiasversion")).thenReturn("ModeAlias Version");
73 70
         when(pluginManager.getPluginInfos()).thenReturn(Lists.newArrayList(pluginInfo1, pluginInfo2));
74 71
         when(pluginInfo1.getPath("/META-INF/licences/")).thenReturn(pluginPath1);
75 72
         when(pluginInfo2.getPath("/META-INF/licences/")).thenReturn(pluginPath2);
@@ -78,8 +75,8 @@ public class CoreAboutDialogModelTest {
78 75
         when(pluginMetaData1.getFriendlyName()).thenReturn("Plugin1");
79 76
         when(pluginMetaData2.getFriendlyName()).thenReturn("Plugin2");
80 77
         when(commandLineParser.getLauncherVersion()).thenReturn(Optional.of("Unknown"));
81
-        instance = new CoreAboutDialogModel(globalConfig, path, clientInfo, eventBus,
82
-                pluginManager, commandLineParser);
78
+        instance = new CoreAboutDialogModel(path, clientInfo, eventBus, pluginManager,
79
+                commandLineParser);
83 80
         instance.load();
84 81
     }
85 82
 

Завантаження…
Відмінити
Зберегти