org.eclipse.egit.github.core.client
Class GsonUtils

java.lang.Object
  extended by org.eclipse.egit.github.core.client.GsonUtils

public abstract class GsonUtils
extends Object

Gson utilities.


Constructor Summary
GsonUtils()
           
 
Method Summary
static com.google.gson.Gson createGson()
          Create the standard Gson configuration
static com.google.gson.Gson createGson(boolean serializeNulls)
          Create the standard Gson configuration
static
<V> V
fromJson(Reader reader, Class<V> type)
          Convert content of reader to given type
static
<V> V
fromJson(Reader reader, Type type)
          Convert content of reader to given type
static
<V> V
fromJson(String json, Class<V> type)
          Convert string to given type
static
<V> V
fromJson(String json, Type type)
          Convert string to given type
static com.google.gson.Gson getGson()
          Get reusable pre-configured Gson instance
static com.google.gson.Gson getGson(boolean serializeNulls)
          Get reusable pre-configured Gson instance
static String toJson(Object object)
          Convert object to json
static String toJson(Object object, boolean includeNulls)
          Convert object to json
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GsonUtils

public GsonUtils()
Method Detail

createGson

public static final com.google.gson.Gson createGson()
Create the standard Gson configuration

Returns:
created gson, never null

createGson

public static final com.google.gson.Gson createGson(boolean serializeNulls)
Create the standard Gson configuration

Parameters:
serializeNulls - whether nulls should be serialized
Returns:
created gson, never null

getGson

public static final com.google.gson.Gson getGson()
Get reusable pre-configured Gson instance

Returns:
Gson instance

getGson

public static final com.google.gson.Gson getGson(boolean serializeNulls)
Get reusable pre-configured Gson instance

Parameters:
serializeNulls -
Returns:
Gson instance

toJson

public static final String toJson(Object object)
Convert object to json

Parameters:
object -
Returns:
json string

toJson

public static final String toJson(Object object,
                                  boolean includeNulls)
Convert object to json

Parameters:
object -
includeNulls -
Returns:
json string

fromJson

public static final <V> V fromJson(String json,
                                   Class<V> type)
Convert string to given type

Parameters:
json -
type -
Returns:
instance of type

fromJson

public static final <V> V fromJson(String json,
                                   Type type)
Convert string to given type

Parameters:
json -
type -
Returns:
instance of type

fromJson

public static final <V> V fromJson(Reader reader,
                                   Class<V> type)
Convert content of reader to given type

Parameters:
reader -
type -
Returns:
instance of type

fromJson

public static final <V> V fromJson(Reader reader,
                                   Type type)
Convert content of reader to given type

Parameters:
reader -
type -
Returns:
instance of type


Copyright © 2012. All Rights Reserved.