I'm writing some validation code.
And don't want to declare much constants, so thinking about more dynamic way of how to get a name of properties of a class.
I.e.
class User {
String firstname;
String lastname;
getters/setters ....
}
Is the access via the
User.class.getDeclaredField("firstname").getName();
is an expensive operation and I rather go with constants or some other way?
Aucun commentaire:
Enregistrer un commentaire