Browse Source

Merge pull request #33 from greboid/java8

Add java 8, run away from Dataforce
pull/34/head
Chris Smith 9 years ago
parent
commit
db31d09451

+ 4
- 4
irc/src/com/dmdirc/parser/irc/IRCChannelInfo.java View File

@@ -73,7 +73,7 @@ public class IRCChannelInfo implements ChannelInfo {
73 73
     /** Channel Name. */
74 74
     private final String name;
75 75
     /** Hashtable containing references to ChannelClients. */
76
-    private final Map<String, IRCChannelClientInfo> clients = Collections.synchronizedMap(new HashMap<String, IRCChannelClientInfo>());
76
+    private final Map<String, IRCChannelClientInfo> clients = Collections.synchronizedMap(new HashMap<>());
77 77
     /** Hashtable storing values for modes set in the channel that use parameters. */
78 78
     private final Map<Character, String> paramModes = new HashMap<>();
79 79
     /** Hashtable storing list modes. */
@@ -277,7 +277,7 @@ public class IRCChannelInfo implements ChannelInfo {
277 277
     @Override
278 278
     public Collection<ChannelClientInfo> getChannelClients() {
279 279
         synchronized (clients) {
280
-            return new ArrayList<ChannelClientInfo>(clients.values());
280
+            return new ArrayList<>(clients.values());
281 281
         }
282 282
     }
283 283
 
@@ -529,7 +529,7 @@ public class IRCChannelInfo implements ChannelInfo {
529 529
         }
530 530
 
531 531
         if (!listModes.containsKey(cMode)) {
532
-            listModes.put(cMode, new ArrayList<ChannelListModeItem>());
532
+            listModes.put(cMode, new ArrayList<>());
533 533
         }
534 534
 
535 535
         final List<ChannelListModeItem> lModes = listModes.get(cMode);
@@ -555,7 +555,7 @@ public class IRCChannelInfo implements ChannelInfo {
555 555
         }
556 556
 
557 557
         if (!listModes.containsKey(mode)) {
558
-            listModes.put(mode, new ArrayList<ChannelListModeItem>());
558
+            listModes.put(mode, new ArrayList<>());
559 559
         }
560 560
         return listModes.get(mode);
561 561
     }

+ 2
- 2
irc/src/com/dmdirc/parser/irc/IRCParser.java View File

@@ -517,12 +517,12 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
517 517
     }
518 518
 
519 519
     @Override
