org.plovr
Class GsonUtil
java.lang.Object
org.plovr.GsonUtil
public final class GsonUtil
- extends Object
GsonUtil
provides utilities for working with Gson
.
- Author:
- bolinfest@gmail.com (Michael Bolin)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
STRING_TO_JSON_PRIMITIVE
public static final Function<String,JsonPrimitive> STRING_TO_JSON_PRIMITIVE
stringOrNull
public static String stringOrNull(JsonElement element)
- If element is a
JsonPrimitive
that corresponds to a string, then
return the value of that string; otherwise, return null.
toListOfStrings
public static List<String> toListOfStrings(JsonElement element)
throws IllegalArgumentException
- Parameters:
element
- must be one of:
null
, in which case this returns null
- a single string literal
- a list of non-null string literals
- Returns:
- null or a list of non-null strings
- Throws:
IllegalArgumentException
- if element
does not meet any of
the above conditions
clone
public static JsonObject clone(JsonObject value)