Skip to content

Commit

Permalink
- fixes a bug where the type summary would not be deterministic
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet committed Nov 19, 2020
1 parent 08f5822 commit f9ee25d
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions typesummary/app/src/main/java/typesummary/App.java
Expand Up @@ -17,7 +17,7 @@

import com.google.common.reflect.ClassPath.ClassInfo;
import com.google.common.reflect.ClassPath;

import com.google.common.base.Joiner;
public class App {
// -o absolutepathpath.txt to output to text file instead of console
public static void main(String[] args) throws Exception {
Expand Down Expand Up @@ -106,9 +106,26 @@ private static void serializeFields(final Class<?> clazz, final ILogWriter write
}
}
private static List<String> methodsNameToSkip;
private static String delimiter = " ";
private static void serializeMethods(final Class<?> clazz, final ILogWriter writer) {
final Method[] methods = clazz.getMethods();
Arrays.sort(methods, (o1, o2) -> o1.getName().compareTo(o2.getName()));
Arrays.sort(methods, (o1, o2) -> (o1.getName() +
Joiner.on(delimiter)
.useForNull("")
.join(Arrays.asList(o1.getParameters())
.stream()
.sequential()
.map(x -> x.getName() + x.getType().getName())
.collect(Collectors.toList())))
.compareTo(o2.getName() +
Joiner.on(delimiter)
.useForNull("")
.join(Arrays.asList(o2.getParameters())
.stream()
.sequential()
.map(x -> x.getName() + x.getType().getName())
.collect(Collectors.toList())))
);
for(Method method : methods) {
if(!methodsNameToSkip.contains(method.getName())) {
writer.write("method " + method.getName(), 2);
Expand Down

0 comments on commit f9ee25d

Please sign in to comment.