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

support interfaces for field types

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.0
    • Component/s: Codecs
    • Labels:
      None

      Description

      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.

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: