Class GsonUtility


  • public class GsonUtility
    extends java.lang.Object
    • Constructor Detail

      • GsonUtility

        public GsonUtility()
    • Method Detail

      • 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 request
        resp - a response
        Returns:
        The response, serialized as a JSON tree, with the "handle" value from the request if not already in the response.