Class ArrayConverter

java.lang.Object
org.pipservices3.commons.convert.ArrayConverter

public class ArrayConverter extends Object
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 Details

    • ArrayConverter

      public ArrayConverter()
  • Method Details

    • toNullableArray

      public static List<Object> toNullableArray(Object value)
      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

      public static List<Object> toArray(Object value)
      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

      public static List<Object> toArrayWithDefault(Object value, List<Object> defaultValue)
      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

      public static List<Object> listToArray(Object value)
      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: