Skip to content

Map<Object, Object> should be persistable #68

Description

@JanSchankin

We are unable to persist Maps which have non primitve types (i.e. their wrapper types) as key. We need a new BeanConverterExtenstion that is able to convert and revert Maps of the type Map<Object, Object> in a way that the Objects are converted to PersistentBeans.

We are currently able to persist Map<T, Object> where T is any wrapper of a primitve type. This is done by MapPrimitiveKeyExtension. This can be used as a template.
https://github.com/ppi-ag/deep-sampler/blob/645e0ab8f4775d194d6c90a54a94cd3e72cf8ca9/deepsampler-persistence/src/main/java/de/ppi/deepsampler/persistence/bean/ext/MapPrimitiveKeyExtension.java

MapPrimitiveKeyExtension converts the key to a String, so that the key can be used as a property name in JSON:

{
   "key": "value"
}

There is no nice way to convert complex objects to Strings that could be used as a key in the same way, so we need to find another way to express the key in a persistable way. One way to do it, would be to convert the Map in a List which has a tuple as entry. The tuple would then contain the key and the value.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions