Package eu.woolplatform.utils
Class DataFormatter
- java.lang.Object
-
- eu.woolplatform.utils.DataFormatter
-
public class DataFormatter extends Object
This class can format maps, lists and primitives (boolean, number, string). The output can be use human-friendly formatting with new lines and indentation. And the output can be JSON or it can use Java toString(). If the output should be JSON, any object that is not a map, list or primitive, will be converted to a map first.
-
-
Constructor Summary
Constructors Constructor Description DataFormatter()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Stringformat(Object value, boolean human)Returns a string representation of the specified value (map, list or primitive).Stringformat(Object value, boolean human, boolean json)Returns a string representation of the specified value (map, list or primitive).
-
-
-
Method Detail
-
format
public String format(Object value, boolean human)
Returns a string representation of the specified value (map, list or primitive). If "human" is true, the returned string will have a friendly formatting, possibly spanning multiple lines.The output of primitives will use Java toString(). See also
format(value, human, json).- Parameters:
value- the value to formathuman- true for friendly formatting, false for single-line formatting- Returns:
- the string
-
format
public String format(Object value, boolean human, boolean json)
Returns a string representation of the specified value (map, list or primitive). If "human" is true, the returned string will have a friendly formatting, possibly spanning multiple lines.- Parameters:
value- the value to formathuman- true for friendly formatting, false for single-line formattingjson- true if the output should be JSON, false if the output should use Java toString()- Returns:
- the string
-
-