public class DefaultStringKeySerializer extends Object implements io.micronaut.core.serialize.ObjectSerializer
The default key serializer used by caches that require serializing the keys as strings. Builds a key from the
configured cache name and String conversion of the object as dictated by ConversionService
.
Note this implementation does not support deserialization
Constructor and Description |
---|
DefaultStringKeySerializer(String cacheName,
Charset charset,
io.micronaut.core.convert.ConversionService<?> conversionService)
Construct a default serializer for given parameters.
|
Modifier and Type | Method and Description |
---|---|
<T> Optional<T> |
deserialize(InputStream inputStream,
Class<T> requiredType) |
Optional<byte[]> |
serialize(Object object) |
void |
serialize(Object object,
OutputStream outputStream) |
public DefaultStringKeySerializer(String cacheName, Charset charset, io.micronaut.core.convert.ConversionService<?> conversionService)
cacheName
- The cache key or namecharset
- The charset used for serialization and de-serializing instance from the to/from cacheconversionService
- To convert value/object from the cache to Stringpublic Optional<byte[]> serialize(Object object) throws io.micronaut.core.serialize.exceptions.SerializationException
serialize
in interface io.micronaut.core.serialize.ObjectSerializer
io.micronaut.core.serialize.exceptions.SerializationException
public void serialize(Object object, OutputStream outputStream) throws io.micronaut.core.serialize.exceptions.SerializationException
serialize
in interface io.micronaut.core.serialize.ObjectSerializer
io.micronaut.core.serialize.exceptions.SerializationException
public <T> Optional<T> deserialize(InputStream inputStream, Class<T> requiredType) throws io.micronaut.core.serialize.exceptions.SerializationException
deserialize
in interface io.micronaut.core.serialize.ObjectSerializer
io.micronaut.core.serialize.exceptions.SerializationException