mardi 28 juillet 2015

Is incorrect this use of Reflection

I have various methods to validate an object. For now i run the validation like this:

boolean error = false;
if(!methodOneValidade(myObject)) error = true;
if(!methodTwoValidade(myObject)) error = true;
if(!methodTreeValidade(myObject)) error = true;
.
.
.
if(!method23Validade(myObject)) error = true;
return error;

Instead, if i annotate the methods with an specific annotation (@MyRule e.g.) and execute them using reflection, is it a good practice? For me will be smart and practical, but is it acceptable way use of reflection in java?





Aucun commentaire:

Enregistrer un commentaire