Package net.handle.hdllib
Class GsonUtility
java.lang.Object
net.handle.hdllib.GsonUtility
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static class
static class
static class
static class
static class
static class
static class
static class
static class
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.gson.Gson
getGson()
Returns a Gson instance which can serialize and deserialize various Handle.net types.static com.google.gson.GsonBuilder
Returns a GsonBuilder which can serialize and deserialize various Handle.net types.static com.google.gson.Gson
Returns a Gson instance which can serialize and deserialize various Handle.net types.static com.google.gson.JsonElement
Serialize a response, adding in the handle value from the given request.static com.google.gson.GsonBuilder
setup
(com.google.gson.GsonBuilder gsonBuilder) Register Handle.net type adapters on a given GsonBuilder, to enable serialization and deserialization of various Handle.net types.
-
Constructor Details
-
GsonUtility
public GsonUtility()
-
-
Method Details
-
setup
public static com.google.gson.GsonBuilder setup(com.google.gson.GsonBuilder gsonBuilder) Register Handle.net type adapters on a given GsonBuilder, to enable serialization and deserialization of various Handle.net types.- Parameters:
gsonBuilder
- a GsonBuilder- Returns:
- the passed-in GsonBuilder.
-
getNewGsonBuilder
public static com.google.gson.GsonBuilder getNewGsonBuilder()Returns a GsonBuilder which can serialize and deserialize various Handle.net types.- Returns:
- a GsonBuilder which can serialize and deserialize various Handle.net types.
-
getGson
public static com.google.gson.Gson getGson()Returns a Gson instance which can serialize and deserialize various Handle.net types. This Gson instance has HTML escaping disabled.- Returns:
- a Gson instance which can serialize and deserialize various Handle.net types.
-
getPrettyGson
public static com.google.gson.Gson getPrettyGson()Returns a Gson instance which can serialize and deserialize various Handle.net types. This Gson instance has HTML escaping disabled and pretty-printing enabled.- Returns:
- a Gson instance which can serialize and deserialize various Handle.net types.
-
serializeResponseToRequest
public static com.google.gson.JsonElement serializeResponseToRequest(AbstractRequest req, AbstractResponse resp) Serialize a response, adding in the handle value from the given request.- Parameters:
req
- a requestresp
- a response- Returns:
- The response, serialized as a JSON tree, with the "handle" value from the request if not already in the response.
-