Interface Serializer<M>
- Type Parameters:
M
- the medium type
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
Serializer.Default
public interface Serializer<M> extends AutoCloseable
Convenient API layer to use the binary persistence functionality for a simple serializer.
It is based on a SerializerFoundation
, which can be configured to various needs.
Per default Binary
and byte[]
are supported as medium types.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
Serializer.Default<M>
static interface
Serializer.Source
static class
Serializer.Static
static interface
Serializer.Target
-
Method Summary
Modifier and Type Method Description static Serializer<Binary>
Binary()
static Serializer<Binary>
Binary(SerializerFoundation<?> foundation)
static Serializer<byte[]>
Bytes()
static Serializer<byte[]>
Bytes(SerializerFoundation<?> foundation)
<T> T
deserialize(M medium)
Recreates an object graph based on the given data.static <M> Serializer<M>
New(Function<Binary,M> toMedium, Function<M,Binary> toBinary)
static <M> Serializer<M>
New(SerializerFoundation<?> foundation, Function<Binary,M> toMedium, Function<M,Binary> toBinary)
M
serialize(Object object)
Serializes the given object graph into the medium type.
-
Method Details
-
serialize
Serializes the given object graph into the medium type.- Parameters:
object
- the graph's root- Returns:
- the binary format
-
deserialize
Recreates an object graph based on the given data.- Type Parameters:
T
- the object's type- Parameters:
medium
- the medium to read from- Returns:
- the deserialized object graph
-
Binary
-
Binary
-
Bytes
-
Bytes
-
New
-
New
static <M> Serializer<M> New(SerializerFoundation<?> foundation, Function<Binary,M> toMedium, Function<M,Binary> toBinary)
-