Package com.authlete.common.util
Class Utils
- java.lang.Object
-
- com.authlete.common.util.Utils
-
public class Utils extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> TfromJson(String json, Class<T> klass)Convert the given JSON string into an object using Gson.static Stringjoin(String[] strings, String delimiter)Concatenate string with the specified delimiter.static StringstringifyPrompts(Prompt[] prompts)Stringify an array ofPrompt.static StringstringifyProperties(Property[] properties)Stringify an array ofProperty.static StringstringifyScopeNames(Scope[] scopes)Generate a list of scope names.static StringtoJson(Object object)Convert the given object into a JSON string using Gson.static StringtoJson(Object object, boolean pretty)Convert the given object into a JSON string using Gson.
-
-
-
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. Ifnullor an empty string is given, delimiters are not inserted between strings.- Returns:
- A concatenated string. If
stringsisnull,nullis returned. If the size ofstringsis 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
objectisnull,nullis 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
objectisnull,nullis 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 ofProperty.- Parameters:
properties- An array ofProperty. Ifnullis given,nullis returned.- Returns:
- A formatted string containing the information about
the given properties. If the
propertiesparameter isnull,nullis returned. - Since:
- 2.5
-
stringifyPrompts
public static String stringifyPrompts(Prompt[] prompts)
Stringify an array ofPrompt.- Parameters:
prompts- An array ofPrompt. Ifnullis given,nullis returned.- Returns:
- A string containing lower-case prompt names using white spaces as the delimiter.
- Since:
- 2.5
-
-