thank you for reading in advance.
I'm currently working on a spring project in wich I have to do some things very generic. A friend just recommend me to use Spring ReflectionUtils and some existential doubds came into my mind.
What would be the difference between using ReflectionUtils and just the standard java reflection (apart from having to deal with the exceptions, it seems to me that ReflectionUtils is more bolierplate)
Here's some code to show you:
public Object genericObject(){
return ReflectionUtils.invokeMethod(
ReflectionUtils.findMethod(genericService.getClass(), "getGenericObject"),
genericService)
}
and the standard java way:
public Object genericObject() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
return genericService.getClass().getMethod("getGenericObject").invoke(genericService);}
(I know is not the best exception handling, it's just for representation)
what you guys think? let me know!
Aucun commentaire:
Enregistrer un commentaire