You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/06/13 14:44:14 UTC
[commons-lang] branch master updated: [LANG-1561] use List.sort
instead of Collection.sort (#546)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-lang.git
The following commit(s) were added to refs/heads/master by this push:
new 7651124 [LANG-1561] use List.sort instead of Collection.sort (#546)
7651124 is described below
commit 7651124bec8a74366fcc70af41ccaa2e441dec3b
Author: XenoAmess <xe...@gmail.com>
AuthorDate: Sat Jun 13 22:44:05 2020 +0800
[LANG-1561] use List.sort instead of Collection.sort (#546)
* use_List_sort
* Update MethodUtils.java
* Update ObjectToStringComparatorTest.java
---
src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java | 3 +--
.../apache/commons/lang3/compare/ObjectToStringComparatorTest.java | 7 +++----
2 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
index 1d76ce6..a706ab0 100644
--- a/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
+++ b/src/main/java/org/apache/commons/lang3/reflect/MethodUtils.java
@@ -25,7 +25,6 @@ import java.lang.reflect.Type;
import java.lang.reflect.TypeVariable;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.LinkedHashSet;
@@ -694,7 +693,7 @@ public class MethodUtils {
}
// Sort methods by signature to force deterministic result
- Collections.sort(matchingMethods, METHOD_BY_SIGNATURE);
+ matchingMethods.sort(METHOD_BY_SIGNATURE);
Method bestMatch = null;
for (final Method method : matchingMethods) {
diff --git a/src/test/java/org/apache/commons/lang3/compare/ObjectToStringComparatorTest.java b/src/test/java/org/apache/commons/lang3/compare/ObjectToStringComparatorTest.java
index c233cf1..489c310 100644
--- a/src/test/java/org/apache/commons/lang3/compare/ObjectToStringComparatorTest.java
+++ b/src/test/java/org/apache/commons/lang3/compare/ObjectToStringComparatorTest.java
@@ -20,7 +20,6 @@ package org.apache.commons.lang3.compare;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import org.junit.jupiter.api.Test;
@@ -47,7 +46,7 @@ public class ObjectToStringComparatorTest {
@Test
public void testNull() {
final List<Thing> things = Arrays.asList(null, new Thing("y"), null);
- Collections.sort(things, ObjectToStringComparator.INSTANCE);
+ things.sort(ObjectToStringComparator.INSTANCE);
assertEquals("y", things.get(0).string);
assertEquals(null, things.get(1));
assertEquals(null, things.get(2));
@@ -56,7 +55,7 @@ public class ObjectToStringComparatorTest {
@Test
public void testNullToString() {
final List<Thing> things = Arrays.asList(new Thing(null), new Thing("y"), new Thing(null));
- Collections.sort(things, ObjectToStringComparator.INSTANCE);
+ things.sort(ObjectToStringComparator.INSTANCE);
assertEquals("y", things.get(0).string);
assertEquals(null, things.get(1).string);
assertEquals(null, things.get(2).string);
@@ -65,7 +64,7 @@ public class ObjectToStringComparatorTest {
@Test
public void testSortCollection() {
final List<Thing> things = Arrays.asList(new Thing("z"), new Thing("y"), new Thing("x"));
- Collections.sort(things, ObjectToStringComparator.INSTANCE);
+ things.sort(ObjectToStringComparator.INSTANCE);
assertEquals("x", things.get(0).string);
assertEquals("y", things.get(1).string);
assertEquals("z", things.get(2).string);