Class ArrayFormatter

  • All Implemented Interfaces:
    IFormatter

    public class ArrayFormatter
    extends Object
    implements IFormatter
    A formatter for converting an array of elements, represented by String to an array of specified type (method parse(String)).
    Also it provides the back convertion from specified type to a String, in outcome result elements will be separated by comma (method format(Object)).
    • Constructor Detail

      • ArrayFormatter

        public ArrayFormatter​(IFormatter elementFormat,
                              Class<?> elementType)
        Parameters:
        elementFormat - formatter for the component type of array.
    • Method Detail

      • format

        public String format​(Object value)
        Converts an input array of elements to String. Elements in the return value will be separated by comma. Null safety.
        Specified by:
        format in interface IFormatter
        Parameters:
        value - array of elements that should be represented as String.
        Returns:
        String representation of the income array. NULL if the income value is NULL or if income value is not an array.
      • parse

        public Object parse​(String value)
        Specified by:
        parse in interface IFormatter
        Parameters:
        value - String representation of the array.
        Returns:
        array of elements. NULL if input is empty or can`t get the component type of the array.
      • getElementFormat

        public IFormatter getElementFormat()