Class Utils


  • public class Utils
    extends Object
    • Method Detail

      • join

        public static String join​(String[] strings,
                                  String delimiter)
        Concatenate string with the specified delimiter.
        Parameters:
        strings - Strings to be concatenated.
        delimiter - A delimiter used between strings. If null or an empty string is given, delimiters are not inserted between strings.
        Returns:
        A concatenated string. If strings is null, null is returned. If the size of strings is 0, an empty string is returned.
      • toJson

        public static String toJson​(Object object)
        Convert the given object into a JSON string using Gson.
        Parameters:
        object - The input object.
        Returns:
        A JSON string. If object is null, null is returned.
        Since:
        1.24
      • toJson

        public static String toJson​(Object object,
                                    boolean pretty)
        Convert the given object into a JSON string using Gson.
        Parameters:
        object - The input object.
        pretty - True for human-readable format.
        Returns:
        A JSON string. If object is null, null is returned.
        Since:
        2.0
      • fromJson

        public static <T> T fromJson​(String json,
                                     Class<T> klass)
        Convert the given JSON string into an object using Gson.
        Parameters:
        json - The input JSON.
        klass - The class of the resultant object.
        Returns:
        A new object generated based on the input JSON.
        Since:
        2.0
      • stringifyProperties

        public static String stringifyProperties​(Property[] properties)
        Stringify an array of Property.
        Parameters:
        properties - An array of Property. If null is given, null is returned.
        Returns:
        A formatted string containing the information about the given properties. If the properties parameter is null, null is returned.
        Since:
        2.5
      • stringifyPrompts

        public static String stringifyPrompts​(Prompt[] prompts)
        Stringify an array of Prompt.
        Parameters:
        prompts - An array of Prompt. If null is given, null is returned.
        Returns:
        A string containing lower-case prompt names using white spaces as the delimiter.
        Since:
        2.5
      • stringifyScopeNames

        public static String stringifyScopeNames​(Scope[] scopes)
        Generate a list of scope names.
        Parameters:
        scopes - An array of Scope. If null is given, null is returned.
        Returns:
        A string containing scope names using white spaces as the delimiter.
        Since:
        2.5