Reflector is small and simple reflection Java library.
Library main usage is:
- get class methods private or not
- get class fields
- select annotated fields
- select and clear some fields
- invoke new instance of class
- invoke object method
- read object field
- read object field as map
- other (get class name, package, super)
Required java version is java 8
Specially not used java 8 features to keep more obvious code. And formatting also not according to official java code style for such reason.
Usage example:
Get all private fields:
List<Field> fields = ReflectionUtils.getAllPrivateFields(List.class);
Get all public and protected methods:
List<Method> allPublicProtectedMethods = ReflectionUtils.getAllPublicProtectedMethods(List.class);
Get all private methods from java.util.List:
List<Method> allPublicProtectedMethods = ReflectionUtils.getAllPrivateMethods(List.class);
Get all annotated fields with @Autowired annotation:
List<Field> fields = ReflectionUtils.getAllAnnotatedFields(DataService.class, Autowired.class);
Get all annotated fields:
String fullClassNameWithPackage = "org.data.model.User";
Object[] obj = {"Name", "Surname"};
User instance = (User) ReflectionUtils.invokeInstance(fullClassNameWithPackage, obj);
- initial release