Object CollectionUtil
-
- All Implemented Interfaces:
public class CollectionUtil
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interfaceCollectionUtil.Data
-
Field Summary
Fields Modifier and Type Field Description public final static CollectionUtilINSTANCE
-
Method Summary
Modifier and Type Method Description final Map<String, Object>flatten(Map<String, Object> data)Converts nested maps and collections in the given parameter to composite string keys. final Map<String, Object>unflatten(Map<String, ?> input)Reverse operation to flatten, example: input: mapOf( "data.key1" to "value1", "data.key2[0]" to "value2", "data.key2[1]" to "value3", )output: mapOf( "data" to mapOf( "key1" to "value1", "key2" to listOf("value2", "value3") ) )final Iterator<Object>maybeGetIterator(Object collectionOrArray)final Iterator<Object>getArrayIterator(Object array)-
-
Method Detail
-
flatten
final Map<String, Object> flatten(Map<String, Object> data)
Converts nested maps and collections in the given parameter to composite string keys.
Example:
input: mapOf( "data" to mapOf( "key1" to "value1", "key2" to listOf("value2", "value3") ) )output: mapOf( "data.key1" to "value1", "data.key2[0]" to "value2", "data.key2[1]" to "value3", )
-
unflatten
final Map<String, Object> unflatten(Map<String, ?> input)
Reverse operation to flatten, example:
input: mapOf( "data.key1" to "value1", "data.key2[0]" to "value2", "data.key2[1]" to "value3", )output: mapOf( "data" to mapOf( "key1" to "value1", "key2" to listOf("value2", "value3") ) )
-
maybeGetIterator
final Iterator<Object> maybeGetIterator(Object collectionOrArray)
-
getArrayIterator
final Iterator<Object> getArrayIterator(Object array)
-
-
-
-