Skip to content

Commit

Permalink
ReflectionUtil.java: For backwards compatibility, always include `bas…
Browse files Browse the repository at this point in the history
…eClassOrInterface`.
  • Loading branch information
seanbright committed Aug 17, 2024
1 parent 026864a commit 05fb7f3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/main/java/org/asteriskjava/util/ReflectionUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
* Utility class that provides helper methods for reflection that is used by the
Expand Down Expand Up @@ -268,13 +269,16 @@ public static Object newInstance(String s) {
* @return a Set of types that implement or extend the provided type
*/
public static <T> Set<Class<? extends T>> loadClasses(String packageName, Class<T> baseClassOrInterface) {
Set<Class<? extends T>> result = new Reflections(packageName)
.getSubTypesOf(baseClassOrInterface)
.stream()
.filter(c -> !Modifier.isAbstract(c.getModifiers()))
.collect(Collectors.toSet());

logger.info("Loaded " + result.size());
Set<Class<? extends T>> result =
Stream.concat(
Stream.of(baseClassOrInterface),
new Reflections(packageName)
.getSubTypesOf(baseClassOrInterface)
.stream())
.filter(c -> !Modifier.isAbstract(c.getModifiers()))
.collect(Collectors.toSet());

logger.info("Loaded asd" + result.size());

return result;
}
Expand Down

0 comments on commit 05fb7f3

Please sign in to comment.