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
ConstructorDescriptionCreates newObjectHashMapper
.ObjectHashMapper
(org.springframework.data.convert.CustomConversions customConversions) Creates newObjectHashMapper
.ObjectHashMapper
(RedisConverter converter) Creates a newObjectHashMapper
using the givenRedisConverter
for conversion. -
Method Summary
Modifier and TypeMethodDescriptionConvert ahash
(map) to an object.<T> T
Convert ahash
(map) to an object and return the casted result.static ObjectHashMapper
Return a shared defaultObjectHashMapper
instance, lazily building it once needed.Map<byte[],
byte[]> Convert anobject
to a map that can be used with Redis hashes.
-
Constructor Details
-
ObjectHashMapper
public ObjectHashMapper()Creates newObjectHashMapper
. -
ObjectHashMapper
Creates a newObjectHashMapper
using the givenRedisConverter
for 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:HashMapper
Convert anobject
to a map that can be used with Redis hashes.- Specified by:
toHash
in interfaceHashMapper<Object,
byte[], byte[]> - Returns:
-
fromHash
Description copied from interface:HashMapper
Convert ahash
(map) to an object.- Specified by:
fromHash
in interfaceHashMapper<Object,
byte[], byte[]> - Returns:
-
fromHash
Convert ahash
(map) to an object and return the casted result.- Type Parameters:
T
-- Parameters:
hash
-type
-- Returns: