org.springframework.data.keyvalue.redis.serializer
Class GenericToStringSerializer<T>
java.lang.Object
org.springframework.data.keyvalue.redis.serializer.GenericToStringSerializer<T>
- All Implemented Interfaces:
- BeanFactoryAware, RedisSerializer<T>
public class GenericToStringSerializer<T>
- extends Object
- implements RedisSerializer<T>, BeanFactoryAware
Generic String to byte[] (and back) serializer. Relies on the Spring ConversionService
to transform objects into String and vice versa. The Strings are convert into bytes and vice-versa
using the specified charset (by default UTF-8).
Note: The conversion service initialization happens automatically if the class is defined
as a Spring bean.
Note: Does not handle nulls in any special way delegating everything to the container.
- Author:
- Costin Leau
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
GenericToStringSerializer
public GenericToStringSerializer(Class<T> type)
GenericToStringSerializer
public GenericToStringSerializer(Class<T> type,
Charset charset)
setConversionService
public void setConversionService(ConversionService conversionService)
setTypeConverter
public void setTypeConverter(TypeConverter typeConverter)
deserialize
public T deserialize(byte[] bytes)
- Description copied from interface:
RedisSerializer
- Deserialize an object from the given binary data.
- Specified by:
deserialize
in interface RedisSerializer<T>
- Parameters:
bytes
- object binary representation
- Returns:
- the equivalent object instance
serialize
public byte[] serialize(T object)
- Description copied from interface:
RedisSerializer
- Serialize the given object to binary data.
- Specified by:
serialize
in interface RedisSerializer<T>
- Parameters:
object
- object to serialize
- Returns:
- the equivalent binary data
setBeanFactory
public void setBeanFactory(BeanFactory beanFactory)
throws BeansException
- Specified by:
setBeanFactory
in interface BeanFactoryAware
- Throws:
BeansException
Copyright © 2010-2011 SpringSource. All Rights Reserved.