Skip to content

Commit

Permalink
Use Comparators.lexicographical instead of Ordering.from in DeclaredM…
Browse files Browse the repository at this point in the history
…embers
  • Loading branch information
panic08 committed Oct 24, 2024
1 parent d83f677 commit 8932496
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions core/src/com/google/inject/internal/DeclaredMembers.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.inject.internal;

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

public static Method[] getDeclaredMethods(Class<?> type) {
return Arrays.stream(type.getDeclaredMethods())
.sorted(
Comparator.comparing(Method::getName)
.thenComparing(Method::getReturnType, Comparator.comparing(Class::getName))
.thenComparing(
method -> Arrays.asList(method.getParameterTypes()),
// TODO: use Comparators.lexicographical when it's not @Beta.
Ordering.<Class<?>>from(Comparator.comparing(Class::getName))
.lexicographical()))
.toArray(Method[]::new);
.sorted(
Comparator.comparing(Method::getName)
.thenComparing(Method::getReturnType, Comparator.comparing(Class::getName))
.thenComparing(
method -> Arrays.asList(method.getParameterTypes()),
Comparators.lexicographical(Comparator.comparing(Class::getName))
)
)
.toArray(Method[]::new);
}
}

0 comments on commit 8932496

Please sign in to comment.