Ver código fonte

Merge pull request #497 from csmith/master

Minor style fixes
pull/498/head
Greg Holmes 7 anos atrás
pai
commit
b08146ca8d

+ 1
- 3
calc/src/main/java/com/dmdirc/addons/calc/Parser.java Ver arquivo

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

+ 2
- 3
calc/src/main/java/com/dmdirc/addons/calc/TokenType.java Ver arquivo

130
 
130
 
131
                 @Override
131
                 @Override
132
                 public Number evaluate(final TreeToken token) {
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
     /** The string representation of tokens that may follow this one. */
137
     /** The string representation of tokens that may follow this one. */

+ 3
- 5
dcc/src/main/java/com/dmdirc/addons/dcc/TransferContainer.java Ver arquivo

307
             //that this send is for.
307
             //that this send is for.
308
             if (connection.getParser().get().getStringConverter().equalsIgnoreCase(
308
             if (connection.getParser().get().getStringConverter().equalsIgnoreCase(
309
                     otherNickname, myNickname)) {
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
                 errorThread.start();
313
                 errorThread.start();
316
             } else {
314
             } else {
317
                 if (config.getOptionBool(plugin.getDomain(), "send.reverse")) {
315
                 if (config.getOptionBool(plugin.getDomain(), "send.reverse")) {

+ 1
- 7
freedesktop_notifications/src/main/java/com/dmdirc/addons/freedesktop_notifications/FDNotifyCommand.java Ver arquivo

60
     @Override
60
     @Override
61
     public void execute(@Nonnull final WindowModel origin, final CommandArguments args,
61
     public void execute(@Nonnull final WindowModel origin, final CommandArguments args,
62
             final CommandContext context) {
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 Ver arquivo

54
     public Map<String, Color> readNickColourEntries(final Path path) {
54
     public Map<String, Color> readNickColourEntries(final Path path) {
55
         final Map<String, Color> nickColours = new HashMap<>();
55
         final Map<String, Color> nickColours = new HashMap<>();
56
         final Collection<NickColourEntry> nickColourEntries = read(path);
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
         return nickColours;
58
         return nickColours;
61
     }
59
     }
62
 
60
 

+ 1
- 2
nowplaying/src/main/java/com/dmdirc/addons/nowplaying/NowPlayingManager.java Ver arquivo

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

+ 2
- 5
tabcompletion_mirc/src/main/java/com/dmdirc/addons/tabcompletion_mirc/MircStyle.java Ver arquivo

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

+ 0
- 2
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/EdtHandlerInvocation.java Ver arquivo

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

+ 1
- 1
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/components/NicklistListModel.java Ver arquivo

104
      */
104
      */
105
     public void sort() {
105
     public void sort() {
106
         synchronized (nicknames) {
106
         synchronized (nicknames) {
107
-            Collections.sort(nicknames, new NicklistComparator(sortByMode, sortByCase));
107
+            nicknames.sort(new NicklistComparator(sortByMode, sortByCase));
108
         }
108
         }
109
         rerender();
109
         rerender();
110
     }
110
     }

+ 2
- 6
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/components/TopicBar.java Ver arquivo

221
         validateTopic();
221
         validateTopic();
222
 
222
 
223
         final Optional<Topic> topic = channel.getCurrentTopic();
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
     @Handler(invocation = EdtHandlerInvocation.class)
227
     @Handler(invocation = EdtHandlerInvocation.class)
316
         topicText.setVisible(false);
314
         topicText.setVisible(false);
317
         topicText.setText("");
315
         topicText.setText("");
318
         final Optional<Topic> topic = channel.getCurrentTopic();
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
         applyAttributes();
318
         applyAttributes();
323
         topicText.setCaretPosition(0);
319
         topicText.setCaretPosition(0);
324
         topicText.setFocusable(true);
320
         topicText.setFocusable(true);

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

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

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

111
         final Optional<JMenu> menu = getParentMenuItem(parentMenu);
111
         final Optional<JMenu> menu = getParentMenuItem(parentMenu);
112
         if (menu.isPresent()) {
112
         if (menu.isPresent()) {
113
             final Optional<JMenuItem> menuItem = getChildItem(menu.get(), childItem);
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 Ver arquivo

140
         deleteAlias.setEnabled(false);
140
         deleteAlias.setEnabled(false);
141
         deleteAlias.addActionListener(e -> {
141
         deleteAlias.addActionListener(e -> {
142
             final Optional<Alias> alias = model.getSelectedAlias();
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
         command.setEnabled(model.isCommandValid());
196
         command.setEnabled(model.isCommandValid());
199
         command.setText(model.getSelectedAliasName());
197
         command.setText(model.getSelectedAliasName());
200
         final int index;
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
         if (index != selectionModel.getLeadSelectionIndex()) {
200
         if (index != selectionModel.getLeadSelectionIndex()) {
207
             selectionModel.setLeadSelectionIndex(index);
201
             selectionModel.setLeadSelectionIndex(index);
208
         }
202
         }

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

115
         final Optional<TextFrame> parent = event.getParentWindow();
115
         final Optional<TextFrame> parent = event.getParentWindow();
116
         final TextFrame window = event.getChildWindow();
116
         final TextFrame window = event.getChildWindow();
117
         final TreeViewNode parentNode;
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
         UIUtilities.invokeAndWait(() -> {
120
         UIUtilities.invokeAndWait(() -> {
125
             final TreeViewNode node = new TreeViewNode(null, window);
121
             final TreeViewNode node = new TreeViewNode(null, window);

+ 2
- 2
ui_swing/src/main/java/com/dmdirc/addons/ui_swing/injection/DialogModule.java Ver arquivo

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

Carregando…
Cancelar
Salvar