Skip to content

Commit 8932496

Browse files
committed
Use Comparators.lexicographical instead of Ordering.from in DeclaredMembers
1 parent d83f677 commit 8932496

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

core/src/com/google/inject/internal/DeclaredMembers.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.google.inject.internal;
1717

18+
import com.google.common.collect.Comparators;
1819
import com.google.common.collect.Ordering;
1920
import java.lang.reflect.Field;
2021
import java.lang.reflect.Method;
@@ -46,14 +47,14 @@ public static Field[] getDeclaredFields(Class<?> type) {
4647

4748
public static Method[] getDeclaredMethods(Class<?> type) {
4849
return Arrays.stream(type.getDeclaredMethods())
49-
.sorted(
50-
Comparator.comparing(Method::getName)
51-
.thenComparing(Method::getReturnType, Comparator.comparing(Class::getName))
52-
.thenComparing(
53-
method -> Arrays.asList(method.getParameterTypes()),
54-
// TODO: use Comparators.lexicographical when it's not @Beta.
55-
Ordering.<Class<?>>from(Comparator.comparing(Class::getName))
56-
.lexicographical()))
57-
.toArray(Method[]::new);
50+
.sorted(
51+
Comparator.comparing(Method::getName)
52+
.thenComparing(Method::getReturnType, Comparator.comparing(Class::getName))
53+
.thenComparing(
54+
method -> Arrays.asList(method.getParameterTypes()),
55+
Comparators.lexicographical(Comparator.comparing(Class::getName))
56+
)
57+
)
58+
.toArray(Method[]::new);
5859
}
5960
}

0 commit comments

Comments
 (0)