Class MultiValuedToFlatMapConverter
java.lang.Object
de.xima.fc.converter.json.MultiValuedToFlatMapConverter
Converts between a flat map
Map<String, V> with compound keys and a multivalued map Map<String,
List<V>>.
The flat map uses keys in the format "key.index" to represent lists, where "key" is the base key and "index" is the zero-based index of the value in the list.
For example, the multivalued map:
Map.of("key", List.of("value1", "value2", "value3"));
corresponds to the flat map:
Map.of("key.0", "value1", "key.1", "value2", "key.2", "value3");
- Since:
- 8.5.0
-
Method Summary
Modifier and TypeMethodDescriptionfromFlatMap(Map<String, V> flatMap) Converts a flat map with compound keys into a multivalued map.Converts a multivalued map into a flat map with compound keys.static <V> voidConverts a multivalued map into a flat map with compound keys, writing the result into the provided target map.
-
Method Details
-
fromFlatMap
Converts a flat map with compound keys into a multivalued map.- Type Parameters:
V- the type of values in the map.- Parameters:
flatMap- The flat map to convert, where keys are in the format "key.index".- Returns:
- A multivalued map where each key maps to a list of values.
-
toFlatMap
Converts a multivalued map into a flat map with compound keys.- Type Parameters:
V- the type of values in the map.- Parameters:
multiValuedMap- The multivalued map to convert, where each key maps to a list of values.- Returns:
- A flat map where keys are in the format "key.index".
-
toFlatMap
Converts a multivalued map into a flat map with compound keys, writing the result into the provided target map.- Type Parameters:
V- the type of values in the map.- Parameters:
multiValuedMap- The multivalued map to convert, where each key maps to a list of values.target- The target flat map where the result will be written.
-