Package org.pipservices3.commons.convert
Class ArrayConverter
java.lang.Object
org.pipservices3.commons.convert.ArrayConverter
Converts arbitrary values into array objects.
### Example ###
List<Object> value1 = ArrayConverter.toArray(1); // Result: [1]
List<Object> value2 = ArrayConverter.listToArray("1,2,3"); // Result: ["1", "2", "3"]
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionlistToArray
(Object value) Converts value into array object with empty array as default.Converts value into array object with empty array as default.toArrayWithDefault
(Object value, List<Object> defaultValue) Converts value into array object with empty array as default.toNullableArray
(Object value) Converts value into array object.
-
Constructor Details
-
ArrayConverter
public ArrayConverter()
-
-
Method Details
-
toNullableArray
Converts value into array object. Single values are converted into arrays with a single element.- Parameters:
value
- the value to convert.- Returns:
- array object or null when value is null.
-
toArray
Converts value into array object with empty array as default. Single values are converted into arrays with single element.- Parameters:
value
- the value to convert.- Returns:
- array object or empty array when value is null.
- See Also:
-
toArrayWithDefault
Converts value into array object with empty array as default. Single values are converted into arrays with single element.- Parameters:
value
- the value to convert.defaultValue
- default array object.- Returns:
- array object or empty array when value is null.
- See Also:
-
listToArray
Converts value into array object with empty array as default. Strings with comma-delimited values are split into array of strings.- Parameters:
value
- the list to convert.- Returns:
- array object or empty array when value is null
- See Also:
-