diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-15 16:06:32 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-15 16:06:32 +0200 |
commit | a85308ec103a69a86a8e02adf02112d472b00568 (patch) | |
tree | a1fe0ef9fe221292774ef280e4d8f0d55cf1555c /testing/src | |
parent | 9cab74717265239e03d1aec53c5ec60a6d7d9718 (diff) | |
download | aspectj-a85308ec103a69a86a8e02adf02112d472b00568.tar.gz aspectj-a85308ec103a69a86a8e02adf02112d472b00568.zip |
Manual array to collection copy
Reports the copying of array contents to a collection where each element is added individually using a for loop. Such constructs may be replaced by a call to Collection.addAll(Arrays.asList()) or Collections.addAll().
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'testing/src')
3 files changed, 4 insertions, 16 deletions
diff --git a/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java b/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java index 546eadba3..98878dcbc 100644 --- a/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java +++ b/testing/src/test/java/org/aspectj/internal/tools/ant/taskdefs/Ajctest.java @@ -36,13 +36,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.text.DateFormat; //import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.Vector; +import java.util.*; import javax.swing.BorderFactory; import javax.swing.BoxLayout; @@ -1426,9 +1420,7 @@ public class Ajctest extends Task implements PropertyChangeListener { public AjdocWrapper(Testset testset, List args) { super(testset, ajdocArgs(args), true); String[] cmds = testset.getAjdoc().getCommandline().getCommandline(); - for (String cmd : cmds) { - this.args.add(cmd); - } + Collections.addAll(this.args, cmds); } String getMainClassName() { return "org.aspectj.tools.ajdoc.Main"; diff --git a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java index e5e2fcdb9..81e2616ea 100644 --- a/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java +++ b/testing/src/test/java/org/aspectj/testing/XMLBasedAjcTestCase.java @@ -415,9 +415,7 @@ public abstract class XMLBasedAjcTestCase extends AjcTestCase { public List<LocalVariable> sortedLocalVariables(LocalVariableTable lvt) { List<LocalVariable> l = new ArrayList<>(); LocalVariable lv[] = lvt.getLocalVariableTable(); - for (LocalVariable lvEntry : lv) { - l.add(lvEntry); - } + Collections.addAll(l, lv); Collections.sort(l, new MyComparator()); return l; } diff --git a/testing/src/test/java/org/aspectj/testing/util/options/Values.java b/testing/src/test/java/org/aspectj/testing/util/options/Values.java index 7a04fbed0..608d4a610 100644 --- a/testing/src/test/java/org/aspectj/testing/util/options/Values.java +++ b/testing/src/test/java/org/aspectj/testing/util/options/Values.java @@ -398,9 +398,7 @@ public class Values { String s = value.prefix.render(output[0]); if (null != s) { // this means the prefix is set list.add(s); - for (int j = 1; j < output.length; j++) { - list.add(output[j]); - } + list.addAll(Arrays.asList(output).subList(1, output.length)); } } } |