Multi level hierarchy with Serialization/Deserialization and configuration value #4465
Unanswered
micsport13
asked this question in
Q&A
Replies: 2 comments
-
you can register subtypes manually on ObjectMapper |
Beta Was this translation helpful? Give feedback.
0 replies
-
If I want them all to get serialized the same way but then get deserialized into the concrete class, does that change anything? There shouldn't be much difference between the concrete classes and the abstract base classes. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'm creating a fake data generator project and as a result, I have created this existing interface:
Which works well for me, however, I'm looking to make my program a little more modular in terms of converting all of these subtypes into abstract classes and then creating implementations based off of the abstract classes that are currently normal classes (like DecimalDataType). One example would be DecimalDataType is subclassed by MySQLDecimalDataType, PostgresDecimalDataType, SQLServerDataType, etc. My question is, is there a way that I can pass an environment variable to know that a DecimalDataType should get deserialized into a PostgresDecimalDataType if the variable DB_ENGINE=Postgres for example, similar to an abstract factory pattern? I would like to keep them serialized the same but get deserialized into a concrete class. If so, how would one do this? If not, do I have to create a custom deserializer for each one of these classes and just switch based on the deserialization context? Any ideas would be greatly appreciated.
Beta Was this translation helpful? Give feedback.
All reactions