Browse Source

Merge pull request #497 from csmith/master

Minor style fixes
pull/498/head
Greg Holmes 7 years ago
parent
commit
b08146ca8d

+ 1
- 3
calc/src/main/java/com/dmdirc/addons/calc/Parser.java View File

@@ -25,7 +25,6 @@ package com.dmdirc.addons.calc;
25 25
 import java.text.ParseException;
26 26
 import java.util.ArrayList;
27 27
 import java.util.Arrays;
28
-import java.util.Collections;
29 28
 import java.util.Comparator;
30 29
 import java.util.List;
31 30
 import java.util.stream.Collectors;
@@ -44,8 +43,7 @@ public class Parser {
44 43
     static {
45 44
         TOKENS_BY_PRECEDENCE = new ArrayList<>(Arrays.asList(
46 45
                 TokenType.values()));
47
-        Collections.sort(TOKENS_BY_PRECEDENCE,
48
-                new TokenTypePrecedenceComparator());
46
+        TOKENS_BY_PRECEDENCE.sort(new TokenTypePrecedenceComparator());
49 47
     }
50 48
 
51 49
     public Parser(final Lexer lexer) {

+ 2
- 3
calc/src/main/java/com/dmdirc/addons/calc/TokenType.java View File

@@ -130,9 +130,8 @@ public enum TokenType {
130 130
 
131 131
                 @Override
132 132
                 public Number evaluate(final TreeToken token) {
133
-                    return new Float(Math.pow(token.getChildren().get(0).evaluate()
134
-                                    .doubleValue(),
135
-                                    token.getChildren().get(1).evaluate().doubleValue()));
133
+                    return (float) Math.pow(token.getChildren().get(0).evaluate().doubleValue(),
134
+                            token.getChildren().get(1).evaluate().doubleValue());
136 135
                 }
137 136
             };
138 137
     /** The string representation of tokens that may follow this one. */

+ 3
- 5
dcc/src/main/java/com/dmdirc/addons/dcc/TransferContainer.java View File

@@ -307,11 +307,9 @@ public class TransferContainer extends FrameContainer implements
307 307
             //that this send is for.
308 308
             if (connection.getParser().get().getStringConverter().equalsIgnoreCase(
309 309
                     otherNickname, myNickname)) {
310
-                final Thread errorThread = new Thread(() -> {
311
-                    JOptionPane.showMessageDialog(null,
312
-                            "You can't DCC yourself.", "DCC Error",
313
-                            JOptionPane.ERROR_MESSAGE);
314
-                }, "DCC-Error-Message");
310
+                final Thread errorThread = new Thread(() -> JOptionPane.showMessageDialog(null,
311
+                        "You can't DCC yourself.", "DCC Error",
312
+                        JOptionPane.ERROR_MESSAGE), "DCC-Error-Message");
315 313
                 errorThread.start();
316 314
             } else {
317 315
                 if (config.getOptionBool(plugin.getDomain(), "send.reverse")) {

+ 1
- 7
freedesktop_notifications/src/main/java/com/dmdirc/addons/freedesktop_notifications/FDNotifyCommand.java View File

@@ -60,13 +60,7 @@ public final class FDNotifyCommand extends Command {
60 60
     @Override
61 61
     public void execute(@Nonnull final WindowModel origin, final CommandArguments args,
62 62
             final CommandContext context) {
63
-        new Thread() {
64
-
65
-            @Override
66
-            public void run() {
67
-                manager.showNotification("", args.getArgumentsAsString());
68
-            }
69
-        }.start();
63
+        new Thread(() -> manager.showNotification("", args.getArgumentsAsString())).start();
70 64
     }
71 65
 
72 66
 }

+ 1
- 3
nickcolours/src/main/java/com/dmdirc/addons/nickcolours/NickColourYamlStore.java View File

@@ -54,9 +54,7 @@ public class NickColourYamlStore extends BaseYamlStore<NickColourEntry> {
54 54
     public Map<String, Color> readNickColourEntries(final Path path) {
55 55
         final Map<String, Color> nickColours = new HashMap<>();
56 56
         final Collection<NickColourEntry> nickColourEntries = read(path);
57
-        nickColourEntries.stream().forEach(
58
-                e -> nickColours.put(e.getNetwork() + ':' + e.getUser(), e.getColor())
59
-        );
57
+        nickColourEntries.forEach(e -> nickColours.put(e.getNetwork() + ':' + e.getUser(), e.getColor()));
60 58
         return nickColours;
61 59
     }
62 60
 

+ 1
- 2
nowplaying/src/main/java/com/dmdirc/addons/nowplaying/NowPlayingManager.java View File

@@ -38,7 +38,6 @@ import com.dmdirc.plugins.PluginInfo;
38 38
 import com.dmdirc.plugins.PluginManager;
39 39
 import java.util.ArrayList;
40 40
 import java.util.Collection;
41
-import java.util.Collections;
42 41
 import java.util.List;
43 42
 import javax.inject.Inject;
44 43
 import net.engio.mbassy.listener.Handler;
@@ -195,7 +194,7 @@ public class NowPlayingManager {
195 194
     public MediaSource getBestSource() {
196 195
         final List<MediaSource> possibleSources = getSources();
197 196
 
198
-        Collections.sort(possibleSources, new MediaSourceComparator(order));
197
+        possibleSources.sort(new MediaSourceComparator(order));
199 198
 
200 199
         MediaSource paused = null;
201 200
         for (final MediaSource source : possibleSources) {

+ 2
- 5
tabcompletion_mirc/src/main/java/com/dmdirc/addons/tabcompletion_mirc/MircStyle.java View File

@@ -29,11 +29,8 @@ import com.dmdirc.ui.input.TabCompleter;
29 29
 import com.dmdirc.ui.input.TabCompletionMatches;
30 30
 import com.dmdirc.ui.input.tabstyles.TabCompletionResult;
31 31
 import com.dmdirc.ui.input.tabstyles.TabCompletionStyle;
32
-
33 32
 import com.google.common.collect.Lists;
34
-
35 33
 import java.awt.Toolkit;
36
-import java.util.Collections;
37 34
 import java.util.List;
38 35
 
39 36
 public class MircStyle implements TabCompletionStyle {
@@ -68,7 +65,7 @@ public class MircStyle implements TabCompletionStyle {
68 65
         if (word.equals(lastWord)) {
69 66
             final TabCompletionMatches res = tabCompleter.complete(tabString, additional);
70 67
             final List<String> results = Lists.newArrayList(res.getResults());
71
-            Collections.sort(results, String.CASE_INSENSITIVE_ORDER);
68
+            results.sort(String.CASE_INSENSITIVE_ORDER);
72 69
             // We're continuing to tab through
73 70
             target = results.get((results.indexOf(lastWord) + (shiftPressed ? -1: 1) + results.size()) % results.size());
74 71
         } else {
@@ -80,7 +77,7 @@ public class MircStyle implements TabCompletionStyle {
80 77
                 Toolkit.getDefaultToolkit().beep();
81 78
                 return null;
82 79
             } else {
83
-                Collections.sort(results, String.CASE_INSENSITIVE_ORDER);
80
+                results.sort(String.CASE_INSENSITIVE_ORDER);
84 81
 
85 82
                 if (!word.isEmpty()
86 83
                         && window instanceof GroupChat

+ 0
- 2
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/EdtHandlerInvocation.java View File

@@ -22,8 +22,6 @@
22 22
 
23 23
 package com.dmdirc.addons.ui_swing;
24 24
 
25
-import java.lang.reflect.Method;
26
-
27 25
 import net.engio.mbassy.bus.MessagePublication;
28 26
 import net.engio.mbassy.dispatch.ReflectiveHandlerInvocation;
29 27
 import net.engio.mbassy.subscription.SubscriptionContext;

+ 1
- 1
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/components/NicklistListModel.java View File

@@ -104,7 +104,7 @@ public final class NicklistListModel extends AbstractListModel<GroupChatUser> im
104 104
      */
105 105
     public void sort() {
106 106
         synchronized (nicknames) {
107
-            Collections.sort(nicknames, new NicklistComparator(sortByMode, sortByCase));
107
+            nicknames.sort(new NicklistComparator(sortByMode, sortByCase));
108 108
         }
109 109
         rerender();
110 110
     }

+ 2
- 6
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/components/TopicBar.java View File

@@ -221,9 +221,7 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
221 221
         validateTopic();
222 222
 
223 223
         final Optional<Topic> topic = channel.getCurrentTopic();
224
-        if (topic.isPresent()) {
225
-            topicChanged(channel, topic.get());
226
-        }
224
+        topic.ifPresent(topic1 -> topicChanged(channel, topic1));
227 225
     }
228 226
 
229 227
     @Handler(invocation = EdtHandlerInvocation.class)
@@ -316,9 +314,7 @@ public class TopicBar extends JComponent implements ActionListener, ConfigChange
316 314
         topicText.setVisible(false);
317 315
         topicText.setText("");
318 316
         final Optional<Topic> topic = channel.getCurrentTopic();
319
-        if (topic.isPresent()) {
320
-            topicText.setText(topic.get().getTopic());
321
-        }
317
+        topic.ifPresent(topic1 -> topicText.setText(topic1.getTopic()));
322 318
         applyAttributes();
323 319
         topicText.setCaretPosition(0);
324 320
         topicText.setFocusable(true);

+ 2
- 3
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/components/addonpanel/PluginPanel.java View File

@@ -36,7 +36,6 @@ import com.dmdirc.updater.manager.CachingUpdateManager;
36 36
 import java.awt.Window;
37 37
 import java.util.ArrayList;
38 38
 import java.util.Collection;
39
-import java.util.Collections;
40 39
 import java.util.Comparator;
41 40
 import java.util.List;
42 41
 import javax.inject.Inject;
@@ -99,14 +98,14 @@ public class PluginPanel extends AddonPanel {
99 98
         final List<PluginInfo> list = new ArrayList<>();
100 99
         final Collection<PluginInfo> sortedList = new ArrayList<>();
101 100
         list.addAll(pluginManager.getPluginInfos());
102
-        Collections.sort(list, COMPARATOR);
101
+        list.sort(COMPARATOR);
103 102
         list.stream().filter(plugin -> plugin.getMetaData().getParent() == null).forEach(plugin -> {
104 103
             final List<PluginInfo> childList = new ArrayList<>();
105 104
             sortedList.add(plugin);
106 105
             plugin.getChildren().stream()
107 106
                     .filter(child -> !childList.contains(child))
108 107
                     .forEach(childList::add);
109
-            Collections.sort(childList, COMPARATOR);
108
+            childList.sort(COMPARATOR);
110 109
             sortedList.addAll(childList);
111 110
         });
112 111
 

+ 1
- 3
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/components/menubar/MenuBar.java View File

@@ -111,9 +111,7 @@ public class MenuBar extends JMenuBar {
111 111
         final Optional<JMenu> menu = getParentMenuItem(parentMenu);
112 112
         if (menu.isPresent()) {
113 113
             final Optional<JMenuItem> menuItem = getChildItem(menu.get(), childItem);
114
-            if (menuItem.isPresent()) {
115
-                menu.get().remove(menuItem.get());
116
-            }
114
+            menuItem.ifPresent(jMenuItem -> menu.get().remove(jMenuItem));
117 115
         }
118 116
     }
119 117
 

+ 2
- 8
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/dialogs/aliases/AliasManagerLinker.java View File

@@ -140,9 +140,7 @@ public class AliasManagerLinker implements AliasDialogModelListener {
140 140
         deleteAlias.setEnabled(false);
141 141
         deleteAlias.addActionListener(e -> {
142 142
             final Optional<Alias> alias = model.getSelectedAlias();
143
-            if (alias.isPresent()) {
144
-                model.removeAlias(alias.get().getName());
145
-            }
143
+            alias.ifPresent(alias1 -> model.removeAlias(alias1.getName()));
146 144
         });
147 145
     }
148 146
 
@@ -198,11 +196,7 @@ public class AliasManagerLinker implements AliasDialogModelListener {
198 196
         command.setEnabled(model.isCommandValid());
199 197
         command.setText(model.getSelectedAliasName());
200 198
         final int index;
201
-        if (alias.isPresent()) {
202
-            index = commandModel.indexOf(alias.get());
203
-        } else {
204
-            index = -1;
205
-        }
199
+        index = alias.map(alias1 -> commandModel.indexOf(alias1)).orElseGet(() -> -1);
206 200
         if (index != selectionModel.getLeadSelectionIndex()) {
207 201
             selectionModel.setLeadSelectionIndex(index);
208 202
         }

+ 1
- 5
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/framemanager/ctrltab/CtrlTabWindowManager.java View File

@@ -115,11 +115,7 @@ public class CtrlTabWindowManager {
115 115
         final Optional<TextFrame> parent = event.getParentWindow();
116 116
         final TextFrame window = event.getChildWindow();
117 117
         final TreeViewNode parentNode;
118
-        if (parent.isPresent()) {
119
-            parentNode = nodes.get(parent.get());
120
-        } else {
121
-            parentNode = model.getRootNode();
122
-        }
118
+        parentNode = parent.map(nodes::get).orElseGet(model::getRootNode);
123 119
 
124 120
         UIUtilities.invokeAndWait(() -> {
125 121
             final TreeViewNode node = new TreeViewNode(null, window);

+ 2
- 2
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/injection/DialogModule.java View File

@@ -85,14 +85,14 @@ public class DialogModule {
85 85
      * Qualifier that indicates a restart dialog is needed for updates to be applied.
86 86
      */
87 87
     @Qualifier
88
-    public static @interface ForUpdates {
88
+    public @interface ForUpdates {
89 89
     }
90 90
 
91 91
     /**
92 92
      * Qualifier that indicates a restart dialog is needed for settings to be applied.
93 93
      */
94 94
     @Qualifier
95
-    public static @interface ForSettings {
95
+    public @interface ForSettings {
96 96
     }
97 97
 
98 98
     @Provides

Loading…
Cancel
Save