Class DomainObjectReader
java.lang.Object
org.springframework.data.rest.webmvc.json.DomainObjectReader
Component to apply an
ObjectNode
to an existing domain object. This is effectively a best-effort workaround
for Jackson's inability to apply a (partial) JSON document to an existing object in a deeply nested way. We manually
detect nested objects, lookup the original value and apply the merge recursively.- Since:
- 2.2
- Author:
- Oliver Gierke, Mark Paluch, Craig Andrews, Mathias Düsterhöft, Thomas Mrozinski, Lars Vierbergen
-
Constructor Summary
ConstructorDescriptionDomainObjectReader
(org.springframework.data.mapping.context.PersistentEntities entities, Associations associationLinks) -
Method Summary
Modifier and TypeMethodDescription<T> T
read
(InputStream source, T target, com.fasterxml.jackson.databind.ObjectMapper mapper) Reads the given input stream into anObjectNode
and applies that to the given existing instance.<T> T
readPut
(com.fasterxml.jackson.databind.node.ObjectNode source, T target, com.fasterxml.jackson.databind.ObjectMapper mapper) Reads the given source node onto the given target object and applies PUT semantics, i.e. explicitly
-
Constructor Details
-
DomainObjectReader
public DomainObjectReader(org.springframework.data.mapping.context.PersistentEntities entities, Associations associationLinks)
-
-
Method Details
-
read
Reads the given input stream into anObjectNode
and applies that to the given existing instance.- Parameters:
source
- must not be null.target
- must not be null.mapper
- must not be null.- Returns:
-
readPut
public <T> T readPut(com.fasterxml.jackson.databind.node.ObjectNode source, T target, com.fasterxml.jackson.databind.ObjectMapper mapper) throws Exception Reads the given source node onto the given target object and applies PUT semantics, i.e. explicitly- Parameters:
source
- must not be null.target
- must not be null.mapper
-- Returns:
- Throws:
Exception
-