Skip to content

Commit f9ee25d

Browse files
committed
- fixes a bug where the type summary would not be deterministic
1 parent 08f5822 commit f9ee25d

File tree

1 file changed

+19
-2
lines changed
  • typesummary/app/src/main/java/typesummary

1 file changed

+19
-2
lines changed

typesummary/app/src/main/java/typesummary/App.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import com.google.common.reflect.ClassPath.ClassInfo;
1919
import com.google.common.reflect.ClassPath;
20-
20+
import com.google.common.base.Joiner;
2121
public class App {
2222
// -o absolutepathpath.txt to output to text file instead of console
2323
public static void main(String[] args) throws Exception {
@@ -106,9 +106,26 @@ private static void serializeFields(final Class<?> clazz, final ILogWriter write
106106
}
107107
}
108108
private static List<String> methodsNameToSkip;
109+
private static String delimiter = " ";
109110
private static void serializeMethods(final Class<?> clazz, final ILogWriter writer) {
110111
final Method[] methods = clazz.getMethods();
111-
Arrays.sort(methods, (o1, o2) -> o1.getName().compareTo(o2.getName()));
112+
Arrays.sort(methods, (o1, o2) -> (o1.getName() +
113+
Joiner.on(delimiter)
114+
.useForNull("")
115+
.join(Arrays.asList(o1.getParameters())
116+
.stream()
117+
.sequential()
118+
.map(x -> x.getName() + x.getType().getName())
119+
.collect(Collectors.toList())))
120+
.compareTo(o2.getName() +
121+
Joiner.on(delimiter)
122+
.useForNull("")
123+
.join(Arrays.asList(o2.getParameters())
124+
.stream()
125+
.sequential()
126+
.map(x -> x.getName() + x.getType().getName())
127+
.collect(Collectors.toList())))
128+
);
112129
for(Method method : methods) {
113130
if(!methodsNameToSkip.contains(method.getName())) {
114131
writer.write("method " + method.getName(), 2);

0 commit comments

Comments
 (0)