public class DefaultStringKeySerializer
extends java.lang.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(java.lang.String cacheName,
java.nio.charset.Charset charset,
io.micronaut.core.convert.ConversionService<?> conversionService)
Construct a default serializer for given parameters.
|
Modifier and Type | Method and Description |
---|---|
<T> java.util.Optional<T> |
deserialize(java.io.InputStream inputStream,
java.lang.Class<T> requiredType) |
java.util.Optional<byte[]> |
serialize(java.lang.Object object) |
void |
serialize(java.lang.Object object,
java.io.OutputStream outputStream) |
public DefaultStringKeySerializer(java.lang.String cacheName, java.nio.charset.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 java.util.Optional<byte[]> serialize(java.lang.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(java.lang.Object object, java.io.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> java.util.Optional<T> deserialize(java.io.InputStream inputStream, java.lang.Class<T> requiredType) throws io.micronaut.core.serialize.exceptions.SerializationException
deserialize
in interface io.micronaut.core.serialize.ObjectSerializer
io.micronaut.core.serialize.exceptions.SerializationException