520
-    public void setTrustManagers(final TrustManager[] managers) {
520
+    public void setTrustManagers(final TrustManager... managers) {
521 521
         myTrustManager = managers == null ? null : Arrays.copyOf(managers, managers.length);
522 522
     }
523 523
 
524 524
     @Override
525
-    public void setKeyManagers(final KeyManager[] managers) {
525
+    public void setKeyManagers(final KeyManager... managers) {
526 526
         myKeyManagers = managers == null ? null : Arrays.copyOf(managers, managers.length);
527 527
     }
528 528
 

+ 3
- 7
irc/src/com/dmdirc/parser/irc/IRCReader.java View File

@@ -32,10 +32,6 @@ import java.nio.charset.CharacterCodingException;
32 32
 import java.nio.charset.Charset;
33 33
 import java.nio.charset.CharsetDecoder;
34 34
 import java.nio.charset.CodingErrorAction;
35
-import java.text.SimpleDateFormat;
36
-import java.util.Arrays;
37
-import java.util.Collections;
38
-import java.util.Date;
39 35
 import java.util.HashMap;
40 36
 import java.util.Map;
41 37
 
@@ -197,7 +193,7 @@ public class IRCReader implements Closeable {
197 193
      * @param tokens The tokens to extract a source from
198 194
      * @return The relevant source or null if none specified
199 195
      */
200
-    private String getSource(final String[] tokens) {
196
+    private String getSource(final String... tokens) {
201 197
         if (tokens.length > 0 && tokens[0].length() > 1 && tokens[0].charAt(0) == ':') {
202 198
             return tokens[0].substring(1);
203 199
         }
@@ -214,7 +210,7 @@ public class IRCReader implements Closeable {
214 210
      * @param tokens The tokens to extract a destination from
215 211
      * @return The relevant destination or null if none specified
216 212
      */
217
-    private String getDestination(final String[] tokens) {
213
+    private String getDestination(final String... tokens) {
218 214
         if (tokens.length > 0 && tokens[0].length() >= 3 && tokens[0].charAt(0) == ':') {
219 215
             final int target = tokens[1].matches("^[0-9]+$") ? 3 : 2;
220 216
 
@@ -251,7 +247,7 @@ public class IRCReader implements Closeable {
251 247
          * @param line A string representation of the line
252 248
          * @param lineTokens The tokens which make up the line
253 249
          */
254
-        public ReadLine(final String line, final String[] lineTokens) {
250
+        public ReadLine(final String line, final String... lineTokens) {
255 251
             this.line = line;
256 252
 
257 253
             String[] tokens = lineTokens;

+ 1
- 1
irc/src/com/dmdirc/parser/irc/Logging.java View File

@@ -91,7 +91,7 @@ public class Logging {
91 91
             factory = Class.forName("org.apache.commons.logging.LogFactory");
92 92
 
93 93
             if (factory != null) {
94
-                final Method getLog = factory.getMethod("getLog", new Class[]{Class.class});
94
+                final Method getLog = factory.getMethod("getLog", Class.class);
95 95
                 log = getLog.invoke(null, this.getClass());
96 96
             }
97 97
         } catch (ClassNotFoundException | NoSuchMethodException | IllegalAccessException | InvocationTargetException cnfe) {

+ 3
- 3
irc/src/com/dmdirc/parser/irc/ProcessingManager.java View File

@@ -225,7 +225,7 @@ public class ProcessingManager {
225 225
      * @param token IRCTokenised line to process
226 226
      * @throws ProcessorNotFoundException exception if no processors exists to handle the line
227 227
      */
228
-    public void process(final String sParam, final String[] token) throws ProcessorNotFoundException {
228
+    public void process(final String sParam, final String... token) throws ProcessorNotFoundException {
229 229
         process(new Date(), sParam, token);
230 230
     }
231 231
 
@@ -237,7 +237,7 @@ public class ProcessingManager {
237 237
      * @param token IRCTokenised line to process
238 238
      * @throws ProcessorNotFoundException exception if no processors exists to handle the line
239 239
      */
240
-    public void process(final Date date, final String sParam, final String[] token) throws ProcessorNotFoundException {
240
+    public void process(final Date date, final String sParam, final String... token) throws ProcessorNotFoundException {
241 241
         IRCProcessor messageProcessor = null;
242 242
         try {
243 243
             messageProcessor = getProcessor(sParam);
@@ -272,7 +272,7 @@ public class ProcessingManager {
272 272
      * @param token IRC Tokenised line
273 273
      * @return true if a method was called, false otherwise
274 274
      */
275
-    protected boolean callNumeric(final int numeric, final String[] token) {
275
+    protected boolean callNumeric(final int numeric, final String... token) {
276 276
         return parser.getCallbackManager().getCallbackType(NumericListener.class).call(numeric, token);
277 277
     }
278 278
 }

+ 6
- 6
irc/src/com/dmdirc/parser/irc/ServerTypeGroup.java View File

@@ -33,25 +33,25 @@ public enum ServerTypeGroup {
33 33
     /**
34 34
      * Freenode Group.
35 35
      */
36
-    FREENODE("Freenode IRCDs", new ServerType[]{ServerType.HYPERION, ServerType.DANCER}),
36
+    FREENODE("Freenode IRCDs", ServerType.HYPERION, ServerType.DANCER),
37 37
     /**
38 38
      * Charybdis Group.
39 39
      */
40
-    CHARYBDIS("Charybdis-esque IRCDs", new ServerType[]{ServerType.IRCD_SEVEN, ServerType.CHARYBDIS}),
40
+    CHARYBDIS("Charybdis-esque IRCDs", ServerType.IRCD_SEVEN, ServerType.CHARYBDIS),
41 41
     /**
42 42
      * Group for ircds that put the channel owners in a list under raw 386
43 43
      * rather than as a channel user mode.
44 44
      */
45
-    OWNER_386("Owner List", new ServerType[]{ServerType.SWIFTIRC, ServerType.AUSTHEX8}),
45
+    OWNER_386("Owner List", ServerType.SWIFTIRC, ServerType.AUSTHEX8),
46 46
     /**
47 47
      * Group for ircds that put the protected users in a list under raw 388
48 48
      * rather than as a channel user mode.
49 49
      */
50
-    PROTECTED_388("Protected List", new ServerType[]{ServerType.SWIFTIRC, ServerType.AUSTHEX8}),
50
+    PROTECTED_388("Protected List", ServerType.SWIFTIRC, ServerType.AUSTHEX8),
51 51
     /**
52 52
      * Group for ircds that require list modes to be sent one at a time.
53 53
      */
54
-    SINGLE_LISTMODE("Single List Modes", new ServerType[]{ServerType.EUIRCD, ServerType.UNREAL, ServerType.IRSEE});
54
+    SINGLE_LISTMODE("Single List Modes", ServerType.EUIRCD, ServerType.UNREAL, ServerType.IRSEE);
55 55
 
56 56
     /** Name of the group. */
57 57
     final String name;
@@ -64,7 +64,7 @@ public enum ServerTypeGroup {
64 64
      * @param name Name of this group.
65 65
      * @param members Members of this group.
66 66
      */
67
-    ServerTypeGroup(final String name, final ServerType[] members) {
67
+    ServerTypeGroup(final String name, final ServerType... members) {
68 68
         this.name = name;
69 69
         this.members = Arrays.asList(members);
70 70
     }

+ 2
- 2
irc/src/com/dmdirc/parser/irc/TimestampedIRCProcessor.java View File

@@ -43,7 +43,7 @@ public abstract class TimestampedIRCProcessor extends IRCProcessor {
43 43
     }
44 44
 
45 45
     @Override
46
-    public final void process(final String sParam, final String[] token) {
46
+    public final void process(final String sParam, final String... token) {
47 47
         process(new Date(), sParam, token);
48 48
     }
49 49
 
@@ -54,7 +54,7 @@ public abstract class TimestampedIRCProcessor extends IRCProcessor {
54 54
      * @param sParam Type of line to process ("005", "PRIVMSG" etc)
55 55
      * @param token IRCTokenised line to process
56 56
      */
57
-    public abstract void process(final Date date, final String sParam, final String[] token);
57
+    public abstract void process(final Date date, final String sParam, final String... token);
58 58
 
59 59
 
60 60
 }

+ 1
- 7
irc/src/com/dmdirc/parser/irc/outputqueue/PriorityQueueHandler.java View File

@@ -47,13 +47,7 @@ public class PriorityQueueHandler extends QueueHandler {
47 47
      * @return a QueueFactory that produces PrirortyQueueHandlers.
48 48
      */
49 49
     public static QueueFactory getFactory() {
50
-        return new QueueFactory() {
51
-
52
-            @Override
53
-            public QueueHandler getQueueHandler(final OutputQueue outputQueue, final BlockingQueue<QueueItem> queue, final PrintWriter out) {
54
-                return new PriorityQueueHandler(outputQueue, queue, out);
55
-            }
56
-        };
50
+        return PriorityQueueHandler::new;
57 51
     }
58 52
 
59 53
     @Override

+ 1
- 7
irc/src/com/dmdirc/parser/irc/outputqueue/SimpleRateLimitedQueueHandler.java View File

@@ -67,13 +67,7 @@ public class SimpleRateLimitedQueueHandler extends QueueHandler {
67 67
      * @return a QueueFactory that produces PrirortyQueueHandlers.
68 68
      */
69 69
     public static QueueFactory getFactory() {
70
-        return new QueueFactory() {
71
-
72
-            @Override
73
-            public QueueHandler getQueueHandler(final OutputQueue outputQueue, final BlockingQueue<QueueItem> queue, final PrintWriter out) {
74
-                return new SimpleRateLimitedQueueHandler(outputQueue, queue, out);
75
-            }
76
-        };
70
+        return SimpleRateLimitedQueueHandler::new;
77 71
     }
78 72
 
79 73
     /**

+ 5
- 5
irc/src/com/dmdirc/parser/irc/processors/ProcessListModes.java View File

@@ -254,11 +254,11 @@ public class ProcessListModes extends IRCProcessor {
254 254
                 channel.setHasGotListModes(true);
255 255
 
256 256
                 if (isCleverMode) {
257
-                    for (Character thisMode : parser.chanModesOther.keySet()) {
258
-                        if (parser.chanModesOther.get(thisMode) == IRCParser.MODE_LIST) {
259
-                            callChannelGotListModes(channel, thisMode);
260
-                        }
261
-                    }
257
+                    parser.chanModesOther.keySet()
258
+                            .stream()
259
+                            .filter(thisMode -> parser.chanModesOther
260
+                                    .get(thisMode) == IRCParser.MODE_LIST)
261
+                            .forEach(thisMode -> callChannelGotListModes(channel, thisMode));
262 262
                 } else {
263 263
                     callChannelGotListModes(channel, mode);
264 264
                 }

Loading…
Cancel
Save