
Support Enums
MasterCash opened this issue ยท 1 comments
With the current system, the distinction between a string and an enum would be difficult to tell.
Current thought process for this:
new Type
when serializing just convert to string, when deserializing if structure exists already, should be fine, should know to serialize. Issue arrives when structure is not known ahead. The solution would to be had consumer register enums that they expect but this could lead to collisions with that enum string value and a normal string item.
given enum:
public Enum test {
bob,
jill
}
if test.bob
was serialized (as "bob") there wouldn't be a way to know it was an enum on deserialization without the structure.
One solution is to expect the consumer to map out all possible avenues, I personally don't like this and it breaks with configuration changes (needing to load old to convert to new).
Another solution is to have the consumer register all enums that they expect to encounter. This would be a lookup table used when the type is STRING
to check if the string exists in the map. This limits the values of the enum to be limited to one enum. e.g. if the enum test has item bob
then enum other cannot have item named bob
as well. Additionally, if user were to provide the string value expecting it to be treated as a string it would instead make it an enum(this issue is fixed when dealing with existing structures).
Due to these limitations and my lack of knowledge with java, I am closing this issue.