lundi 8 avril 2019

Scala: Can I execute some code when the value of a variable within a class instance changes using reflection?

As stated in the question: is it possible to ensure that a piece of code is executed each time the value of a variable changes within a class instance using reflection? (in my situation, writing this code in the setter of the variable is not an option)

If no, what alternative approaches are there to achieve the same goal (without implementing it in the setter method of the variable).

Example to make it more concrete: I have a class containing certain variables. Every time one of the variables changes, it has to be logged.





Aucun commentaire:

Enregistrer un commentaire