Inline Collections.sort().

This commit is contained in:
Gary Gregory 2022-02-13 11:25:56 -05:00
parent 4984c96072
commit 8ea386b864
8 changed files with 11 additions and 11 deletions

View File

@ -1229,7 +1229,7 @@ public class CollectionUtilsTest extends MockTestCase {
final List<Integer> combinedList = new ArrayList<>(collectionD);
combinedList.addAll(collectionE);
Collections.sort(combinedList);
combinedList.sort(null);
assertEquals(combinedList, result2, "Merge two lists 2");
@ -1258,7 +1258,7 @@ public class CollectionUtilsTest extends MockTestCase {
final Set<Integer> combinedSet = new HashSet<>(collectionD);
combinedSet.addAll(collectionE);
final List<Integer> combinedList = new ArrayList<>(combinedSet);
Collections.sort(combinedList);
combinedList.sort(null);
assertEquals(combinedList, result2, "Merge two lists 2 - ignore duplicates");
}

View File

@ -161,7 +161,7 @@ public class FluentIterableTest {
final List<Integer> combinedList = new ArrayList<>();
CollectionUtils.addAll(combinedList, iterableOdd);
CollectionUtils.addAll(combinedList, iterableEven);
Collections.sort(combinedList);
combinedList.sort(null);
assertEquals(combinedList, result);
try {
@ -183,7 +183,7 @@ public class FluentIterableTest {
final List<Integer> combinedList = new ArrayList<>();
CollectionUtils.addAll(combinedList, iterableOdd);
CollectionUtils.addAll(combinedList, iterableEven);
Collections.sort(combinedList);
combinedList.sort(null);
assertEquals(combinedList, result);
// null comparator is equivalent to natural ordering
@ -352,7 +352,7 @@ public class FluentIterableTest {
List<Integer> combinedList = new ArrayList<>();
CollectionUtils.addAll(combinedList, iterableOdd);
CollectionUtils.addAll(combinedList, iterableEven);
Collections.sort(combinedList);
combinedList.sort(null);
assertEquals(combinedList, result);
try {

View File

@ -579,7 +579,7 @@ public class IteratorUtilsTest {
final List<Integer> combinedList = new ArrayList<>(collectionOdd);
combinedList.addAll(collectionEven);
Collections.sort(combinedList);
combinedList.sort(null);
assertEquals(combinedList, result);

View File

@ -44,7 +44,7 @@ public abstract class AbstractSortedBidiMapTest<K extends Comparable<K>, V exten
public AbstractSortedBidiMapTest(final String testName) {
super(testName);
sortedKeys = getAsList(getSampleKeys());
Collections.sort(sortedKeys);
sortedKeys.sort(null);
sortedKeys = Collections.unmodifiableList(sortedKeys);
final Map<K, V> map = new TreeMap<>();

View File

@ -129,7 +129,7 @@ public class DualTreeBidiMap2Test<K extends Comparable<K>, V extends Comparable<
// Sort by the comparator used in the makeEmptyBidiMap() method
List<K> newSortedKeys = getAsList(getSampleKeys());
Collections.sort(newSortedKeys, new ReverseComparator<>(ComparableComparator.<K>comparableComparator()));
newSortedKeys.sort(new ReverseComparator<>(ComparableComparator.<K>comparableComparator()));
newSortedKeys = Collections.unmodifiableList(newSortedKeys);
final Iterator<K> mapIter = sm.keySet().iterator();

View File

@ -74,7 +74,7 @@ public abstract class AbstractAvailableLocalesTest {
}
}
}
Collections.sort(availableLocales, new ObjectToStringComparator());
availableLocales.sort(ObjectToStringComparator.INSTANCE);
return availableLocales;
}

View File

@ -27,7 +27,7 @@ public final class ObjectToStringComparator implements Comparator<Object>, Seria
*
* @since 4.5
*/
public final ObjectToStringComparator INSTANCE = new ObjectToStringComparator();
public static final ObjectToStringComparator INSTANCE = new ObjectToStringComparator();
private static final long serialVersionUID = 1L;

View File

@ -78,7 +78,7 @@ public abstract class AbstractOrderedMapTest<K, V> extends AbstractIterableMapTe
@SuppressWarnings("unchecked")
public K[] getSampleKeys() {
final List<K> list = new ArrayList<>(Arrays.asList(super.getSampleKeys()));
Collections.sort(list, new NullComparator<K>());
list.sort(new NullComparator<K>());
return (K[]) list.toArray();
}