Class MapToStringTransformer

    • Constructor Detail

      • MapToStringTransformer

        public MapToStringTransformer()
        Creates MapToStringTransformer with defaults:
         mappingSequence = "=";
         separatorSequence = "&";
         nullValue = "null";
         
      • MapToStringTransformer

        public MapToStringTransformer​(String mappingSequence,
                                      String separatorSequence,
                                      String nullValue)
        Creates MapToStringTransformer with given values
        Parameters:
        mappingSequence - sequence inserted between key and value
        separatorSequence - sequence inserted between every pair of Map entries
        nullValue - sequence inserted for every null key or value
    • Method Detail

      • transform

        public String transform​(Map<?,​?> map)
        Transforms Map to String, representing every entry as key mappingSequence value , joined by separatorSequence

        Calls toString() for keys and values, replacing null with the value of nullValue property

        For example, if we have a map with two entries: ("key1", "1") and ("key2", "2") this method would return "key1=1&key2=2" if mappingSequence is "=" and separator sequence is "&";

        Parameters:
        map - map of arguments
        Returns:
        String resulting string