mardi 3 mars 2020

Determine Which Parameter in Constructor was used to Set a Specific Field in Class?

I'm working on developing a custom Java object persistence framework as I recently discussed in this question.

One issue I am trying to solve is to force uniform annotation values in constructor parameter and method.

Is it possible to know which parameter in constructor was used to set a specific field in class via reflection? For example, if constructor contains parameter String textXYZ and class contains field String textABC and in constructor I do: textABC = textXYZ (so field/parameter have different names). Is it possible to know that the field textABC is associated with the constructor parameter textXYZ via reflection?

This would allow me to set annotation just on field and then deduce annotation value of parameter or vice versa..

Thanks





Aucun commentaire:

Enregistrer un commentaire