use of org.apache.ibatis.javassist.ClassPool in project judge by zjnu-acm.
the class MockGenerator method toMethodComparator.
private Comparator<String> toMethodComparator(Class<?> key) {
AtomicInteger counter = new AtomicInteger();
ClassPool classPool = ClassPool.getDefault();
Map<String, Integer> map = Stream.concat(takeWhile(Stream.<Class<?>>iterate(key, Class::getSuperclass), parent -> parent != null && parent.getClassLoader() != null), Arrays.stream(key.getInterfaces())).flatMap(type -> stream(classPool, type)).collect(Collectors.toMap(method -> method.getDeclaringClass().getName().replace(".", "/") + "." + method.getName() + ":" + method.getSignature(), __ -> counter.getAndIncrement()));
return Comparator.comparingInt(s -> map.getOrDefault(s, Integer.MAX_VALUE));
}
Aggregations