eclipse-emfcloud / emfjson-jackson

emfjson-jackson
Other
16 stars 15 forks source link

`@JsonType` annotations override default settings of `EcoreTypeInfo` #43

Closed janhicken closed 2 years ago

janhicken commented 2 years ago

@JsonType annotations can used to configure a different property for specific classes to read the object's type, like this:

class Bar {}

@JsonType(property="@foo")
class Foo {}

We can also specify a different configuration for the EcoreTypeInfo:

final ValueReader<String, EClass> customLookupFn = ...;
EMFModule module = new EMFModule();
module.setTypeInfo(new EcoreTypeInfo("@bar", customLookupFn));

Using the above configuration, the deserializer will extract the type info from the property @foo when parsing Foo objects and using the property @bar for all other objects, which works fine.

However, the customLookupFn will not be used for Foo objects.

You can actually configure a different lookup function by specifying the use annotation detail, but it does not allow arbitrary functions as shown above.

I think the module's default EcoreTypeInfo' value reader should also be used for the @foo type info configured via annotation.