Reports calls to Collections.sort(list, comparator) which could be replaced with list.sort(comparator).
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
private void sortModel(BuildConfigNode node, Comparator<BuildConfigNode> comparator) {
if (node == null || node.getChildren() == null)
return;
- Collections.sort(node.getChildren(), comparator);
+ node.getChildren().sort(comparator);
for (BuildConfigNode nextNode : node.getChildren()) {
if (nextNode != null)
sortModel(nextNode, comparator);
private void sortView(IStructureViewNode node, Comparator<IStructureViewNode> comparator) {
if (node == null || node.getChildren() == null) return;
- Collections.sort(node.getChildren(), comparator);
+ node.getChildren().sort(comparator);
for (Object o : node.getChildren()) {
IStructureViewNode nextNode = (IStructureViewNode) o;
if (nextNode != null) sortView(nextNode, comparator);
relevantFields.add(field);
}
}
- Collections.sort(relevantFields, new FieldComparator());
+ relevantFields.sort(new FieldComparator());
int relevantFlags = Constants.ACC_PUBLIC | Constants.ACC_PRIVATE | Constants.ACC_PROTECTED | Constants.ACC_STATIC
| Constants.ACC_FINAL | Constants.ACC_VOLATILE | Constants.ACC_TRANSIENT;
for (Field f : relevantFields) {
relevantMethods.add(m);
}
}
- Collections.sort(relevantCtors, new ConstructorComparator());
- Collections.sort(relevantMethods, new MethodComparator());
+ relevantCtors.sort(new ConstructorComparator());
+ relevantMethods.sort(new MethodComparator());
// 5. If a class initializer exists, write out the following:
// 1. The name of the method, <clinit>.
List<Sample> getSortedSamples(Comparator<Sample> comparer) {
ArrayList<Sample> result = new ArrayList<>();
result.addAll(samples);
- Collections.sort(result, comparer);
+ result.sort(comparer);
return result;
}
}
List<LocalVariable> l = new ArrayList<>();
LocalVariable lv[] = lvt.getLocalVariableTable();
Collections.addAll(l, lv);
- Collections.sort(l, new MyComparator());
+ l.sort(new MyComparator());
return l;
}
if (LangUtil.isEmpty(skip)) {
sink.addAll(Arrays.asList(source));
- Collections.sort(sink, MESSAGE_LINEKIND);
+ sink.sort(MESSAGE_LINEKIND);
return sink;
}
for (IMessage message : source) {
sink.add(message);
}
}
- Collections.sort(sink, MESSAGE_LINEKIND);
+ sink.sort(MESSAGE_LINEKIND);
return sink;
}
ArrayList expected = new ArrayList();
expected.addAll(expectedListIn);
- Collections.sort(expected, comparator);
+ expected.sort(comparator);
ArrayList actual = new ArrayList();
actual.addAll(actualListIn);
- Collections.sort(actual, comparator);
+ actual.sort(comparator);
Iterator actualIter = actual.iterator();
Object act = null;
assertFalse(typeA.isMissing());
List<ResolvedMember> viaIteratorList = getThemAll(typeA.getMethods(wantGenerics, true));
List<ResolvedMember> directlyList = typeA.getMethodsWithoutIterator(true, true, wantGenerics);
- Collections.sort(viaIteratorList, new ResolvedMemberComparator());
- Collections.sort(directlyList, new ResolvedMemberComparator());
+ viaIteratorList.sort(new ResolvedMemberComparator());
+ directlyList.sort(new ResolvedMemberComparator());
compare(viaIteratorList, directlyList, name);
// System.out.println(toString(viaIteratorList, directlyList, genericsAware));
}
}
// sort by index
- Collections.sort(arguments, new Comparator<MethodArgument>() {
+ arguments.sort(new Comparator<MethodArgument>() {
public int compare(MethodArgument mo, MethodArgument mo1) {
if (mo.indexOnStack == mo1.indexOnStack) {
return 0;
}
private void weaveInAddedMethods() {
- Collections.sort(addedLazyMethodGens, new Comparator<LazyMethodGen>() {
+ addedLazyMethodGens.sort(new Comparator<LazyMethodGen>() {
public int compare(LazyMethodGen aa, LazyMethodGen bb) {
int i = aa.getName().compareTo(bb.getName());
if (i != 0) {
// this code may need
// a bit of alteration...
- Collections.sort(shadowMungerList, new Comparator<ShadowMunger>() {
+ shadowMungerList.sort(new Comparator<ShadowMunger>() {
public int compare(ShadowMunger sm1, ShadowMunger sm2) {
if (sm1.getSourceLocation() == null) {
return (sm2.getSourceLocation() == null ? 0 : 1);
lists.add(list);
List<Map.Entry<BcelShadow, Field>> entries = new ArrayList<>(tjpFields.entrySet());
- Collections.sort(entries, new Comparator<Map.Entry<BcelShadow, Field>>() {
+ entries.sort(new Comparator<Map.Entry<BcelShadow, Field>>() {
@Override
public int compare(Map.Entry<BcelShadow, Field> a, Map.Entry<BcelShadow, Field> b) {
return (a.getValue()).getName().compareTo((b.getValue()).getName());