Centralize Gson config
TinaTiel opened this issue · 2 comments
Generally in calls that serialize/deserialize objects, a new Gson instance is being created. Gson instances are thread-safe, so what we can do is initialize GSON in the contructor.
This would enable us to centralize configuration, for example to add custom serializers/deserializers, or even a RuntimeTypeAdapter to better handle the polymorphism inherent in the Request/Response structure.
This also would enable us to test the serialization/deserialization (or at least smoke-test it) to verify there aren't any mistakes in mapping stuff. Tests would get the Gson instance from OBSCommunicator (or wherever) and verify the configuration is correct.
Related to #25 .
Having to repeat myself with FilterInfo. This could hypothetically be solved with RuntimeTypeAdaptors, etc. but I need to centralize Gson config first.
For now I'll do the dirty and repeat myself on the one class I encountered this...Then I could revisit that and refactor it as part of this work.
This can be closed, resolved by #37