Browse Source

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 years ago
parent
commit
df55470ea4

+ 2
- 2
src/com/dmdirc/actions/CoreActionComparison.java View File

112
     STRING_CONTAINS {
112
     STRING_CONTAINS {
113
         @Override
113
         @Override
114
         public boolean test(final Object arg1, final Object arg2) {
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
         @Override
118
         @Override
129
     STRING_NCONTAINS {
129
     STRING_NCONTAINS {
130
         @Override
130
         @Override
131
         public boolean test(final Object arg1, final Object arg2) {
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
         @Override
135
         @Override

+ 14
- 12
src/com/dmdirc/actions/CoreActionComponent.java View File

26
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.FrameContainer;
27
 import com.dmdirc.Query;
27
 import com.dmdirc.Query;
28
 import com.dmdirc.interfaces.Connection;
28
 import com.dmdirc.interfaces.Connection;
29
+import com.dmdirc.interfaces.PrivateChat;
29
 import com.dmdirc.interfaces.actions.ActionComponent;
30
 import com.dmdirc.interfaces.actions.ActionComponent;
30
 import com.dmdirc.interfaces.config.ConfigProvider;
31
 import com.dmdirc.interfaces.config.ConfigProvider;
31
 import com.dmdirc.interfaces.ui.Window;
32
 import com.dmdirc.interfaces.ui.Window;
33
 import com.dmdirc.logger.Logger;
34
 import com.dmdirc.logger.Logger;
34
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
35
 import com.dmdirc.parser.interfaces.ChannelClientInfo;
35
 import com.dmdirc.parser.interfaces.ClientInfo;
36
 import com.dmdirc.parser.interfaces.ClientInfo;
36
-import com.dmdirc.util.colours.Colour;
37
 import com.dmdirc.ui.messages.Styliser;
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
 import java.awt.event.KeyEvent;
42
 import java.awt.event.KeyEvent;
40
 import java.util.Calendar;
43
 import java.util.Calendar;
41
-import java.util.GregorianCalendar;
42
 
44
 
43
 import javax.swing.KeyStroke;
45
 import javax.swing.KeyStroke;
44
 
46
 
248
         @Override
250
         @Override
249
         public Object get(final Object arg) {
251
         public Object get(final Object arg) {
250
             // TODO: This should understand unset notifications
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
         @Override
256
         @Override
450
     STRING_LENGTH {
452
     STRING_LENGTH {
451
         @Override
453
         @Override
452
         public Object get(final Object arg) {
454
         public Object get(final Object arg) {
453
-            return ((String) arg).length();
455
+            return ((CharSequence) arg).length();
454
         }
456
         }
455
 
457
 
456
         @Override
458
         @Override
496
     CALENDAR_FULLSTRING {
498
     CALENDAR_FULLSTRING {
497
         @Override
499
         @Override
498
         public Object get(final Object arg) {
500
         public Object get(final Object arg) {
499
-            return ((GregorianCalendar) arg).getTime().toString();
501
+            return ((Calendar) arg).getTime().toString();
500
         }
502
         }
501
 
503
 
502
         @Override
504
         @Override
520
     KEYEVENT_KEYNAME {
522
     KEYEVENT_KEYNAME {
521
         @Override
523
         @Override
522
         public Object get(final Object arg) {
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
         @Override
528
         @Override
544
     KEYEVENT_CTRLSTATE {
546
     KEYEVENT_CTRLSTATE {
545
         @Override
547
         @Override
546
         public Object get(final Object arg) {
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
         @Override
552
         @Override
568
     KEYEVENT_SHIFTSTATE {
570
     KEYEVENT_SHIFTSTATE {
569
         @Override
571
         @Override
570
         public Object get(final Object arg) {
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
         @Override
576
         @Override
592
     KEYEVENT_ALTSTATE {
594
     KEYEVENT_ALTSTATE {
593
         @Override
595
         @Override
594
         public Object get(final Object arg) {
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
         @Override
600
         @Override
614
     QUERY_HOST {
616
     QUERY_HOST {
615
         @Override
617
         @Override
616
         public Object get(final Object arg) {
618
         public Object get(final Object arg) {
617
-            return ((Query) arg).getHost();
619
+            return ((PrivateChat) arg).getHost();
618
         }
620
         }
619
 
621
 
620
         @Override
622
         @Override
636
     QUERY_NICK {
638
     QUERY_NICK {
637
         @Override
639
         @Override
638
         public Object get(final Object arg) {
640
         public Object get(final Object arg) {
639
-            return ((Query) arg).getName();
641
+            return ((FrameContainer) arg).getName();
640
         }
642
         }
641
 
643
 
642
         @Override
644
         @Override
661
         @Override
663
         @Override
662
         public Object get(final Object arg) {
664
         public Object get(final Object arg) {
663
             // TODO: This should understand unset notifications
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
         @Override
669
         @Override

+ 8
- 11
src/com/dmdirc/actions/wrappers/PerformWrapper.java View File

114
      *
114
      *
115
      * @since 0.6.4
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
         synchronized (this) {
118
         synchronized (this) {
119
             Action action = getAction(perform.getType() == PerformType.NETWORK
119
             Action action = getAction(perform.getType() == PerformType.NETWORK
120
                     ? CoreActionComponent.SERVER_NETWORK : CoreActionComponent.SERVER_NAME,
120
                     ? CoreActionComponent.SERVER_NETWORK : CoreActionComponent.SERVER_NAME,
177
      *
177
      *
178
      * @since 0.6.4
178
      * @since 0.6.4
179
      */
179
      */
180
-    private static boolean isEmpty(final String[] perform) {
180
+    private static boolean isEmpty(final String... perform) {
181
         for (String part : perform) {
181
         for (String part : perform) {
182
             if (part != null && !part.isEmpty()) {
182
             if (part != null && !part.isEmpty()) {
183
                 return false;
183
                 return false;
195
      * @since 0.6.3m2
195
      * @since 0.6.3m2
196
      * @return True if the conditions are valid, false otherwise
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
         boolean target = false;
199
         boolean target = false;
200
         boolean profile = false;
200
         boolean profile = false;
201
 
201
 
383
 
383
 
384
             final PerformDescription other = (PerformDescription) obj;
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
         @Override
391
         @Override
395
         public int hashCode() {
392
         public int hashCode() {
396
             int hash = 7;
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
             return hash;
397
             return hash;
401
         }
398
         }
402
 
399
 

+ 2
- 2
src/com/dmdirc/commandparser/CommandManager.java View File

131
      * @since 0.6.3m1
131
      * @since 0.6.3m1
132
      */
132
      */
133
     private void registerCommand(final CommandInfo info, final Command command,
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
         for (CommandParser parser : myParsers) {
135
         for (CommandParser parser : myParsers) {
136
             if (register) {
136
             if (register) {
137
                 parser.registerCommand(command, info);
137
                 parser.registerCommand(command, info);
261
         final Map<CommandInfo, Command> res = new HashMap<>();
261
         final Map<CommandInfo, Command> res = new HashMap<>();
262
 
262
 
263
         for (Map.Entry<CommandInfo, Command> entry : commands.entrySet()) {
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
                     && (name == null || name.equals(entry.getKey().getName()))) {
265
                     && (name == null || name.equals(entry.getKey().getName()))) {
266
                 res.put(entry.getKey(), entry.getValue());
266
                 res.put(entry.getKey(), entry.getValue());
267
             }
267
             }

+ 1
- 2
src/com/dmdirc/commandparser/commands/global/OpenWindow.java View File

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

+ 17
- 17
src/com/dmdirc/commandparser/commands/global/SetCommand.java View File

24
 
24
 
25
 import com.dmdirc.Channel;
25
 import com.dmdirc.Channel;
26
 import com.dmdirc.FrameContainer;
26
 import com.dmdirc.FrameContainer;
27
-import com.dmdirc.Server;
28
 import com.dmdirc.commandparser.BaseCommandInfo;
27
 import com.dmdirc.commandparser.BaseCommandInfo;
29
 import com.dmdirc.commandparser.CommandArguments;
28
 import com.dmdirc.commandparser.CommandArguments;
30
 import com.dmdirc.commandparser.CommandInfo;
29
 import com.dmdirc.commandparser.CommandInfo;
41
 import com.dmdirc.interfaces.config.ConfigProvider;
40
 import com.dmdirc.interfaces.config.ConfigProvider;
42
 import com.dmdirc.interfaces.config.IdentityController;
41
 import com.dmdirc.interfaces.config.IdentityController;
43
 import com.dmdirc.interfaces.config.IdentityFactory;
42
 import com.dmdirc.interfaces.config.IdentityFactory;
43
+import com.dmdirc.interfaces.config.ReadOnlyConfigProvider;
44
 import com.dmdirc.ui.input.AdditionalTabTargets;
44
 import com.dmdirc.ui.input.AdditionalTabTargets;
45
 
45
 
46
 import java.util.List;
46
 import java.util.List;
120
             }
120
             }
121
 
121
 
122
             identity = origin.getConnection().getServerIdentity();
122
             identity = origin.getConnection().getServerIdentity();
123
-            manager = ((Server) origin.getConnection()).getConfigManager();
123
+            manager = ((FrameContainer) origin.getConnection()).getConfigManager();
124
         }
124
         }
125
 
125
 
126
         if (res.hasFlag(channelFlag)) {
126
         if (res.hasFlag(channelFlag)) {
201
      * @param domain   The domain to be inspected
201
      * @param domain   The domain to be inspected
202
      */
202
      */
203
     private void doOptionsList(final FrameContainer origin,
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
         final StringBuilder output = new StringBuilder(24);
205
         final StringBuilder output = new StringBuilder(24);
206
 
206
 
207
         output.append("Options in domain '");
207
         output.append("Options in domain '");
234
      * @param option   The name of the option
234
      * @param option   The name of the option
235
      */
235
      */
236
     private void doShowOption(final FrameContainer origin,
236
     private void doShowOption(final FrameContainer origin,
237
-            final boolean isSilent, final AggregateConfigProvider manager,
237
+            final boolean isSilent, final ReadOnlyConfigProvider manager,
238
             final String domain, final String option) {
238
             final String domain, final String option) {
239
         if (manager.hasOptionString(domain, option)) {
239
         if (manager.hasOptionString(domain, option)) {
240
             sendLine(origin, isSilent, FORMAT_OUTPUT, "The current value of "
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
         } else {
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
             final String domain, final String option, final String newvalue) {
259
             final String domain, final String option, final String newvalue) {
260
         identity.setOption(domain, option, newvalue);
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
                 + " has been set to: " + newvalue);
263
                 + " has been set to: " + newvalue);
264
     }
264
     }
265
 
265
 
276
      */
276
      */
277
     private void doAppendOption(final FrameContainer origin,
277
     private void doAppendOption(final FrameContainer origin,
278
             final boolean isSilent, final ConfigProvider identity,
278
             final boolean isSilent, final ConfigProvider identity,
279
-            final AggregateConfigProvider manager,
279
+            final ReadOnlyConfigProvider manager,
280
             final String domain, final String option, final String data) {
280
             final String domain, final String option, final String data) {
281
         doSetOption(origin, isSilent, identity, domain, option,
281
         doSetOption(origin, isSilent, identity, domain, option,
282
                 (manager.hasOptionString(domain, option)
282
                 (manager.hasOptionString(domain, option)
297
             final String option) {
297
             final String option) {
298
         identity.unsetOption(domain, option);
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
     @Override
303
     @Override
315
             res.add("--channel");
315
             res.add("--channel");
316
             res.excludeAll();
316
             res.excludeAll();
317
         } else if (arg == 1 && previousArgs.size() >= 1) {
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
                 res.addAll(context.getWindow().getConfigManager()
322
                 res.addAll(context.getWindow().getConfigManager()
323
                         .getDomains());
323
                         .getDomains());
324
             } else {
324
             } else {
326
                         .getOptions(previousArgs.get(0)).keySet());
326
                         .getOptions(previousArgs.get(0)).keySet());
327
             }
327
             }
328
             res.excludeAll();
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
             res.addAll(context.getWindow().getConfigManager()
333
             res.addAll(context.getWindow().getConfigManager()
334
                     .getOptions(previousArgs.get(1)).keySet());
334
                     .getOptions(previousArgs.get(1)).keySet());
335
             res.excludeAll();
335
             res.excludeAll();

+ 2
- 2
src/com/dmdirc/commandparser/commands/server/OpenQuery.java View File

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

+ 1
- 1
src/com/dmdirc/config/ConfigTarget.java View File

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

+ 11
- 11
src/com/dmdirc/config/prefs/PreferencesSetting.java View File

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

+ 1
- 1
src/com/dmdirc/interfaces/ui/SearchBar.java View File

28
 public interface SearchBar {
28
 public interface SearchBar {
29
 
29
 
30
     /** Direction used for searching. */
30
     /** Direction used for searching. */
31
-    public enum Direction {
31
+    enum Direction {
32
 
32
 
33
         /** Move up through the document. */
33
         /** Move up through the document. */
34
         UP,
34
         UP,

+ 2
- 6
src/com/dmdirc/logger/ErrorManager.java View File

211
             final boolean appError,
211
             final boolean appError,
212
             final boolean canReport) {
212
             final boolean canReport) {
213
         final boolean dupe = addError(error);
213
         final boolean dupe = addError(error);
214
-        if (error.getLevel().equals(ErrorLevel.FATAL)) {
214
+        if (error.getLevel() == ErrorLevel.FATAL) {
215
             if (dupe) {
215
             if (dupe) {
216
                 error.setReportStatus(ErrorReportStatus.NOT_APPLICABLE);
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
             error.setReportStatus(ErrorReportStatus.NOT_APPLICABLE);
219
             error.setReportStatus(ErrorReportStatus.NOT_APPLICABLE);
224
         } else if (sendReports) {
220
         } else if (sendReports) {
225
             sendError(error);
221
             sendError(error);

+ 4
- 4
src/com/dmdirc/logger/ProgramError.java View File

184
      * @param newStatus new ErrorReportStatus for the error
184
      * @param newStatus new ErrorReportStatus for the error
185
      */
185
      */
186
     public void setReportStatus(final ErrorReportStatus newStatus) {
186
     public void setReportStatus(final ErrorReportStatus newStatus) {
187
-        if (newStatus != null && !reportStatus.equals(newStatus)) {
187
+        if (newStatus != null && reportStatus != newStatus) {
188
             reportStatus = newStatus;
188
             reportStatus = newStatus;
189
             ErrorManager.getErrorManager().fireErrorStatusChanged(this);
189
             ErrorManager.getErrorManager().fireErrorStatusChanged(this);
190
 
190
 
246
         if (errorFile.exists()) {
246
         if (errorFile.exists()) {
247
             boolean rename = false;
247
             boolean rename = false;
248
             for (int i = 0; !rename; i++) {
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
             return "1 occurrence on " + format.format(getDate());
338
             return "1 occurrence on " + format.format(getDate());
339
         } else {
339
         } else {
340
             return count.get() + " occurrences between " + format.format(
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
     @Override
361
     @Override
362
     public String toString() {
362
     public String toString() {
363
         return "ID" + id + " Level: " + getLevel() + " Status: " + getReportStatus()
363
         return "ID" + id + " Level: " + getLevel() + " Status: " + getReportStatus()
364
-                + " Message: '" + getMessage() + "'";
364
+                + " Message: '" + getMessage() + '\'';
365
     }
365
     }
366
 
366
 
367
     @Override
367
     @Override

+ 17
- 15
test/com/dmdirc/actions/ActionComponentChainTest.java View File

23
 package com.dmdirc.actions;
23
 package com.dmdirc.actions;
24
 
24
 
25
 import com.dmdirc.Server;
25
 import com.dmdirc.Server;
26
+import com.dmdirc.interfaces.actions.ActionComponent;
26
 
27
 
27
 import org.junit.Before;
28
 import org.junit.Before;
28
 import org.junit.Test;
29
 import org.junit.Test;
61
     @Test
62
     @Test
62
     public void testSingle() {
63
     public void testSingle() {
63
         final ActionComponentChain chain = new ActionComponentChain(String.class, "STRING_STRING", actionManager);
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
         assertEquals("STRING_STRING", chain.toString());
66
         assertEquals("STRING_STRING", chain.toString());
66
     }
67
     }
67
 
68
 
69
     public void testDouble() {
70
     public void testDouble() {
70
         final ActionComponentChain chain = new ActionComponentChain(String.class,
71
         final ActionComponentChain chain = new ActionComponentChain(String.class,
71
                 "STRING_STRING.STRING_STRING", actionManager);
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
         assertEquals("STRING_STRING.STRING_STRING", chain.toString());
74
         assertEquals("STRING_STRING.STRING_STRING", chain.toString());
74
     }
75
     }
75
 
76
 
90
 
91
 
91
     @Test
92
     @Test
92
     public void testAppliesTo() {
93
     public void testAppliesTo() {
93
-        final ActionComponentChain chain = new ActionComponentChain(String.class,
94
+        final ActionComponent chain = new ActionComponentChain(String.class,
94
                 "STRING_STRING.STRING_STRING.STRING_LENGTH", actionManager);
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
     @Test
99
     @Test
99
     public void testGetType() {
100
     public void testGetType() {
100
-        final ActionComponentChain chain = new ActionComponentChain(String.class,
101
+        final ActionComponent chain = new ActionComponentChain(String.class,
101
                 "STRING_STRING.STRING_STRING.STRING_LENGTH", actionManager);
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
     @Test
106
     @Test
106
     public void testGetName() {
107
     public void testGetName() {
107
-        final ActionComponentChain chain = new ActionComponentChain(String.class,
108
+        final ActionComponent chain = new ActionComponentChain(String.class,
108
                 "STRING_STRING.STRING_STRING.STRING_LENGTH", actionManager);
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
     @Test(expected=AssertionError.class)
115
     @Test(expected=AssertionError.class)
115
     public void testEmptyAppliesTo() {
116
     public void testEmptyAppliesTo() {
116
-        final ActionComponentChain chain = new ActionComponentChain(String.class, "", actionManager);
117
+        final ActionComponent chain = new ActionComponentChain(String.class, "", actionManager);
117
         chain.appliesTo();
118
         chain.appliesTo();
118
     }
119
     }
119
 
120
 
120
     @Test(expected=AssertionError.class)
121
     @Test(expected=AssertionError.class)
121
     public void testEmptyGetType() {
122
     public void testEmptyGetType() {
122
-        final ActionComponentChain chain = new ActionComponentChain(String.class, "", actionManager);
123
+        final ActionComponent chain = new ActionComponentChain(String.class, "", actionManager);
123
         chain.getType();
124
         chain.getType();
124
     }
125
     }
125
 
126
 
126
     @Test(expected=AssertionError.class)
127
     @Test(expected=AssertionError.class)
127
     public void testEmptyGetName() {
128
     public void testEmptyGetName() {
128
-        final ActionComponentChain chain = new ActionComponentChain(String.class, "", actionManager);
129
+        final ActionComponent chain = new ActionComponentChain(String.class, "", actionManager);
129
         chain.getName();
130
         chain.getName();
130
     }
131
     }
131
 
132
 
133
+    @SuppressWarnings("ResultOfMethodCallIgnored")
132
     @Test(expected=AssertionError.class)
134
     @Test(expected=AssertionError.class)
133
     public void testEmptyToString() {
135
     public void testEmptyToString() {
134
         final ActionComponentChain chain = new ActionComponentChain(String.class, "", actionManager);
136
         final ActionComponentChain chain = new ActionComponentChain(String.class, "", actionManager);
135
         chain.toString();
137
         chain.toString();
136
     }
138
     }
137
 
139
 
138
-    @Test()
140
+    @Test
139
     public void testRequiresConnection1() {
141
     public void testRequiresConnection1() {
140
         final ActionComponentChain chain = new ActionComponentChain(Server.class,
142
         final ActionComponentChain chain = new ActionComponentChain(Server.class,
141
                 "SERVER_NETWORK", actionManager);
143
                 "SERVER_NETWORK", actionManager);
142
         assertTrue(chain.requiresConnection());
144
         assertTrue(chain.requiresConnection());
143
     }
145
     }
144
 
146
 
145
-    @Test()
147
+    @Test
146
     public void testRequiresConnection2() {
148
     public void testRequiresConnection2() {
147
         final ActionComponentChain chain = new ActionComponentChain(Server.class,
149
         final ActionComponentChain chain = new ActionComponentChain(Server.class,
148
                 "SERVER_NETWORK.STRING_LENGTH", actionManager);
150
                 "SERVER_NETWORK.STRING_LENGTH", actionManager);
149
         assertTrue(chain.requiresConnection());
151
         assertTrue(chain.requiresConnection());
150
     }
152
     }
151
 
153
 
152
-    @Test()
154
+    @Test
153
     public void testRequiresConnection3() {
155
     public void testRequiresConnection3() {
154
         final ActionComponentChain chain = new ActionComponentChain(Server.class,
156
         final ActionComponentChain chain = new ActionComponentChain(Server.class,
155
                 "SERVER_NAME.STRING_LENGTH", actionManager);
157
                 "SERVER_NAME.STRING_LENGTH", actionManager);

+ 12
- 16
test/com/dmdirc/config/prefs/PreferencesDialogModelTest.java View File

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

Loading…
Cancel
Save