[JAVA-4326] codecs for traits (not sealed traits) Created: 29/Sep/21 Updated: 04/May/22 |
|
| Status: | Backlog |
| Project: | Java Driver |
| Component/s: | Scala |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Unknown |
| Reporter: | Andy Lii | Assignee: | Ross Lawley |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | external-user | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
Is it possible to use Macro to derive codecs for traits (not sealed traits)? If not, how do I make one myself? Suppose the following:
If I register the registry and codec like this:
Then I am able to encode (i.e. turn bar into a BsonDocument, but not decode - it will fail with next on empty iterator on FooMacroCodec$1.getClassName. Is there a way to do this? I've simplified my code a lot, in reality I simply cannot turn Foo into a sealed trait. Thanks in advance. |
| Comments |
| Comment by Ross Lawley [ 12/Oct/21 ] |
|
Thanks for the ticket. I think this should be supported as it is in the Java driver for POJOs. This will be scheduled for a future fix. Ross |