Class ObjectHashMapper
java.lang.Object
org.springframework.data.redis.hash.ObjectHashMapper
- All Implemented Interfaces:
HashMapper<Object,byte[], byte[]>
HashMapper based on MappingRedisConverter. Supports nested properties and simple types like
String.
class Person {
String firstname;
String lastname;
List<String> nicknames;
List<Person> coworkers;
Address address;
}
The above is represented as:
_class=org.example.Person
firstname=rand
lastname=al'thor
coworkers.[0].firstname=mat
coworkers.[0].nicknames.[0]=prince of the ravens
coworkers.[1].firstname=perrin
coworkers.[1].address.city=two rivers
- Since:
- 1.8
- Author:
- Christoph Strobl, Mark Paluch
-
Constructor Summary
ConstructorsConstructorDescriptionCreates newObjectHashMapper.ObjectHashMapper(org.springframework.data.convert.CustomConversions customConversions) Creates newObjectHashMapper.ObjectHashMapper(RedisConverter converter) Creates a newObjectHashMapperusing the givenRedisConverterfor conversion. -
Method Summary
Modifier and TypeMethodDescriptionConvert ahash(map) to an object.<T> TConvert ahash(map) to an object and return the casted result.static ObjectHashMapperReturn a shared defaultObjectHashMapperinstance, lazily building it once needed.Map<byte[],byte[]> Convert anobjectto a map that can be used with Redis hashes.
-
Constructor Details
-
ObjectHashMapper
public ObjectHashMapper()Creates newObjectHashMapper. -
ObjectHashMapper
Creates a newObjectHashMapperusing the givenRedisConverterfor conversion.- Parameters:
converter- must not be null.- Throws:
IllegalArgumentException- if the given converter is null.- Since:
- 2.4
-
ObjectHashMapper
public ObjectHashMapper(@Nullable org.springframework.data.convert.CustomConversions customConversions) Creates newObjectHashMapper.- Parameters:
customConversions- can be null.- Since:
- 2.0
-
-
Method Details
-
toHash
Description copied from interface:HashMapperConvert anobjectto a map that can be used with Redis hashes.- Specified by:
toHashin interfaceHashMapper<Object,byte[], byte[]> - Returns:
-
fromHash
Description copied from interface:HashMapperConvert ahash(map) to an object.- Specified by:
fromHashin interfaceHashMapper<Object,byte[], byte[]> - Returns:
-
fromHash
Convert ahash(map) to an object and return the casted result.- Type Parameters:
T-- Parameters:
hash-type-- Returns: