Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-2223

support interfaces for field types

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.5.0
    • Affects Version/s: None
    • Component/s: Codecs
    • Labels:
      None

      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:

      1. 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
      2. 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.

            Assignee:
            Unassigned Unassigned
            Reporter:
            justin.lee Justin Lee
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: