I'm working on a large Android project which is using Gson. The method fromJson()
is called dozens of times in many files. I need to provide some special-case tests every time this method is called.
Rather than going through and repeating the tests for each and every time this method is used, I'd like to follow the DRY doctrine and simply override the fromJson()
method somehow.
My first thought is to make a child class of Gson and override the method, but I would still have to make dozens (perhaps hundreds) of changes to make this work. But even if I were willing to do this work, Gson is final
and thus can't be extended.
Second thought: it might be possible to alter the Gson library code. But I don't want to go this route as I'm afraid that I may break something that otherwise works perfectly.
This is an area of Java that I have never ventured before. Anyone have any suggestions?