Package org.pipservices3.commons.convert
Class RecursiveMapConverter
java.lang.Object
org.pipservices3.commons.convert.RecursiveMapConverter
Converts arbitrary values into map objects using extended conversion rules.
This class is similar to
MapConverter
, but is recursively converts all values
stored in objects and arrays.
### Example ###
Map<String, Object> value1 = RecursiveMapConverted.toNullableMap("ABC"); // Result: null
Map<String, Object> value2 = RecursiveMapConverted.toNullableMap({ key: 123 }); // Result: { key: 123 }
List<Object> result = new ArrayList<Object>();
result.add(1);
result.add(new int[]{2, 3});
Map<String, Object> value3 = RecursiveMapConverted.toNullableMap(result); // Result: { "0": 1, { "0": 2, "1": 3 } }
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionConverts value into map object or returns empty map when conversion is not possibletoMapWithDefault
(Object value, Map<String, Object> defaultValue) Converts value into map object or returns default when conversion is not possibletoNullableMap
(Object value) Converts value into map object or returns null when conversion is not possible.
-
Constructor Details
-
RecursiveMapConverter
public RecursiveMapConverter()
-
-
Method Details
-
toNullableMap
Converts value into map object or returns null when conversion is not possible.- Parameters:
value
- the value to convert.- Returns:
- map object or null when conversion is not supported.
-
toMap
Converts value into map object or returns empty map when conversion is not possible- Parameters:
value
- the value to convert.- Returns:
- map object or empty map when conversion is not supported.
- See Also:
-
toMapWithDefault
Converts value into map object or returns default when conversion is not possible- Parameters:
value
- the value to convert.defaultValue
- the default value.- Returns:
- map object or empty map when conversion is not supported.
- See Also:
-