Explorar el Código

Use forEach where possible.

pull/39/head
Chris Smith hace 9 años
padre
commit
6c38b5789d

+ 6
- 10
common/src/com/dmdirc/parser/common/CallbackManager.java Ver fichero

217
      * @param o instance of ICallbackInterface to remove.
217
      * @param o instance of ICallbackInterface to remove.
218
      */
218
      */
219
     public void delAllCallback(final CallbackInterface o) {
219
     public void delAllCallback(final CallbackInterface o) {
220
-        for (CallbackObject cb : callbackHash.values()) {
221
-            if (cb != null && cb.getType().isInstance(o)) {
222
-                cb.del(o);
223
-            }
224
-        }
220
+        callbackHash.values().stream()
221
+                .filter(cb -> cb != null && cb.getType().isInstance(o))
222
+                .forEach(cb -> cb.del(o));
225
     }
223
     }
226
 
224
 
227
     /**
225
     /**
230
      * @param o instance of ICallbackInterface to add.
228
      * @param o instance of ICallbackInterface to add.
231
      */
229
      */
232
     public void addAllCallback(final CallbackInterface o) {
230
     public void addAllCallback(final CallbackInterface o) {
233
-        for (CallbackObject cb : callbackHash.values()) {
234
-            if (cb != null && cb.getType().isInstance(o)) {
235
-                cb.add(o);
236
-            }
237
-        }
231
+        callbackHash.values().stream()
232
+                .filter(cb -> cb != null && cb.getType().isInstance(o))
233
+                .forEach(cb -> cb.add(o));
238
     }
234
     }
239
 
235
 
240
     /**
236
     /**

+ 2
- 7
common/src/com/dmdirc/parser/common/IgnoreList.java Ver fichero

25
 import java.util.ArrayList;
25
 import java.util.ArrayList;
26
 import java.util.List;
26
 import java.util.List;
27
 import java.util.regex.PatternSyntaxException;
27
 import java.util.regex.PatternSyntaxException;
28
+import java.util.stream.Collectors;
28
 
29
 
29
 /**
30
 /**
30
  * Parser Ignore list.
31
  * Parser Ignore list.
197
      * @throws UnsupportedOperationException if an expression can't be converted
198
      * @throws UnsupportedOperationException if an expression can't be converted
198
      */
199
      */
199
     public List<String> getSimpleList() throws UnsupportedOperationException {
200
     public List<String> getSimpleList() throws UnsupportedOperationException {
200
-        final List<String> res = new ArrayList<>();
201
-
202
-        for (String regex : ignoreInfo) {
203
-            res.add(regexToSimple(regex));
204
-        }
205
-
206
-        return res;
201
+        return ignoreInfo.stream().map(IgnoreList::regexToSimple).collect(Collectors.toList());
207
     }
202
     }
208
 
203
 
209
     /**
204
     /**

Loading…
Cancelar
Guardar