Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Map<Object, Object> should be persistable #68

Open
JanSchankin opened this issue Jun 21, 2021 · 0 comments
Open

Map<Object, Object> should be persistable #68

JanSchankin opened this issue Jun 21, 2021 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@JanSchankin
Copy link
Contributor

JanSchankin commented Jun 21, 2021

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.

@JanSchankin JanSchankin added the enhancement New feature or request label Jun 21, 2021
@JanSchankin JanSchankin added this to the v1.2.0 milestone Jun 22, 2021
@JanSchankin JanSchankin removed this from the v1.2.0 milestone Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants