Package io.ran
Interface ISerializer
- All Known Implementing Classes:
GsonSerializer
public interface ISerializer
Used to convert objects to and from strings for storage in the database, for cases where the database does not
support the type natively and no converter is available.
This can also be used in cases where backwards compatibility is required.
-
Method Summary
Modifier and TypeMethodDescriptiondefault <T> T
deserialize
(Clazz<T> clazz, String value) Deserialize a string into an object of the given class.<T> T
deserialize
(Class<T> clazz, String value) Deserialize a string into an object of the given class.<T> String
serialize
(T object) Serialize an object into a string.
-
Method Details
-
deserialize
Deserialize a string into an object of the given class.For objects with no generics, this is the same as calling
deserialize(Clazz, String)
with aClazz
object.For objects with generics this may not preserve the type information, and
deserialize(Clazz, String)
should be used instead.- Type Parameters:
T
- The type of the object to deserialize.- Parameters:
clazz
- The class to deserialize into.value
- The string to deserialize.- Returns:
- An instance of the given class, deserialized from the given string.
-
deserialize
Deserialize a string into an object of the given class.Contains a more informed
Clazz
object instead of the basic JavaClass
.By default, this delegates to the existing
deserialize(Class, String)
method, but can be overridden to provide more information about the class being deserialized to the deserializer.- Type Parameters:
T
- The type of the object to deserialize.- Parameters:
clazz
- The class to deserialize into.value
- The string to deserialize.- Returns:
- An instance of the given class, deserialized from the given string.
-
serialize
Serialize an object into a string.- Type Parameters:
T
- The type of the object to serialize.- Parameters:
object
- The object to serialize.- Returns:
- A string representation of the given object.
-