-
-
Notifications
You must be signed in to change notification settings - Fork 695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get all classes from package #13
Comments
What would be the next step after you get these classes? How would you act on them? |
I need them (List of class) to call Class.forName("fullnameOfTheClass") cause there are many classes in many package and subpackage and I wouldn't manually write them. |
So you basically want to print them? That's not the right usage for Reflections, although you can do it - See http://stackoverflow.com/questions/520328/can-you-find-all-classes-in-a-package-using-reflection The right usage would be, for example, to get all sub types of some interface - and than you can act on these using the common interface. That would be programmatically meaningful. See the difference? |
OK, I have fix it like this //lista as classes do pacote "com.google", incluindo os subpacotes This is exactly what I was looking for! |
@ronmamo I don't agree that acting on all class in a package is an invalid use case. |
Good point. I agree.
|
I have seen the example like
Set<Class<? extends Module>> modules = reflections.getSubTypesOf(com.google.inject.Module.class);
But, I'd like to get all classes from package wihout especified the class, something like
List clazz = reflections.getClassFromPackage("com.someproject.model");
is it possible? how can I do that with Reflection library?
The text was updated successfully, but these errors were encountered: