瀏覽代碼

Tidying

Change-Id: I2ae082b9a0a6596615627debd052b80502b92c58
Reviewed-on: http://gerrit.dmdirc.com/3920
Reviewed-by: Greg Holmes <greg@dmdirc.com>
Automatic-Compile: DMDirc Build Manager
pull/1/head
Chris Smith 9 年之前
父節點
當前提交
df55470ea4

+ 2
- 2
src/com/dmdirc/actions/CoreActionComparison.java 查看文件

@@ -112,7 +112,7 @@ public enum CoreActionComparison implements ActionComparison {
112 112
     STRING_CONTAINS {
113 113
         @Override
114 114
         public boolean test(final Object arg1, final Object arg2) {
115
-            return ((String) arg1).contains((String) arg2);
115
+            return ((String) arg1).contains((CharSequence) arg2);
116 116
         }
117 117
 
118 118
         @Override
@@ -129,7 +129,7 @@ public enum CoreActionComparison implements ActionComparison {
129 129
     STRING_NCONTAINS {
130 130
         @Override
131 131
         public boolean test(final Object arg1, final Object arg2) {
132
-            return !((String) arg1).contains((String) arg2);
132
+            return !((String) arg1).contains((CharSequence) arg2);
133 133
         }
134 134
 
135 135
         @Override

+ 14
- 12
src/com/dmdirc/actions/CoreActionComponent.java 查看文件

@@ -26,6 +26,7 @@ import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27 27
 import com.dmdirc.Query;
28 28
 import com.dmdirc.interfaces.Connection;
29
+import com.dmdirc.interfaces.PrivateChat;
29 30
 import com.dmdirc.interfaces.actions.ActionComponent;
30 31
 import com.dmdirc.interfaces.config.ConfigProvider;
31 32
 import com.dmdirc.interfaces.ui.Window;
@@ -33,12 +34,13 @@ import com.dmdirc.logger.ErrorLevel;
33 34
 import com.dmdirc.logger.Logger;
34 35
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
35 36
 import com.dmdirc.parser.interfaces.ClientInfo;
36
-import com.dmdirc.util.colours.Colour;
37 37
 import com.dmdirc.ui.messages.Styliser;
38
+import com.dmdirc.util.colours.Colour;
38 39
 
40
+import java.awt.AWTKeyStroke;
41
+import java.awt.event.InputEvent;
39 42
 import java.awt.event.KeyEvent;
40 43
 import java.util.Calendar;
41
-import java.util.GregorianCalendar;
42 44
 
43 45
 import javax.swing.KeyStroke;
44 46
 
@@ -248,7 +250,7 @@ public enum CoreActionComponent implements ActionComponent {
248 250
         @Override
249 251
         public Object get(final Object arg) {
250 252
             // TODO: This should understand unset notifications
251
-            return ((Channel) arg).getNotification().or(Colour.BLACK);
253
+            return ((FrameContainer) arg).getNotification().or(Colour.BLACK);
252 254
         }
253 255
 
254 256
         @Override
@@ -450,7 +452,7 @@ public enum CoreActionComponent implements ActionComponent {
450 452
     STRING_LENGTH {
451 453
         @Override
452 454
         public Object get(final Object arg) {
453
-            return ((String) arg).length();
455
+            return ((CharSequence) arg).length();
454 456
         }
455 457
 
456 458
         @Override
@@ -496,7 +498,7 @@ public enum CoreActionComponent implements ActionComponent {
496 498
     CALENDAR_FULLSTRING {
497 499
         @Override
498 500
         public Object get(final Object arg) {
499
-            return ((GregorianCalendar) arg).getTime().toString();
501
+            return ((Calendar) arg).getTime().toString();
500 502
         }
501 503
 
502 504
         @Override
@@ -520,7 +522,7 @@ public enum CoreActionComponent implements ActionComponent {
520 522
     KEYEVENT_KEYNAME {
521 523
         @Override
522 524
         public Object get(final Object arg) {
523
-            return KeyEvent.getKeyText(((KeyStroke) arg).getKeyCode());
525
+            return KeyEvent.getKeyText(((AWTKeyStroke) arg).getKeyCode());
524 526
         }
525 527
 
526 528
         @Override
@@ -544,7 +546,7 @@ public enum CoreActionComponent implements ActionComponent {
544 546
     KEYEVENT_CTRLSTATE {
545 547
         @Override
546 548
         public Object get(final Object arg) {
547
-            return (((KeyStroke) arg).getModifiers() & KeyEvent.CTRL_DOWN_MASK) != 0;
549
+            return (((AWTKeyStroke) arg).getModifiers() & InputEvent.CTRL_DOWN_MASK) != 0;
548 550
         }
549 551
 
550 552
         @Override
@@ -568,7 +570,7 @@ public enum CoreActionComponent implements ActionComponent {
568 570
     KEYEVENT_SHIFTSTATE {
569 571
         @Override
570 572
         public Object get(final Object arg) {
571
-            return (((KeyStroke) arg).getModifiers() & KeyEvent.SHIFT_DOWN_MASK) != 0;
573
+            return (((AWTKeyStroke) arg).getModifiers() & InputEvent.SHIFT_DOWN_MASK) != 0;
572 574
         }
573 575
 
574 576
         @Override
@@ -592,7 +594,7 @@ public enum CoreActionComponent implements ActionComponent {
592 594
     KEYEVENT_ALTSTATE {
593 595
         @Override
594 596
         public Object get(final Object arg) {
595
-            return (((KeyStroke) arg).getModifiers() & KeyEvent.ALT_DOWN_MASK) != 0;
597
+            return (((AWTKeyStroke) arg).getModifiers() & InputEvent.ALT_DOWN_MASK) != 0;
596 598
         }
597 599
 
598 600
         @Override
@@ -614,7 +616,7 @@ public enum CoreActionComponent implements ActionComponent {
614 616
     QUERY_HOST {
615 617
         @Override
616 618
         public Object get(final Object arg) {
617
-            return ((Query) arg).getHost();
619
+            return ((PrivateChat) arg).getHost();
618 620
         }
619 621
 
620 622
         @Override
@@ -636,7 +638,7 @@ public enum CoreActionComponent implements ActionComponent {
636 638
     QUERY_NICK {
637 639
         @Override
638 640
         public Object get(final Object arg) {
639
-            return ((Query) arg).getName();
641
+            return ((FrameContainer) arg).getName();
640 642
         }
641 643
 
642 644
         @Override
@@ -661,7 +663,7 @@ public enum CoreActionComponent implements ActionComponent {
661 663
         @Override
662 664
         public Object get(final Object arg) {
663 665
             // TODO: This should understand unset notifications
664
-            return ((Query) arg).getNotification().or(Colour.BLACK);
666
+            return ((FrameContainer) arg).getNotification().or(Colour.BLACK);
665 667
         }
666 668
 
667 669
         @Override

+ 8
- 11
src/com/dmdirc/actions/wrappers/PerformWrapper.java 查看文件

@@ -114,7 +114,7 @@ public class PerformWrapper extends ActionGroup {
114 114
      *
115 115
      * @since 0.6.4
116 116
      */
117
-    public void setPerform(final PerformDescription perform, final String[] content) {
117
+    public void setPerform(final PerformDescription perform, final String... content) {
118 118
         synchronized (this) {
119 119
             Action action = getAction(perform.getType() == PerformType.NETWORK
120 120
                     ? CoreActionComponent.SERVER_NETWORK : CoreActionComponent.SERVER_NAME,
@@ -177,7 +177,7 @@ public class PerformWrapper extends ActionGroup {
177 177
      *
178 178
      * @since 0.6.4
179 179
      */
180
-    private static boolean isEmpty(final String[] perform) {
180
+    private static boolean isEmpty(final String... perform) {
181 181
         for (String part : perform) {
182 182
             if (part != null && !part.isEmpty()) {
183 183
                 return false;
@@ -195,7 +195,7 @@ public class PerformWrapper extends ActionGroup {
195 195
      * @since 0.6.3m2
196 196
      * @return True if the conditions are valid, false otherwise
197 197
      */
198
-    protected boolean checkConditions(final List<ActionCondition> conditions) {
198
+    protected boolean checkConditions(final Iterable<ActionCondition> conditions) {
199 199
         boolean target = false;
200 200
         boolean profile = false;
201 201
 
@@ -383,20 +383,17 @@ public class PerformWrapper extends ActionGroup {
383 383
 
384 384
             final PerformDescription other = (PerformDescription) obj;
385 385
 
386
-            if (this.type != other.type || !this.target.equals(other.target)) {
387
-                return false;
388
-            }
386
+            return !(type != other.type || !target.equals(other.target)) &&
387
+                    (profile == null ? other.profile == null : profile.equals(other.profile));
389 388
 
390
-            return !((this.profile == null) ? (other.profile != null)
391
-                    : !this.profile.equals(other.profile));
392 389
         }
393 390
 
394 391
         @Override
395 392
         public int hashCode() {
396 393
             int hash = 7;
397
-            hash = 89 * hash + (this.type != null ? this.type.hashCode() : 0);
398
-            hash = 89 * hash + (this.target != null ? this.target.hashCode() : 0);
399
-            hash = 89 * hash + (this.profile != null ? this.profile.hashCode() : 0);
394
+            hash = 89 * hash + (type != null ? type.hashCode() : 0);
395
+            hash = 89 * hash + target.hashCode();
396
+            hash = 89 * hash + (profile != null ? profile.hashCode() : 0);
400 397
             return hash;
401 398
         }
402 399
 

+ 2
- 2
src/com/dmdirc/commandparser/CommandManager.java 查看文件

@@ -131,7 +131,7 @@ public class CommandManager implements CommandController {
131 131
      * @since 0.6.3m1
132 132
      */
133 133
     private void registerCommand(final CommandInfo info, final Command command,
134
-            final List<? extends CommandParser> myParsers, final boolean register) {
134
+            final Iterable<? extends CommandParser> myParsers, final boolean register) {
135 135
         for (CommandParser parser : myParsers) {
136 136
             if (register) {
137 137
                 parser.registerCommand(command, info);
@@ -261,7 +261,7 @@ public class CommandManager implements CommandController {
261 261
         final Map<CommandInfo, Command> res = new HashMap<>();
262 262
 
263 263
         for (Map.Entry<CommandInfo, Command> entry : commands.entrySet()) {
264
-            if ((type == null || type.equals(entry.getKey().getType()))
264
+            if ((type == null || type == entry.getKey().getType())
265 265
                     && (name == null || name.equals(entry.getKey().getName()))) {
266 266
                 res.put(entry.getKey(), entry.getValue());
267 267
             }

+ 1
- 2
src/com/dmdirc/commandparser/commands/global/OpenWindow.java 查看文件

@@ -26,7 +26,6 @@ import com.dmdirc.ClientModule.GlobalConfig;
26 26
 import com.dmdirc.CustomWindow;
27 27
 import com.dmdirc.DMDircMBassador;
28 28
 import com.dmdirc.FrameContainer;
29
-import com.dmdirc.Server;
30 29
 import com.dmdirc.commandparser.BaseCommandInfo;
31 30
 import com.dmdirc.commandparser.CommandArguments;
32 31
 import com.dmdirc.commandparser.CommandInfo;
@@ -104,7 +103,7 @@ public class OpenWindow extends Command implements IntelligentCommand {
104 103
                 return;
105 104
             }
106 105
 
107
-            parent = (Server) origin.getConnection();
106
+            parent = (FrameContainer) origin.getConnection();
108 107
             start = 1;
109 108
         } else if (args.getArguments().length > 0 && "--child".equals(args.getArguments()[0])) {
110 109
             parent = origin;

+ 17
- 17
src/com/dmdirc/commandparser/commands/global/SetCommand.java 查看文件

@@ -24,7 +24,6 @@ package com.dmdirc.commandparser.commands.global;
24 24
 
25 25
 import com.dmdirc.Channel;
26 26
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Server;
28 27
 import com.dmdirc.commandparser.BaseCommandInfo;
29 28
 import com.dmdirc.commandparser.CommandArguments;
30 29
 import com.dmdirc.commandparser.CommandInfo;
@@ -41,6 +40,7 @@ import com.dmdirc.interfaces.config.AggregateConfigProvider;
41 40
 import com.dmdirc.interfaces.config.ConfigProvider;
42 41
 import com.dmdirc.interfaces.config.IdentityController;
43 42
 import com.dmdirc.interfaces.config.IdentityFactory;
43
+import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
44 44
 import com.dmdirc.ui.input.AdditionalTabTargets;
45 45
 
46 46
 import java.util.List;
@@ -120,7 +120,7 @@ public class SetCommand extends Command implements IntelligentCommand {
120 120
             }
121 121
 
122 122
             identity = origin.getConnection().getServerIdentity();
123
-            manager = ((Server) origin.getConnection()).getConfigManager();
123
+            manager = ((FrameContainer) origin.getConnection()).getConfigManager();
124 124
         }
125 125
 
126 126
         if (res.hasFlag(channelFlag)) {
@@ -201,7 +201,7 @@ public class SetCommand extends Command implements IntelligentCommand {
201 201
      * @param domain   The domain to be inspected
202 202
      */
203 203
     private void doOptionsList(final FrameContainer origin,
204
-            final boolean isSilent, final AggregateConfigProvider manager, final String domain) {
204
+            final boolean isSilent, final ReadOnlyConfigProvider manager, final String domain) {
205 205
         final StringBuilder output = new StringBuilder(24);
206 206
 
207 207
         output.append("Options in domain '");
@@ -234,13 +234,13 @@ public class SetCommand extends Command implements IntelligentCommand {
234 234
      * @param option   The name of the option
235 235
      */
236 236
     private void doShowOption(final FrameContainer origin,
237
-            final boolean isSilent, final AggregateConfigProvider manager,
237
+            final boolean isSilent, final ReadOnlyConfigProvider manager,
238 238
             final String domain, final String option) {
239 239
         if (manager.hasOptionString(domain, option)) {
240 240
             sendLine(origin, isSilent, FORMAT_OUTPUT, "The current value of "
241
-                    + domain + "." + option + " is: " + manager.getOption(domain, option));
241
+                    + domain + '.' + option + " is: " + manager.getOption(domain, option));
242 242
         } else {
243
-            sendLine(origin, isSilent, FORMAT_ERROR, "Option not found: " + domain + "." + option);
243
+            sendLine(origin, isSilent, FORMAT_ERROR, "Option not found: " + domain + '.' + option);
244 244
         }
245 245
     }
246 246
 
@@ -259,7 +259,7 @@ public class SetCommand extends Command implements IntelligentCommand {
259 259
             final String domain, final String option, final String newvalue) {
260 260
         identity.setOption(domain, option, newvalue);
261 261
 
262
-        sendLine(origin, isSilent, FORMAT_OUTPUT, domain + "." + option
262
+        sendLine(origin, isSilent, FORMAT_OUTPUT, domain + '.' + option
263 263
                 + " has been set to: " + newvalue);
264 264
     }
265 265
 
@@ -276,7 +276,7 @@ public class SetCommand extends Command implements IntelligentCommand {
276 276
      */
277 277
     private void doAppendOption(final FrameContainer origin,
278 278
             final boolean isSilent, final ConfigProvider identity,
279
-            final AggregateConfigProvider manager,
279
+            final ReadOnlyConfigProvider manager,
280 280
             final String domain, final String option, final String data) {
281 281
         doSetOption(origin, isSilent, identity, domain, option,
282 282
                 (manager.hasOptionString(domain, option)
@@ -297,7 +297,7 @@ public class SetCommand extends Command implements IntelligentCommand {
297 297
             final String option) {
298 298
         identity.unsetOption(domain, option);
299 299
 
300
-        sendLine(origin, isSilent, FORMAT_OUTPUT, domain + "." + option + " has been unset.");
300
+        sendLine(origin, isSilent, FORMAT_OUTPUT, domain + '.' + option + " has been unset.");
301 301
     }
302 302
 
303 303
     @Override
@@ -315,10 +315,10 @@ public class SetCommand extends Command implements IntelligentCommand {
315 315
             res.add("--channel");
316 316
             res.excludeAll();
317 317
         } else if (arg == 1 && previousArgs.size() >= 1) {
318
-            if (previousArgs.get(0).equalsIgnoreCase("--unset")
319
-                    || previousArgs.get(0).equalsIgnoreCase("--append")
320
-                    || previousArgs.get(0).equalsIgnoreCase("--server")
321
-                    || previousArgs.get(0).equalsIgnoreCase("--channel")) {
318
+            if ("--unset".equalsIgnoreCase(previousArgs.get(0))
319
+                    || "--append".equalsIgnoreCase(previousArgs.get(0))
320
+                    || "--server".equalsIgnoreCase(previousArgs.get(0))
321
+                    || "--channel".equalsIgnoreCase(previousArgs.get(0))) {
322 322
                 res.addAll(context.getWindow().getConfigManager()
323 323
                         .getDomains());
324 324
             } else {
@@ -326,10 +326,10 @@ public class SetCommand extends Command implements IntelligentCommand {
326 326
                         .getOptions(previousArgs.get(0)).keySet());
327 327
             }
328 328
             res.excludeAll();
329
-        } else if (arg == 2 && (previousArgs.get(0).equalsIgnoreCase("--unset")
330
-                || previousArgs.get(0).equalsIgnoreCase("--append")
331
-                || previousArgs.get(0).equalsIgnoreCase("--server")
332
-                || previousArgs.get(0).equalsIgnoreCase("--channel"))) {
329
+        } else if (arg == 2 && ("--unset".equalsIgnoreCase(previousArgs.get(0))
330
+                || "--append".equalsIgnoreCase(previousArgs.get(0))
331
+                || "--server".equalsIgnoreCase(previousArgs.get(0))
332
+                || "--channel".equalsIgnoreCase(previousArgs.get(0)))) {
333 333
             res.addAll(context.getWindow().getConfigManager()
334 334
                     .getOptions(previousArgs.get(1)).keySet());
335 335
             res.excludeAll();

+ 2
- 2
src/com/dmdirc/commandparser/commands/server/OpenQuery.java 查看文件

@@ -77,9 +77,9 @@ public class OpenQuery extends Command implements IntelligentCommand,
77 77
                     + "with a channel; maybe you meant " + Styliser.CODE_FIXED
78 78
                     + Styliser.CODE_BOLD
79 79
                     + getController().getCommandChar()
80
-                    + (args.getArguments().length > 1 ? "msg" : "join") + " "
80
+                    + (args.getArguments().length > 1 ? "msg" : "join") + ' '
81 81
                     + args.getArgumentsAsString()
82
-                    + Styliser.CODE_BOLD + Styliser.CODE_FIXED + "?");
82
+                    + Styliser.CODE_BOLD + Styliser.CODE_FIXED + '?');
83 83
             return;
84 84
         }
85 85
 

+ 1
- 1
src/com/dmdirc/config/ConfigTarget.java 查看文件

@@ -227,7 +227,7 @@ public class ConfigTarget implements Comparable<ConfigTarget>, Serializable {
227 227
      */
228 228
     @Override
229 229
     public int compareTo(@Nonnull final ConfigTarget target) {
230
-        if (type.equals(target.getType())) {
230
+        if (type == target.getType()) {
231 231
             return target.getOrder() - order;
232 232
         } else {
233 233
             return type.compareTo(target.getType());

+ 11
- 11
src/com/dmdirc/config/prefs/PreferencesSetting.java 查看文件

@@ -22,14 +22,14 @@
22 22
 
23 23
 package com.dmdirc.config.prefs;
24 24
 
25
-import com.dmdirc.interfaces.config.AggregateConfigProvider;
26 25
 import com.dmdirc.interfaces.config.ConfigProvider;
26
+import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
27 27
 import com.dmdirc.util.validators.PermissiveValidator;
28 28
 import com.dmdirc.util.validators.Validator;
29 29
 
30 30
 import java.util.ArrayList;
31
+import java.util.Collection;
31 32
 import java.util.HashMap;
32
-import java.util.List;
33 33
 import java.util.Map;
34 34
 
35 35
 /**
@@ -58,7 +58,7 @@ public class PreferencesSetting {
58 58
     /** The original value of this setting. */
59 59
     private String original;
60 60
     /** A list of change listeners. */
61
-    private final List<SettingChangeListener> listeners = new ArrayList<>();
61
+    private final Collection<SettingChangeListener> listeners = new ArrayList<>();
62 62
     /** Identity to save settings to. */
63 63
     private final ConfigProvider identity;
64 64
 
@@ -77,8 +77,8 @@ public class PreferencesSetting {
77 77
     public PreferencesSetting(final PreferencesType type,
78 78
             final Validator<String> validator, final String domain,
79 79
             final String option, final String title, final String helptext,
80
-            final AggregateConfigProvider configManager, final ConfigProvider identity) {
81
-        if (PreferencesType.MULTICHOICE.equals(type)) {
80
+            final ReadOnlyConfigProvider configManager, final ConfigProvider identity) {
81
+        if (PreferencesType.MULTICHOICE == type) {
82 82
             throw new IllegalArgumentException("Multi-choice preferences must "
83 83
                     + "have their options specified.");
84 84
         }
@@ -110,8 +110,8 @@ public class PreferencesSetting {
110 110
      */
111 111
     public PreferencesSetting(final PreferencesType type, final String domain,
112 112
             final String option, final String title, final String helptext,
113
-            final AggregateConfigProvider configManager, final ConfigProvider identity) {
114
-        if (PreferencesType.MULTICHOICE.equals(type)) {
113
+            final ReadOnlyConfigProvider configManager, final ConfigProvider identity) {
114
+        if (PreferencesType.MULTICHOICE == type) {
115 115
             throw new IllegalArgumentException("Multi-choice preferences must "
116 116
                     + "have their options specified.");
117 117
         }
@@ -143,7 +143,7 @@ public class PreferencesSetting {
143 143
     public PreferencesSetting(final String domain, final String option,
144 144
             final String title, final String helptext,
145 145
             final Map<String, String> options,
146
-            final AggregateConfigProvider configManager, final ConfigProvider identity) {
146
+            final ReadOnlyConfigProvider configManager, final ConfigProvider identity) {
147 147
         this.type = PreferencesType.MULTICHOICE;
148 148
         this.comboOptions = new HashMap<>(options);
149 149
         this.validator = new PermissiveValidator<>();
@@ -157,7 +157,7 @@ public class PreferencesSetting {
157 157
         original = value;
158 158
 
159 159
         if (!comboOptions.containsKey(value)) {
160
-            comboOptions.put(value, "Current (" + value + ")");
160
+            comboOptions.put(value, "Current (" + value + ')');
161 161
         }
162 162
     }
163 163
 
@@ -255,8 +255,8 @@ public class PreferencesSetting {
255 255
      * Dismisses changes to this setting.
256 256
      */
257 257
     public void dismiss() {
258
-        if ((original != null && original.equals(value))
259
-                || (original == null && value == null)) {
258
+        if (original != null && original.equals(value)
259
+                || original == null && value == null) {
260 260
             return;
261 261
         }
262 262
 

+ 1
- 1
src/com/dmdirc/interfaces/ui/SearchBar.java 查看文件

@@ -28,7 +28,7 @@ package com.dmdirc.interfaces.ui;
28 28
 public interface SearchBar {
29 29
 
30 30
     /** Direction used for searching. */
31
-    public enum Direction {
31
+    enum Direction {
32 32
 
33 33
         /** Move up through the document. */
34 34
         UP,

+ 2
- 6
src/com/dmdirc/logger/ErrorManager.java 查看文件

@@ -211,15 +211,11 @@ public class ErrorManager implements ConfigChangeListener {
211 211
             final boolean appError,
212 212
             final boolean canReport) {
213 213
         final boolean dupe = addError(error);
214
-        if (error.getLevel().equals(ErrorLevel.FATAL)) {
214
+        if (error.getLevel() == ErrorLevel.FATAL) {
215 215
             if (dupe) {
216 216
                 error.setReportStatus(ErrorReportStatus.NOT_APPLICABLE);
217 217
             }
218
-        } else if (!canReport || (appError && !error.isValidSource())) {
219
-            error.setReportStatus(ErrorReportStatus.NOT_APPLICABLE);
220
-        } else if (!appError) {
221
-            error.setReportStatus(ErrorReportStatus.NOT_APPLICABLE);
222
-        } else if (dupe) {
218
+        } else if (!canReport || appError && !error.isValidSource() || !appError || dupe) {
223 219
             error.setReportStatus(ErrorReportStatus.NOT_APPLICABLE);
224 220
         } else if (sendReports) {
225 221
             sendError(error);

+ 4
- 4
src/com/dmdirc/logger/ProgramError.java 查看文件

@@ -184,7 +184,7 @@ public final class ProgramError implements Serializable {
184 184
      * @param newStatus new ErrorReportStatus for the error
185 185
      */
186 186
     public void setReportStatus(final ErrorReportStatus newStatus) {
187
-        if (newStatus != null && !reportStatus.equals(newStatus)) {
187
+        if (newStatus != null && reportStatus != newStatus) {
188 188
             reportStatus = newStatus;
189 189
             ErrorManager.getErrorManager().fireErrorStatusChanged(this);
190 190
 
@@ -246,7 +246,7 @@ public final class ProgramError implements Serializable {
246 246
         if (errorFile.exists()) {
247 247
             boolean rename = false;
248 248
             for (int i = 0; !rename; i++) {
249
-                rename = errorFile.renameTo(new File(errorDir, logName + "-" + i + ".log"));
249
+                rename = errorFile.renameTo(new File(errorDir, logName + '-' + i + ".log"));
250 250
             }
251 251
         }
252 252
 
@@ -338,7 +338,7 @@ public final class ProgramError implements Serializable {
338 338
             return "1 occurrence on " + format.format(getDate());
339 339
         } else {
340 340
             return count.get() + " occurrences between " + format.format(
341
-                    getDate()) + " and " + format.format(getLastDate()) + ".";
341
+                    getDate()) + " and " + format.format(getLastDate()) + '.';
342 342
         }
343 343
     }
344 344
 
@@ -361,7 +361,7 @@ public final class ProgramError implements Serializable {
361 361
     @Override
362 362
     public String toString() {
363 363
         return "ID" + id + " Level: " + getLevel() + " Status: " + getReportStatus()
364
-                + " Message: '" + getMessage() + "'";
364
+                + " Message: '" + getMessage() + '\'';
365 365
     }
366 366
 
367 367
     @Override

+ 17
- 15
test/com/dmdirc/actions/ActionComponentChainTest.java 查看文件

@@ -23,6 +23,7 @@
23 23
 package com.dmdirc.actions;
24 24
 
25 25
 import com.dmdirc.Server;
26
+import com.dmdirc.interfaces.actions.ActionComponent;
26 27
 
27 28
 import org.junit.Before;
28 29
 import org.junit.Test;
@@ -61,7 +62,7 @@ public class ActionComponentChainTest {
61 62
     @Test
62 63
     public void testSingle() {
63 64
         final ActionComponentChain chain = new ActionComponentChain(String.class, "STRING_STRING", actionManager);
64
-        assertEquals(chain.get("foo bar baz"), "foo bar baz");
65
+        assertEquals("foo bar baz", chain.get("foo bar baz"));
65 66
         assertEquals("STRING_STRING", chain.toString());
66 67
     }
67 68
 
@@ -69,7 +70,7 @@ public class ActionComponentChainTest {
69 70
     public void testDouble() {
70 71
         final ActionComponentChain chain = new ActionComponentChain(String.class,
71 72
                 "STRING_STRING.STRING_STRING", actionManager);
72
-        assertEquals(chain.get("foo bar baz"), "foo bar baz");
73
+        assertEquals("foo bar baz", chain.get("foo bar baz"));
73 74
         assertEquals("STRING_STRING.STRING_STRING", chain.toString());
74 75
     }
75 76
 
@@ -90,66 +91,67 @@ public class ActionComponentChainTest {
90 91
 
91 92
     @Test
92 93
     public void testAppliesTo() {
93
-        final ActionComponentChain chain = new ActionComponentChain(String.class,
94
+        final ActionComponent chain = new ActionComponentChain(String.class,
94 95
                 "STRING_STRING.STRING_STRING.STRING_LENGTH", actionManager);
95
-        assertEquals(String.class, chain.appliesTo());
96
+        assertSame(String.class, chain.appliesTo());
96 97
     }
97 98
 
98 99
     @Test
99 100
     public void testGetType() {
100
-        final ActionComponentChain chain = new ActionComponentChain(String.class,
101
+        final ActionComponent chain = new ActionComponentChain(String.class,
101 102
                 "STRING_STRING.STRING_STRING.STRING_LENGTH", actionManager);
102
-        assertEquals(Integer.class, chain.getType());
103
+        assertSame(Integer.class, chain.getType());
103 104
     }
104 105
 
105 106
     @Test
106 107
     public void testGetName() {
107
-        final ActionComponentChain chain = new ActionComponentChain(String.class,
108
+        final ActionComponent chain = new ActionComponentChain(String.class,
108 109
                 "STRING_STRING.STRING_STRING.STRING_LENGTH", actionManager);
109 110
 
110
-        assertTrue(chain.getName().indexOf(CoreActionComponent.STRING_STRING.getName()) > -1);
111
-        assertTrue(chain.getName().indexOf(CoreActionComponent.STRING_LENGTH.getName()) > -1);
111
+        assertTrue(chain.getName().contains(CoreActionComponent.STRING_STRING.getName()));
112
+        assertTrue(chain.getName().contains(CoreActionComponent.STRING_LENGTH.getName()));
112 113
     }
113 114
 
114 115
     @Test(expected=AssertionError.class)
115 116
     public void testEmptyAppliesTo() {
116
-        final ActionComponentChain chain = new ActionComponentChain(String.class, "", actionManager);
117
+        final ActionComponent chain = new ActionComponentChain(String.class, "", actionManager);
117 118
         chain.appliesTo();
118 119
     }
119 120
 
120 121
     @Test(expected=AssertionError.class)
121 122
     public void testEmptyGetType() {
122
-        final ActionComponentChain chain = new ActionComponentChain(String.class, "", actionManager);
123
+        final ActionComponent chain = new ActionComponentChain(String.class, "", actionManager);
123 124
         chain.getType();
124 125
     }
125 126
 
126 127
     @Test(expected=AssertionError.class)
127 128
     public void testEmptyGetName() {
128
-        final ActionComponentChain chain = new ActionComponentChain(String.class, "", actionManager);
129
+        final ActionComponent chain = new ActionComponentChain(String.class, "", actionManager);
129 130
         chain.getName();
130 131
     }
131 132
 
133
+    @SuppressWarnings("ResultOfMethodCallIgnored")
132 134
     @Test(expected=AssertionError.class)
133 135
     public void testEmptyToString() {
134 136
         final ActionComponentChain chain = new ActionComponentChain(String.class, "", actionManager);
135 137
         chain.toString();
136 138
     }
137 139
 
138
-    @Test()
140
+    @Test
139 141
     public void testRequiresConnection1() {
140 142
         final ActionComponentChain chain = new ActionComponentChain(Server.class,
141 143
                 "SERVER_NETWORK", actionManager);
142 144
         assertTrue(chain.requiresConnection());
143 145
     }
144 146
 
145
-    @Test()
147
+    @Test
146 148
     public void testRequiresConnection2() {
147 149
         final ActionComponentChain chain = new ActionComponentChain(Server.class,
148 150
                 "SERVER_NETWORK.STRING_LENGTH", actionManager);
149 151
         assertTrue(chain.requiresConnection());
150 152
     }
151 153
 
152
-    @Test()
154
+    @Test
153 155
     public void testRequiresConnection3() {
154 156
         final ActionComponentChain chain = new ActionComponentChain(Server.class,
155 157
                 "SERVER_NAME.STRING_LENGTH", actionManager);

+ 12
- 16
test/com/dmdirc/config/prefs/PreferencesDialogModelTest.java 查看文件

@@ -22,9 +22,9 @@
22 22
 
23 23
 package com.dmdirc.config.prefs;
24 24
 
25
+import com.dmdirc.DMDircMBassador;
25 26
 import com.dmdirc.events.ClientPrefsClosedEvent;
26 27
 import com.dmdirc.events.ClientPrefsOpenedEvent;
27
-import com.dmdirc.interfaces.ActionListener;
28 28
 import com.dmdirc.interfaces.config.AggregateConfigProvider;
29 29
 import com.dmdirc.plugins.PluginManager;
30 30
 import com.dmdirc.plugins.Service;
@@ -38,8 +38,6 @@ import org.junit.runner.RunWith;
38 38
 import org.mockito.Mock;
39 39
 import org.mockito.runners.MockitoJUnitRunner;
40 40
 
41
-import com.dmdirc.DMDircMBassador;
42
-
43 41
 import static org.junit.Assert.assertFalse;
44 42
 import static org.junit.Assert.assertNotNull;
45 43
 import static org.junit.Assert.assertNull;
@@ -67,7 +65,7 @@ public class PreferencesDialogModelTest {
67 65
 
68 66
     @Test
69 67
     public void testDefaults() {
70
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
68
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
71 69
         when(cm.getOption("domain", "option")).thenReturn("fallback");
72 70
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
73 71
                 null, null, cm, null, pluginManager, eventBus);
@@ -83,7 +81,7 @@ public class PreferencesDialogModelTest {
83 81
 
84 82
     @Test
85 83
     public void testDismiss() {
86
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
84
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
87 85
         when(cm.getOption("domain", "option")).thenReturn("fallback");
88 86
         final PreferencesCategory category = mock(PreferencesCategory.class);
89 87
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
@@ -98,7 +96,7 @@ public class PreferencesDialogModelTest {
98 96
     public void testSaveNoRestart() {
99 97
         final PreferencesCategory category = mock(PreferencesCategory.class);
100 98
         when(category.save()).thenReturn(false);
101
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
99
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
102 100
         when(cm.getOption("domain", "option")).thenReturn("fallback");
103 101
 
104 102
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
@@ -113,7 +111,7 @@ public class PreferencesDialogModelTest {
113 111
     public void testSaveRestart() {
114 112
         final PreferencesCategory category = mock(PreferencesCategory.class);
115 113
         when(category.save()).thenReturn(true);
116
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
114
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
117 115
         when(cm.getOption("domain", "option")).thenReturn("fallback");
118 116
 
119 117
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
@@ -126,7 +124,7 @@ public class PreferencesDialogModelTest {
126 124
 
127 125
     @Test
128 126
     public void testGetCategory() {
129
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
127
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
130 128
         when(cm.getOption("domain", "option")).thenReturn("fallback");
131 129
 
132 130
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
@@ -136,7 +134,7 @@ public class PreferencesDialogModelTest {
136 134
 
137 135
     @Test
138 136
     public void testGetCategories() {
139
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
137
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
140 138
         when(cm.getOption("domain", "option")).thenReturn("fallback");
141 139
 
142 140
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
@@ -151,7 +149,7 @@ public class PreferencesDialogModelTest {
151 149
 
152 150
     @Test
153 151
     public void testSaveListener() {
154
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
152
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
155 153
         when(cm.getOption("domain", "option")).thenReturn("fallback");
156 154
 
157 155
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
@@ -165,19 +163,17 @@ public class PreferencesDialogModelTest {
165 163
 
166 164
     @Test
167 165
     public void testOpenAction() {
168
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
166
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
169 167
         when(cm.getOption("domain", "option")).thenReturn("fallback");
170 168
 
171
-        final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
172
-                null, null, cm, null, pluginManager, eventBus);
169
+        new PreferencesDialogModel(null, null, null, null, cm, null, pluginManager, eventBus);
173 170
 
174 171
         verify(eventBus).publishAsync(isA(ClientPrefsOpenedEvent.class));
175 172
     }
176 173
 
177 174
     @Test
178 175
     public void testCloseAction() {
179
-        final ActionListener tal = mock(ActionListener.class);
180
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
176
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
181 177
         when(cm.getOption("domain", "option")).thenReturn("fallback");
182 178
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,
183 179
                 null, null, cm, null, pluginManager, eventBus);
@@ -188,7 +184,7 @@ public class PreferencesDialogModelTest {
188 184
 
189 185
     @Test
190 186
     public void testCategoryObjectSaveListeners() {
191
-        AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
187
+        final AggregateConfigProvider cm = mock(AggregateConfigProvider.class);
192 188
         when(cm.getOption("domain", "option")).thenReturn("fallback");
193 189
 
194 190
         final PreferencesDialogModel pm = new PreferencesDialogModel(null, null,

Loading…
取消
儲存