Skip to content

Commit f2a71af

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

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

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

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

18-
import com.google.common.collect.Ordering;
18+
import com.google.common.collect.Comparators;
1919
import java.lang.reflect.Field;
2020
import java.lang.reflect.Method;
2121
import java.util.Arrays;
@@ -34,26 +34,26 @@
3434
*/
3535
public final class DeclaredMembers {
3636

37-
private DeclaredMembers() {}
37+
private DeclaredMembers() {}
3838

39-
public static Field[] getDeclaredFields(Class<?> type) {
40-
return Arrays.stream(type.getDeclaredFields())
41-
.sorted(
42-
Comparator.comparing(Field::getName)
43-
.thenComparing(Field::getType, Comparator.comparing(Class::getName)))
44-
.toArray(Field[]::new);
45-
}
39+
public static Field[] getDeclaredFields(Class<?> type) {
40+
return Arrays.stream(type.getDeclaredFields())
41+
.sorted(
42+
Comparator.comparing(Field::getName)
43+
.thenComparing(Field::getType, Comparator.comparing(Class::getName)))
44+
.toArray(Field[]::new);
45+
}
4646

47-
public static Method[] getDeclaredMethods(Class<?> type) {
48-
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);
58-
}
47+
public static Method[] getDeclaredMethods(Class<?> type) {
48+
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+
Comparators.lexicographical(Comparator.comparing(Class::getName))
55+
)
56+
)
57+
.toArray(Method[]::new);
58+
}
5959
}

0 commit comments

Comments
 (0)