Ver código fonte

Java 7 conversions

Change-Id: Id834157281c02302bfe6f71201042712144b22ff
Reviewed-on: http://gerrit.dmdirc.com/2894
Automatic-Compile: DMDirc Build Manager
Reviewed-by: Chris Smith <chris@dmdirc.com>
tags/0.8
Greg Holmes 10 anos atrás
pai
commit
6864a35fa2

+ 1
- 1
src/com/dmdirc/parser/common/BaseChannelClientInfo.java Ver arquivo

@@ -35,7 +35,7 @@ import java.util.Map;
35 35
 public abstract class BaseChannelClientInfo implements ChannelClientInfo {
36 36
 
37 37
     /** A map for random data associated with the client to be stored in. */
38
-    private final Map<Object, Object> map = new HashMap<Object, Object>();
38
+    private final Map<Object, Object> map = new HashMap<>();
39 39
 
40 40
     /** The channel that the client is associated with. */
41 41
     private final ChannelInfo channel;

+ 2
- 2
src/com/dmdirc/parser/common/BaseChannelInfo.java Ver arquivo

@@ -39,10 +39,10 @@ public abstract class BaseChannelInfo implements ChannelInfo {
39 39
     private final Parser parser;
40 40
 
41 41
     /** A map for random data associated with the client to be stored in. */
42
-    private final Map<Object, Object> map = new HashMap<Object, Object>();
42
+    private final Map<Object, Object> map = new HashMap<>();
43 43
 
44 44
     /** The clients in this channel. */
45
-    private final Map<String, ChannelClientInfo> clients = new HashMap<String, ChannelClientInfo>();
45
+    private final Map<String, ChannelClientInfo> clients = new HashMap<>();
46 46
 
47 47
     /** The name of this channel. */
48 48
     private final String name;

+ 1
- 1
src/com/dmdirc/parser/common/BaseClientInfo.java Ver arquivo

@@ -37,7 +37,7 @@ public abstract class BaseClientInfo implements ClientInfo {
37 37
     private final Parser parser;
38 38
 
39 39
     /** A map for random data associated with the client to be stored in. */
40
-    private final Map<Object, Object> map = new HashMap<Object, Object>();
40
+    private final Map<Object, Object> map = new HashMap<>();
41 41
 
42 42
     /** The user's details. */
43 43
     private String nick, user, host, realname, account = null;

+ 1
- 1
src/com/dmdirc/parser/common/CallbackManager.java Ver arquivo

@@ -110,7 +110,7 @@ public class CallbackManager {
110 110
 
111 111
     /** Hashtable used to store the different types of callback known. */
112 112
     private final Map<Class<? extends CallbackInterface>, CallbackObject> callbackHash
113
-            = new HashMap<Class<? extends CallbackInterface>, CallbackObject>();
113
+            = new HashMap<>();
114 114
 
115 115
     /** A map of implementations to use for parser interfaces. */
116 116
     private final Map<Class<?>, Class<?>> implementationMap;

+ 17
- 22
src/com/dmdirc/parser/common/CallbackObject.java Ver arquivo

@@ -19,7 +19,6 @@
19 19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 20
  * SOFTWARE.
21 21
  */
22
-
23 22
 package com.dmdirc.parser.common;
24 23
 
25 24
 import com.dmdirc.parser.interfaces.FakableArgument;
@@ -47,8 +46,8 @@ public class CallbackObject {
47 46
     protected final Class<? extends CallbackInterface> type;
48 47
 
49 48
     /** Arraylist for storing callback information related to the callback. */
50
-    protected final List<CallbackInterface> callbackInfo =
51
-            new CopyOnWriteArrayList<CallbackInterface>();
49
+    protected final List<CallbackInterface> callbackInfo
50
+            = new CopyOnWriteArrayList<>();
52 51
 
53 52
     /** Reference to the Parser that owns this callback. */
54 53
     protected Parser myParser;
@@ -168,7 +167,8 @@ public class CallbackObject {
168 167
         for (CallbackInterface iface : callbackInfo) {
169 168
             try {
170 169
                 type.getMethods()[0].invoke(iface, newArgs);
171
-            } catch (Exception e) {
170
+            } catch (SecurityException | IllegalAccessException |
171
+                    IllegalArgumentException | InvocationTargetException e) {
172 172
                 if (getType().equals(ErrorInfoListener.class)) {
173 173
                     System.out.printf("Exception in onError Callback. [%s]\n", e.getMessage());
174 174
                     e.printStackTrace();
@@ -187,10 +187,10 @@ public class CallbackObject {
187 187
     }
188 188
 
189 189
     /**
190
-     * Replaces all null entries in the specified array with fake values,
191
-     * if the corresponding parameter of this callback's type is marked with
192
-     * the {@link FakableArgument} annotation. The fake classes are constructed
193
-     * by using parameters designated {@link FakableSource}.
190
+     * Replaces all null entries in the specified array with fake values, if the
191
+     * corresponding parameter of this callback's type is marked with the
192
+     * {@link FakableArgument} annotation. The fake classes are constructed by
193
+     * using parameters designated {@link FakableSource}.
194 194
      *
195 195
      * @param args The arguments to be faked
196 196
      */
@@ -217,15 +217,15 @@ public class CallbackObject {
217 217
      * infinite recursion in cases of cyclic dependencies. If recursion fails,
218 218
      * the constructor is skipped.
219 219
      *
220
-     * If the created object has a <code>setFake(boolean)</code> method, it
221
-     * is automatically invoked with an argument of <code>true</code>.
220
+     * If the created object has a <code>setFake(boolean)</code> method, it is
221
+     * automatically invoked with an argument of <code>true</code>.
222 222
      *
223 223
      * @param args The arguments array to use for sources
224 224
      * @param target The class that should be constructed
225 225
      * @return An instance of the target class, or null on failure
226 226
      */
227 227
     protected Object getFakeArg(final Object[] args, final Class<?> target) {
228
-        final Map<Class<?>, Object> sources = new HashMap<Class<?>, Object>();
228
+        final Map<Class<?>, Object> sources = new HashMap<>();
229 229
         int i = 0;
230 230
 
231 231
         for (Annotation[] anns : type.getMethods()[0].getParameterAnnotations()) {
@@ -285,13 +285,8 @@ public class CallbackObject {
285 285
                     }
286 286
 
287 287
                     return instance;
288
-                } catch (InstantiationException ex) {
289
-                    // Do nothing
290
-                } catch (IllegalAccessException ex) {
291
-                    // Do nothing
292
-                } catch (IllegalArgumentException ex) {
293
-                    // Do nothing
294
-                } catch (InvocationTargetException ex) {
288
+                } catch (InstantiationException | IllegalAccessException |
289
+                        IllegalArgumentException | InvocationTargetException ex) {
295 290
                     // Do nothing
296 291
                 }
297 292
             }
@@ -301,12 +296,12 @@ public class CallbackObject {
301 296
     }
302 297
 
303 298
     /**
304
-     * Returns the concrete class which should be instansiated if this
305
-     * callback object desires an instance of the specified type. Generally,
306
-     * this will translate the common interfaces to specific parser-dependent
299
+     * Returns the concrete class which should be instantiated if this callback
300
+     * object desires an instance of the specified type. Generally, this will
301
+     * translate the common interfaces to specific parser-dependent
307 302
      * implementations.
308 303
      *
309
-     * @param type The type to be instansiated
304
+     * @param type The type to be instantiated
310 305
      * @return A concrete implementation of that type
311 306
      */
312 307
     protected Class<?> getImplementation(final Class<?> type) {

+ 3
- 3
src/com/dmdirc/parser/common/CallbackObjectSpecific.java Ver arquivo

@@ -39,7 +39,7 @@ public class CallbackObjectSpecific extends CallbackObject {
39 39
 
40 40
     /** Hashtable for storing specific information for callback. */
41 41
     protected final Map<CallbackInterface, String> specificData
42
-            = new HashMap<CallbackInterface, String>();
42
+            = new HashMap<>();
43 43
 
44 44
     /**
45 45
      * Create a new instance of the Callback Object.
@@ -147,7 +147,7 @@ public class CallbackObjectSpecific extends CallbackObject {
147 147
 
148 148
         createFakeArgs(newArgs);
149 149
 
150
-        for (CallbackInterface iface : new ArrayList<CallbackInterface>(callbackInfo)) {
150
+        for (CallbackInterface iface : new ArrayList<>(callbackInfo)) {
151 151
             if (type.isAnnotationPresent(SpecificCallback.class)
152 152
                     && ((args[0] instanceof ClientInfo
153 153
                     && !isValidUser(iface, ((ClientInfo) args[0]).getHostname()))
@@ -162,7 +162,7 @@ public class CallbackObjectSpecific extends CallbackObject {
162 162
 
163 163
             try {
164 164
                 type.getMethods()[0].invoke(iface, newArgs);
165
-            } catch (Exception e) {
165
+            } catch (ReflectiveOperationException e) {
166 166
                 final ParserError ei = new ParserError(ParserError.ERROR_ERROR,
167 167
                         "Exception in callback (" + e.getMessage() + ")",
168 168
                         myParser.getLastLine());

+ 3
- 5
src/com/dmdirc/parser/common/IgnoreList.java Ver arquivo

@@ -28,13 +28,11 @@ import java.util.regex.PatternSyntaxException;
28 28
 
29 29
 /**
30 30
  * Parser Ignore list.
31
- *
32
- * @author Shane Mc Cormack
33 31
  */
34 32
 public class IgnoreList {
35 33
 
36 34
     /** Arraylist storing ignore patterns. */
37
-    protected final List<String> ignoreInfo = new ArrayList<String>();
35
+    protected final List<String> ignoreInfo = new ArrayList<>();
38 36
 
39 37
     /**
40 38
      * Creates a new instance of RegexStringList.
@@ -193,7 +191,7 @@ public class IgnoreList {
193 191
      * @return All expressions in this ignore list
194 192
      */
195 193
     public List<String> getRegexList() {
196
-        return new ArrayList<String>(ignoreInfo);
194
+        return new ArrayList<>(ignoreInfo);
197 195
     }
198 196
 
199 197
     /**
@@ -203,7 +201,7 @@ public class IgnoreList {
203 201
      * @throws UnsupportedOperationException if an expression can't be converted
204 202
      */
205 203
     public List<String> getSimpleList() throws UnsupportedOperationException {
206
-        final List<String> res = new ArrayList<String>();
204
+        final List<String> res = new ArrayList<>();
207 205
 
208 206
         for (String regex : ignoreInfo) {
209 207
             res.add(regexToSimple(regex));

+ 2
- 2
src/com/dmdirc/parser/irc/IRCAuthenticator.java Ver arquivo

@@ -46,9 +46,9 @@ public final class IRCAuthenticator extends Authenticator {
46 46
     /** Singleton instance of IRCAuthenticator. */
47 47
     private static IRCAuthenticator me;
48 48
     /** List of authentication replies. */
49
-    private final Map<String, PasswordAuthentication> replies = new HashMap<String, PasswordAuthentication>();
49
+    private final Map<String, PasswordAuthentication> replies = new HashMap<>();
50 50
     /** List of servers for each host. */
51
-    private final Map<String, List<URI>> owners = new HashMap<String, List<URI>>();
51
+    private final Map<String, List<URI>> owners = new HashMap<>();
52 52
     /** Semaphore for connection limiting. */
53 53
     private final Semaphore mySemaphore = new Semaphore(1, true);
54 54
 

+ 1
- 1
src/com/dmdirc/parser/irc/IRCChannelClientInfo.java Ver arquivo

@@ -54,7 +54,7 @@ public class IRCChannelClientInfo implements ChannelClientInfo {
54 54
      * @param channel Channel that owns this channelclient
55 55
      */
56 56
     public IRCChannelClientInfo(final IRCParser tParser, final IRCClientInfo client, final ChannelInfo channel) {
57
-        myMap = new HashMap<Object, Object>();
57
+        myMap = new HashMap<>();
58 58
         myParser = tParser;
59 59
         cClient = client;
60 60
         myChannel = channel;

+ 7
- 7
src/com/dmdirc/parser/irc/IRCChannelInfo.java Ver arquivo

@@ -69,20 +69,20 @@ public class IRCChannelInfo implements ChannelInfo {
69 69
     /** Hashtable containing references to ChannelClients. */
70 70
     private final Map<String, IRCChannelClientInfo> clients = Collections.synchronizedMap(new HashMap<String, IRCChannelClientInfo>());
71 71
     /** Hashtable storing values for modes set in the channel that use parameters. */
72
-    private final Map<Character, String> paramModes = new HashMap<Character, String>();
72
+    private final Map<Character, String> paramModes = new HashMap<>();
73 73
     /** Hashtable storing list modes. */
74
-    private final Map<Character, ArrayList<ChannelListModeItem>> listModes = new HashMap<Character, ArrayList<ChannelListModeItem>>();
74
+    private final Map<Character, ArrayList<ChannelListModeItem>> listModes = new HashMap<>();
75 75
     /**
76 76
      * LinkedList storing status of mode adding.
77 77
      * if an item is in this list for a mode, we are expecting new items for the list
78 78
      */
79
-    private final List<Character> addingModes = new LinkedList<Character>();
79
+    private final List<Character> addingModes = new LinkedList<>();
80 80
     /** Modes waiting to be sent to the server. */
81
-    private final List<String> modeQueue = new LinkedList<String>();
81
+    private final List<String> modeQueue = new LinkedList<>();
82 82
     /** A Map to allow applications to attach misc data to this object. */
83 83
     private final Map<Object, Object> map;
84 84
     /** Queue of requested list modes. */
85
-    private final Queue<Character> listModeQueue = new LinkedList<Character>();
85
+    private final Queue<Character> listModeQueue = new LinkedList<>();
86 86
     /** Listmode Queue Time. */
87 87
     private long listModeQueueTime = System.currentTimeMillis();
88 88
     /** Have we asked the server for the list modes for this channel yet? */
@@ -97,7 +97,7 @@ public class IRCChannelInfo implements ChannelInfo {
97 97
      * @param name Channel name.
98 98
      */
99 99
     public IRCChannelInfo(final IRCParser parser, final String name) {
100
-        map = new HashMap<Object, Object>();
100
+        map = new HashMap<>();
101 101
         this.parser = parser;
102 102
         this.name = name;
103 103
     }
@@ -113,7 +113,7 @@ public class IRCChannelInfo implements ChannelInfo {
113 113
         // Incase of breakage, if getListModeQueue() was last called greater than
114 114
         // 60 seconds ago, we reset the list.
115 115
         if (now - (30 * 1000) > listModeQueueTime) {
116
-            result = new LinkedList<Character>();
116
+            result = new LinkedList<>();
117 117
             parser.callDebugInfo(IRCParser.DEBUG_LMQ, "Resetting LMQ");
118 118
         }
119 119
         listModeQueueTime = now;

+ 4
- 4
src/com/dmdirc/parser/irc/IRCClientInfo.java Ver arquivo

@@ -62,9 +62,9 @@ public class IRCClientInfo implements LocalClientInfo {
62 62
     /** A Map to allow applications to attach misc data to this object. */
63 63
     private final Map<Object, Object> map;
64 64
     /** List of ChannelClientInfos that point to this. */
65
-    private final Map<String, IRCChannelClientInfo> clients = new HashMap<String, IRCChannelClientInfo>();
65
+    private final Map<String, IRCChannelClientInfo> clients = new HashMap<>();
66 66
     /** Modes waiting to be sent to the server. */
67
-    private final List<String> modeQueue = new LinkedList<String>();
67
+    private final List<String> modeQueue = new LinkedList<>();
68 68
 
69 69
     /**
70 70
      * Create a new client object from a hostmask.
@@ -74,7 +74,7 @@ public class IRCClientInfo implements LocalClientInfo {
74 74
      * @see IRCClientInfo#parseHost
75 75
      */
76 76
     public IRCClientInfo(final IRCParser tParser, final String sHostmask) {
77
-        map = new HashMap<Object, Object>();
77
+        map = new HashMap<>();
78 78
         setUserBits(sHostmask, true);
79 79
         parser = tParser;
80 80
     }
@@ -393,7 +393,7 @@ public class IRCClientInfo implements LocalClientInfo {
393 393
      * @return int with the count of known channels
394 394
      */
395 395
     public List<IRCChannelClientInfo> getChannelClients() {
396
-        return new ArrayList<IRCChannelClientInfo>(clients.values());
396
+        return new ArrayList<>(clients.values());
397 397
     }
398 398
 
399 399
     /** {@inheritDoc} */

+ 1
- 4
src/com/dmdirc/parser/irc/IRCParser.java Ver arquivo

@@ -1020,10 +1020,7 @@ public class IRCParser extends BaseParser implements SecureParser, EncodingParse
1020 1020
         } catch (IOException e) {
1021 1021
             handleConnectException(e, true);
1022 1022
             return;
1023
-        } catch (NoSuchAlgorithmException e) {
1024
-            handleConnectException(e, false);
1025
-            return;
1026
-        } catch (KeyManagementException e) {
1023
+        } catch (NoSuchAlgorithmException | KeyManagementException e) {
1027 1024
             handleConnectException(e, false);
1028 1025
             return;
1029 1026
         }

+ 24
- 20
src/com/dmdirc/parser/irc/ProcessAway.java Ver arquivo

@@ -19,7 +19,6 @@
19 19
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 20
  * SOFTWARE.
21 21
  */
22
-
23 22
 package com.dmdirc.parser.irc;
24 23
 
25 24
 import com.dmdirc.parser.common.AwayState;
@@ -48,28 +47,33 @@ public class ProcessAway extends IRCProcessor {
48 47
      */
49 48
     @Override
50 49
     public void process(final String sParam, final String[] token) {
51
-        if ("AWAY".equals(sParam)) {
52
-            final IRCClientInfo iClient = getClientInfo(token[0]);
53
-            if (iClient != null) {
54
-                final AwayState oldState = iClient.getAwayState();
50
+        final IRCClientInfo iClient = getClientInfo(token[0]);
51
+        switch (sParam) {
52
+            case "AWAY":
53
+                if (iClient != null) {
54
+                    final AwayState oldState = iClient.getAwayState();
55 55
 
56
-                final String reason = (token.length > 2) ? token[token.length - 1] : "";
57
-                iClient.setAwayReason(reason);
58
-                iClient.setAwayState(reason.isEmpty() ? AwayState.HERE : AwayState.AWAY);
56
+                    final String reason = (token.length > 2) ? token[token.length - 1] : "";
57
+                    iClient.setAwayReason(reason);
58
+                    iClient.setAwayState(reason.isEmpty() ? AwayState.HERE : AwayState.AWAY);
59 59
 
60
-                if (iClient == parser.getLocalClient()) {
61
-                    callAwayState(oldState, iClient.getAwayState(), iClient.getAwayReason());
60
+                    if (iClient == parser.getLocalClient()) {
61
+                        callAwayState(oldState, iClient.getAwayState(), iClient.getAwayReason());
62
+                    }
63
+                }
64
+                break;
65
+            case "301":
66
+                // WHO Response
67
+                if (iClient != null) {
68
+                    iClient.setAwayReason(token[token.length - 1]);
62 69
                 }
63
-            }
64
-        } else if ("301".equals(sParam)) { // WHO Response
65
-            final IRCClientInfo iClient = getClientInfo(token[3]);
66
-            if (iClient != null) {
67
-                iClient.setAwayReason(token[token.length - 1]);
68
-            }
69
-        } else { // IRC HERE/BACK response
70
-            final AwayState oldState = parser.getLocalClient().getAwayState();
71
-            parser.getLocalClient().setAwayState("306".equals(sParam) ? AwayState.AWAY : AwayState.HERE);
72
-            callAwayState(oldState, parser.getLocalClient().getAwayState(), parser.getLocalClient().getAwayReason());
70
+                break;
71
+            default:
72
+                // IRC HERE/BACK response
73
+                final AwayState oldState = parser.getLocalClient().getAwayState();
74
+                parser.getLocalClient().setAwayState("306".equals(sParam) ? AwayState.AWAY : AwayState.HERE);
75
+                callAwayState(oldState, parser.getLocalClient().getAwayState(), parser.getLocalClient().getAwayReason());
76
+                break;
73 77
         }
74 78
     }
75 79
 

+ 1
- 1
src/com/dmdirc/parser/irc/ProcessCap.java Ver arquivo

@@ -42,7 +42,7 @@ public class ProcessCap extends TimestampedIRCProcessor {
42 42
     /** Have we handled the pre-connect cap request? */
43 43
     private boolean hasCapped = false;
44 44
     /** List of supported capabilities. */
45
-    private List<String> supportedCapabilities = new ArrayList<String>();
45
+    private List<String> supportedCapabilities = new ArrayList<>();
46 46
 
47 47
     /**
48 48
      * Create a new instance of the IRCProcessor Object.

+ 13
- 10
src/com/dmdirc/parser/irc/ProcessList.java Ver arquivo

@@ -52,16 +52,19 @@ public class ProcessList extends IRCProcessor {
52 52
         // :port80b.se.quakenet.org 321 MD87 Channel :Users  Name
53 53
         // :port80b.se.quakenet.org 322 MD87 #DMDirc 10 :
54 54
         // :port80b.se.quakenet.org 323 MD87 :End of /LIST
55
-
56
-        if ("321".equals(sParam)) {
57
-            getCallbackManager().getCallback(GroupListStartListener.class)
58
-                    .onGroupListStart(null, null);
59
-        } else if ("322".equals(sParam)) {
60
-            getCallbackManager().getCallback(GroupListEntryListener.class)
61
-                    .onGroupListEntry(null, null, token[3], Integer.parseInt(token[4]), token[5]);
62
-        } else if ("323".equals(sParam)) {
63
-            getCallbackManager().getCallback(GroupListEndListener.class)
64
-                    .onGroupListEnd(null, null);
55
+        switch (sParam) {
56
+            case "321":
57
+                getCallbackManager().getCallback(GroupListStartListener.class)
58
+                        .onGroupListStart(null, null);
59
+                break;
60
+            case "322":
61
+                getCallbackManager().getCallback(GroupListEntryListener.class)
62
+                        .onGroupListEntry(null, null, token[3], Integer.parseInt(token[4]), token[5]);
63
+                break;
64
+            case "323":
65
+                getCallbackManager().getCallback(GroupListEndListener.class)
66
+                        .onGroupListEnd(null, null);
67
+                break;
65 68
         }
66 69
     }
67 70
 

+ 10
- 6
src/com/dmdirc/parser/irc/ProcessMOTD.java Ver arquivo

@@ -49,12 +49,16 @@ public class ProcessMOTD extends IRCProcessor {
49 49
      */
50 50
     @Override
51 51
     public void process(final String sParam, final String[] token) {
52
-        if ("375".equals(sParam)) {
53
-            callMOTDStart(token[token.length - 1]);
54
-        } else if ("372".equals(sParam)) {
55
-            callMOTDLine(token[token.length - 1]);
56
-        } else {
57
-            callMOTDEnd("422".equals(sParam), token[token.length - 1]);
52
+        switch (sParam) {
53
+            case "375":
54
+                callMOTDStart(token[token.length - 1]);
55
+                break;
56
+            case "372":
57
+                callMOTDLine(token[token.length - 1]);
58
+                break;
59
+            default:
60
+                callMOTDEnd("422".equals(sParam), token[token.length - 1]);
61
+                break;
58 62
         }
59 63
     }
60 64
 

+ 14
- 11
src/com/dmdirc/parser/irc/ProcessMode.java Ver arquivo

@@ -62,17 +62,20 @@ public class ProcessMode extends IRCProcessor {
62 62
     public void process(final String sParam, final String[] token) {
63 63
         String[] sModestr;
64 64
         String sChannelName;
65
-        if (sParam.equals("324")) {
66
-            sChannelName = token[3];
67
-            sModestr = new String[token.length - 4];
68
-            System.arraycopy(token, 4, sModestr, 0, token.length - 4);
69
-        } else if (sParam.equals("221")) {
70
-            processUserMode(sParam, token, new String[]{token[token.length - 1]}, true);
71
-            return;
72
-        } else {
73
-            sChannelName = token[2];
74
-            sModestr = new String[token.length - 3];
75
-            System.arraycopy(token, 3, sModestr, 0, token.length - 3);
65
+        switch (sParam) {
66
+            case "324":
67
+                sChannelName = token[3];
68
+                sModestr = new String[token.length - 4];
69
+                System.arraycopy(token, 4, sModestr, 0, token.length - 4);
70
+                break;
71
+            case "221":
72
+                processUserMode(sParam, token, new String[]{token[token.length - 1]}, true);
73
+                return;
74
+            default:
75
+                sChannelName = token[2];
76
+                sModestr = new String[token.length - 3];
77
+                System.arraycopy(token, 3, sModestr, 0, token.length - 3);
78
+                break;
76 79
         }
77 80
 
78 81
         if (isValidChannelName(sChannelName)) {

+ 1
- 1
src/com/dmdirc/parser/irc/ProcessQuit.java Ver arquivo

@@ -76,7 +76,7 @@ public class ProcessQuit extends IRCProcessor {
76 76
             sReason = token[token.length - 1];
77 77
         }
78 78
 
79
-        final List<IRCChannelInfo> channelList = new ArrayList<IRCChannelInfo>(parser.getChannels());
79
+        final List<IRCChannelInfo> channelList = new ArrayList<>(parser.getChannels());
80 80
         for (IRCChannelInfo iChannel : channelList) {
81 81
             iChannelClient = iChannel.getChannelClient(iClient);
82 82
             if (iChannelClient != null) {

+ 28
- 29
src/com/dmdirc/parser/irc/ProcessTopic.java Ver arquivo

@@ -49,44 +49,43 @@ public class ProcessTopic extends IRCProcessor {
49 49
     @Override
50 50
     public void process(final String sParam, final String[] token) {
51 51
         IRCChannelInfo iChannel;
52
-        if (sParam.equals("332")) {
53
-            iChannel = getChannel(token[3]);
54
-            if (iChannel == null) {
55
-                return;
56
-            }
57
-            iChannel.setInternalTopic(token[token.length - 1]);
58
-        } else if (sParam.equals("333")) {
59
-            if (token.length > 3) {
52
+        switch (sParam) {
53
+            case "332":
60 54
                 iChannel = getChannel(token[3]);
61 55
                 if (iChannel == null) {
62 56
                     return;
63
-                }
64
-                if (token.length > 4) {
65
-                    iChannel.setTopicUser(token[4]);
66
-                    if (token.length > 5) {
67
-                        iChannel.setTopicTime(Long.parseLong(token[5]));
57
+                }   iChannel.setInternalTopic(token[token.length - 1]);
58
+                break;
59
+            case "333":
60
+                if (token.length > 3) {
61
+                    iChannel = getChannel(token[3]);
62
+                    if (iChannel == null) {
63
+                        return;
64
+                    }
65
+                    if (token.length > 4) {
66
+                        iChannel.setTopicUser(token[4]);
67
+                        if (token.length > 5) {
68
+                            iChannel.setTopicTime(Long.parseLong(token[5]));
69
+                        }
70
+                    }
71
+                    callChannelTopic(iChannel, true);
72
+                }   break;
73
+            default:
74
+                if (IRCParser.ALWAYS_UPDATECLIENT) {
75
+                    final IRCClientInfo iClient = getClientInfo(token[0]);
76
+                    if (iClient != null && iClient.getHostname().isEmpty()) {
77
+                        iClient.setUserBits(token[0], false);
68 78
                     }
69
-                }
70
-                callChannelTopic(iChannel, true);
71
-            }
72
-        } else {
73
-            if (IRCParser.ALWAYS_UPDATECLIENT) {
74
-                final IRCClientInfo iClient = getClientInfo(token[0]);
75
-                if (iClient != null && iClient.getHostname().isEmpty()) {
76
-                    iClient.setUserBits(token[0], false);
77
-                }
78
-            }
79
-            iChannel = getChannel(token[2]);
79
+                }   iChannel = getChannel(token[2]);
80 80
             if (iChannel == null) {
81 81
                 return;
82
-            }
83
-            iChannel.setTopicTime(System.currentTimeMillis() / 1000);
82
+            }   iChannel.setTopicTime(System.currentTimeMillis() / 1000);
84 83
             if (token[0].charAt(0) == ':') {
85 84
                 token[0] = token[0].substring(1);
86
-            }
87
-            iChannel.setTopicUser(token[0]);
85
+            }   iChannel.setTopicUser(token[0]);
88 86
             iChannel.setInternalTopic(token[token.length - 1]);
89
-            callChannelTopic(iChannel, false);
87
+                callChannelTopic(iChannel, false);
88
+                break;
90 89
         }
91 90
     }
92 91
 

+ 1
- 1
src/com/dmdirc/parser/irc/ProcessingManager.java Ver arquivo

@@ -38,7 +38,7 @@ public class ProcessingManager {
38 38
     /** Reference to the parser object that owns this ProcessingManager. */
39 39
     private final IRCParser parser;
40 40
     /** Hashtable used to store the different types of IRCProcessor known. */
41
-    private final Map<String, IRCProcessor> processHash = new HashMap<String, IRCProcessor>();
41
+    private final Map<String, IRCProcessor> processHash = new HashMap<>();
42 42
 
43 43
     /**
44 44
      * Constructor to create a ProcessingManager.

+ 1
- 1
src/com/dmdirc/parser/irc/outputqueue/OutputQueue.java Ver arquivo

@@ -39,7 +39,7 @@ public class OutputQueue {
39 39
     /** Is queueing enabled? */
40 40
     private boolean queueEnabled = true;
41 41
     /** The output queue! */
42
-    private final BlockingQueue<QueueItem> queue = new PriorityBlockingQueue<QueueItem>();
42
+    private final BlockingQueue<QueueItem> queue = new PriorityBlockingQueue<>();
43 43
     /** Object for synchronising access to the {@link #queueHandler}. */
44 44
     private final Object queueHandlerLock = new Object();
45 45
     /** Thread for the sending queue. */

+ 1
- 1
test/com/dmdirc/harness/parser/TestParser.java Ver arquivo

@@ -40,7 +40,7 @@ import java.util.Timer;
40 40
 })
41 41
 public class TestParser extends IRCParser implements Parser {
42 42
 
43
-    public final List<String> sentLines = new ArrayList<String>();
43
+    public final List<String> sentLines = new ArrayList<>();
44 44
 
45 45
     public String nick = "nick";
46 46
 

+ 1
- 1
test/com/dmdirc/parser/common/IgnoreListTest.java Ver arquivo

@@ -115,7 +115,7 @@ public class IgnoreListTest {
115 115
     @Test
116 116
     public void testGetSimpleList() throws UnsupportedOperationException {
117 117
         final IgnoreList list = new IgnoreList();
118
-        final List<String> items = new ArrayList<String>();
118
+        final List<String> items = new ArrayList<>();
119 119
         
120 120
         for (String[] test : tests) {
121 121
             items.add(test[0]);

+ 2
- 2
test/com/dmdirc/parser/irc/ChannelClientInfoTest.java Ver arquivo

@@ -69,8 +69,8 @@ public class ChannelClientInfoTest {
69 69
 
70 70
         parser.injectConnectionStrings();
71 71
         parser.injectLine(":nick JOIN #DMDirc_testing");
72
-        final Map<Object, Object> map1 = new HashMap<Object, Object>();
73
-        final Map<Object, Object> map2 = new HashMap<Object, Object>();
72
+        final Map<Object, Object> map1 = new HashMap<>();
73
+        final Map<Object, Object> map2 = new HashMap<>();
74 74
         
75 75
         final IRCChannelClientInfo cci = parser.getClient("nick").getChannelClients().get(0);
76 76
         

+ 4
- 4
test/com/dmdirc/parser/irc/RegexStringListTest.java Ver arquivo

@@ -42,7 +42,7 @@ public class RegexStringListTest {
42 42
 
43 43
     @Test
44 44
     public void testAddAll() {
45
-        final List<String> tempList = new ArrayList<String>();
45
+        final List<String> tempList = new ArrayList<>();
46 46
         tempList.add("a!b@c");
47 47
         tempList.add("a!b@c");
48 48
         tempList.add("A!B@C");
@@ -57,7 +57,7 @@ public class RegexStringListTest {
57 57
 
58 58
     @Test
59 59
     public void testRmove() {
60
-        final List<String> tempList = new ArrayList<String>();
60
+        final List<String> tempList = new ArrayList<>();
61 61
         tempList.add("a!b@c");
62 62
         tempList.add("Data.*");
63 63
 
@@ -71,7 +71,7 @@ public class RegexStringListTest {
71 71
 
72 72
     @Test
73 73
     public void testClear() {
74
-        final List<String> tempList = new ArrayList<String>();
74
+        final List<String> tempList = new ArrayList<>();
75 75
         tempList.add("a!b@c");
76 76
         tempList.add("Data.*");
77 77
 
@@ -83,7 +83,7 @@ public class RegexStringListTest {
83 83
 
84 84
     @Test
85 85
     public void testMatches() {
86
-        final List<String> tempList = new ArrayList<String>();
86
+        final List<String> tempList = new ArrayList<>();
87 87
         tempList.add("a!b@c");
88 88
         tempList.add("Data.*");
89 89
 

Carregando…
Cancelar
Salvar