Abnaxos / meldioc

A prototype of an IoC (Inversion of Control) library for Java
MIT License
5 stars 1 forks source link

Add an alternative converter for Vavr's Option #69

Open Abnaxos opened 4 years ago

Abnaxos commented 4 years ago

Add a converter for Vavr's Option that behaves more like one would expect: if a value is not present or null, convert to None, otherwise to Some. The current implementation in gson-vavr uses a list. While this strategy does have its point (you can express Some(null)), it's really not what most people probably expect. I've never seen this way of mapping Option in the wild, so for interoperability, you currently have to use java.util.Optional.

As a first step, just add this converter to the codec library. Also consider proposing this change to vavr-gson.