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> T
fromJson(String json, Class<T> klass)
Convert the given JSON string into an object using Gson.static String
join(String[] strings, String delimiter)
Concatenate string with the specified delimiter.static String
stringifyPrompts(Prompt[] prompts)
Stringify an array ofPrompt
.static String
stringifyProperties(Property[] properties)
Stringify an array ofProperty
.static String
stringifyScopeNames(Scope[] scopes)
Generate a list of scope names.static String
toJson(Object object)
Convert the given object into a JSON string using Gson.static String
toJson(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. Ifnull
or an empty string is given, delimiters are not inserted between strings.- Returns:
- A concatenated string. If
strings
isnull
,null
is returned. If the size ofstrings
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
isnull
,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
isnull
,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 ofProperty
.- Parameters:
properties
- An array ofProperty
. Ifnull
is given,null
is returned.- Returns:
- A formatted string containing the information about
the given properties. If the
properties
parameter isnull
,null
is returned. - Since:
- 2.5
-
stringifyPrompts
public static String stringifyPrompts(Prompt[] prompts)
Stringify an array ofPrompt
.- Parameters:
prompts
- An array ofPrompt
. Ifnull
is given,null
is returned.- Returns:
- A string containing lower-case prompt names using white spaces as the delimiter.
- Since:
- 2.5
-
-