org.plovr
Class GsonUtil

java.lang.Object
  extended by org.plovr.GsonUtil

public final class GsonUtil
extends Object

GsonUtil provides utilities for working with Gson.

Author:
bolinfest@gmail.com (Michael Bolin)

Field Summary
static Function<String,JsonPrimitive> STRING_TO_JSON_PRIMITIVE
           
 
Method Summary
static JsonObject clone(JsonObject value)
           
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.
static List<String> toListOfStrings(JsonElement element)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STRING_TO_JSON_PRIMITIVE

public static final Function<String,JsonPrimitive> STRING_TO_JSON_PRIMITIVE
Method Detail

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)