Package io.microsphere.collection
Class PropertiesUtils
- java.lang.Object
-
- io.microsphere.collection.PropertiesUtils
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.String,java.lang.Object>
flatProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
Flattens a nested map of properties into a single-level map.protected static void
flatProperties(java.util.Map<java.lang.String,java.lang.Object> properties, java.lang.String propertyNamePrefix, java.util.Map<java.lang.String,java.lang.Object> flattenProperties)
Recursively flattens the given properties map into a single-level map.
-
-
-
Method Detail
-
flatProperties
@Nonnull @Immutable public static java.util.Map<java.lang.String,java.lang.Object> flatProperties(java.util.Map<java.lang.String,java.lang.Object> properties)
Flattens a nested map of properties into a single-level map.If the input map is empty or null, the same map instance is returned.
For example, given the following input:
The resulting flattened map would be:{ "a": "1", "b": { "c": "2", "d": { "e": "3" } } }
{ "a": "1", "b.c": "2", "b.d.e": "3" }
- Parameters:
properties
- The map containing potentially nested properties to be flattened.- Returns:
- A new unmodifiable map with all properties flattened to a single level.
-
flatProperties
protected static void flatProperties(java.util.Map<java.lang.String,java.lang.Object> properties, java.lang.String propertyNamePrefix, java.util.Map<java.lang.String,java.lang.Object> flattenProperties)
Recursively flattens the given properties map into a single-level map.- Parameters:
properties
- The map containing properties to be flattened.propertyNamePrefix
- The prefix for property names used during flattening.flattenProperties
- The target map where flattened properties are stored.
-
-