I have a few auto-generated classes(models) as part of a core service that I am integrating. However, the authors of those classes have intentionally/unintentionally left the toString method overriding. I have a few options on how to use these classes on which I need some insight.
-
I can make exact duplicates of those classes in my packages overriding the toString method and add those auto-generated classes in .gitignore. However, the caveat with this approach is that any future changes in those classes will not be reflected in my code and new developers may be oblivious to the incompatibility in the service and my implementation.
-
I can create a wrapper class for the top level classes and add toString but then I have to call getters for every single method and if it contains nested classes that might lead to a sort of a flat-map creation. (Chaotic toString method)
-
I was thinking of using the decorator pattern (adding functionality to a class without breaking it), but I'm not sure if this is how it is intended to be used.
I'm positive that I'm not the first one who came across this problem, so there must be some sort of a right way to tackle it. A nudge in that direction would be helpful.
Aucun commentaire:
Enregistrer un commentaire