If a field is declared to be a Foo where Foo is an interface, we need a mechanism to indicate the concrete class to instantiate when deserializing. For embedded entities we can rely on the discriminator value in the nested document. For the case where foo is a enum that implements Foo, we lack sufficient context to rehydrate those objects. Options:
- Require an annotation (or programmatic configuration) to define the concrete class. The container types (List/Map/Set) already use this to guess at the appropriate container type to create. We could expose this for use in the more general case
- We could serialize these cases as documents containing _t with the concrete type and the value. This would make queries slightly awkward outside of Java so that's slightly less attractive. It's more flexible at runtime though since we're not tying that interface implementation to just one type which kind of defeats the purpose of programming to interfaces.