Package org.springframework.data.mapping
Class TraversalContext
java.lang.Object
org.springframework.data.mapping.TraversalContext
A context object for lookups of values for
PersistentPropertyPaths
via a PersistentPropertyAccessor
.
It allows to register functions to post-process the objects returned for a particular property, so that the
subsequent traversal would rather use the processed object. This is especially helpful if you need to traverse paths
that contain Collection
s and Map
that usually need indices and keys to reasonably traverse nested
properties.- Since:
- 2.2
- Author:
- Oliver Drotbohm
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionregisterCollectionHandler
(PersistentProperty<?> property, Function<? super Collection<?>, Object> handler) Registers aFunction
to handleCollection
values for the given property.<T> TraversalContext
registerHandler
(PersistentProperty<?> property, Class<T> type, Function<? super T, Object> handler) Registers the givenFunction
to post-process values obtained for the givenPersistentProperty
for the given type.registerHandler
(PersistentProperty<?> property, Function<Object, Object> handler) Registers aFunction
to post-process values for the given property.registerListHandler
(PersistentProperty<?> property, Function<? super List<?>, Object> handler) registerMapHandler
(PersistentProperty<?> property, Function<? super Map<?, ?>, Object> handler) registerSetHandler
(PersistentProperty<?> property, Function<? super Set<?>, Object> handler)
-
Constructor Details
-
TraversalContext
public TraversalContext()
-
-
Method Details
-
registerHandler
public TraversalContext registerHandler(PersistentProperty<?> property, Function<Object, Object> handler) Registers aFunction
to post-process values for the given property.- Parameters:
property
- must not be null.handler
- must not be null.- Returns:
-
registerCollectionHandler
public TraversalContext registerCollectionHandler(PersistentProperty<?> property, Function<? super Collection<?>, Object> handler) Registers aFunction
to handleCollection
values for the given property.- Parameters:
property
- must not be null.handler
- must not be null.- Returns:
-
registerListHandler
public TraversalContext registerListHandler(PersistentProperty<?> property, Function<? super List<?>, Object> handler) - Parameters:
property
- must not be null.handler
- must not be null.- Returns:
-
registerSetHandler
public TraversalContext registerSetHandler(PersistentProperty<?> property, Function<? super Set<?>, Object> handler) - Parameters:
property
- must not be null.handler
- must not be null.- Returns:
-
registerMapHandler
public TraversalContext registerMapHandler(PersistentProperty<?> property, Function<? super Map<?, ?>, Object> handler) - Parameters:
property
- must not be null.handler
- must not be null.- Returns:
-
registerHandler
public <T> TraversalContext registerHandler(PersistentProperty<?> property, Class<T> type, Function<? super T, Object> handler) Registers the givenFunction
to post-process values obtained for the givenPersistentProperty
for the given type.- Type Parameters:
T
- the type of the value to handle.- Parameters:
property
- must not be null.type
- must not be null.handler
- must not be null.- Returns:
-