@Test public void withMultiPackages() throws Exception { List<Class<?>> classes = findClasses("com.nitorcreations.testdomain.person", "com.nitorcreations.testdomain.another"); assertThat(classes.size(), is(5)); }
public static List<Class<?>> findClasses(final List<String> packages, final URLClassLoader classLoader) { return packages.stream() .map(packageName -> getClasses(classLoader, packageName)) .flatMap(Collection::stream) .filter(DomainClassFinder::isNotPackageInfo) .filter(DomainClassFinder::isNotAnonymousClass) .collect(Collectors.toList()); }
DomainClassFinder { public static List<Class<?>> findClasses(final List<String> packages, final URLClassLoader classLoader) { return packages.stream() .map(packageName -> getClasses(classLoader, packageName)) .flatMap(Collection::stream) .filter(DomainClassFinder::isNotPackageInfo) .filter(DomainClassFinder::isNotAnonymousClass) .collect(Collectors.toList()); } }
DomainClassFinder { public static List<Class<?>> findClasses(final List<String> packages, final URLClassLoader classLoader) { return packages.stream() .map(packageName -> getClasses(classLoader, packageName)) .flatMap(Collection::stream) .filter(DomainClassFinder::isNotPackageInfo) .filter(DomainClassFinder::isNotAnonymousClass) .collect(Collectors.toList()); } private  DomainClassFinder(); }
DomainClassFinder { public static List<Class<?>> findClasses(final List<String> packages, final URLClassLoader classLoader) { return packages.stream() .map(packageName -> getClasses(classLoader, packageName)) .flatMap(Collection::stream) .filter(DomainClassFinder::isNotPackageInfo) .filter(DomainClassFinder::isNotAnonymousClass) .collect(Collectors.toList()); } private  DomainClassFinder(); static List<Class<?>> findClasses(final List<String> packages, final URLClassLoader classLoader); }
DomainClassFinder { public static List<Class<?>> findClasses(final List<String> packages, final URLClassLoader classLoader) { return packages.stream() .map(packageName -> getClasses(classLoader, packageName)) .flatMap(Collection::stream) .filter(DomainClassFinder::isNotPackageInfo) .filter(DomainClassFinder::isNotAnonymousClass) .collect(Collectors.toList()); } private  DomainClassFinder(); static List<Class<?>> findClasses(final List<String> packages, final URLClassLoader classLoader);  }