Class Serializer


  • public class Serializer
    extends Object
    Serializer class, responsible for objects serialization and deserialization.
    • Constructor Detail

      • Serializer

        public Serializer()
    • Method Detail

      • deserializeFromJson

        public static <T extends MPResource> T deserializeFromJson​(Class<T> clazz,
                                                                   String jsonObject)
                                                            throws MPJsonParseException
        Method responsible for deserialize objects.
        Type Parameters:
        T - class type.
        Parameters:
        clazz - class.
        jsonObject - json object.
        Returns:
        object.
        Throws:
        MPJsonParseException - if json cannot be deserialized to an MPResource
      • deserializeResultsResourcesPageFromJson

        public static <T extends MPResourceMPResultsResourcesPage<T> deserializeResultsResourcesPageFromJson​(Type type,
                                                                                                               String jsonObject)
                                                                                                        throws MPJsonParseException
        Method responsible for deserialize json to ResultsResources.
        Type Parameters:
        T - generic type
        Parameters:
        type - type
        jsonObject - jsonObject
        Returns:
        MPResultsResourcesPage deserialized MPResource
        Throws:
        MPJsonParseException - if json cannot be parsed to ResultsResourcesPage
      • deserializeElementsResourcesPageFromJson

        public static <T extends MPResourceMPElementsResourcesPage<T> deserializeElementsResourcesPageFromJson​(Type type,
                                                                                                                 String jsonObject)
                                                                                                          throws MPJsonParseException
        Method responsible for deserialize json to ElementsResources.
        Type Parameters:
        T - generic type
        Parameters:
        type - type
        jsonObject - jsonObject
        Returns:
        MPElementsResourcesPage
        Throws:
        MPJsonParseException - if json cannot be parsed to MPElementsResourcesPage
      • deserializeListFromJson

        public static <T extends MPResourceMPResourceList<T> deserializeListFromJson​(Class<T> clazz,
                                                                                       String jsonObject)
                                                                                throws MPJsonParseException
        Method responsible for deserialize objects.
        Type Parameters:
        T - type
        Parameters:
        clazz - clazz
        jsonObject - jsonObject
        Returns:
        MPResourceList
        Throws:
        MPJsonParseException - if json cannot be parsed to ResultsResourcesPage
      • serializeToJson

        public static <T> com.google.gson.JsonObject serializeToJson​(T resource)
        Method responsible for serialize objects.
        Type Parameters:
        T - class type.
        Parameters:
        resource - resource.
        Returns:
        JsonObject.
      • isJsonValid

        public static boolean isJsonValid​(String json)
                                   throws IOException
        Verify if json is valid.
        Parameters:
        json - json
        Returns:
        boolean
        Throws:
        IOException - exception