Class DomainObjectReader

java.lang.Object
org.springframework.data.rest.webmvc.json.DomainObjectReader

public class DomainObjectReader extends Object
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

    Constructors
    Constructor
    Description
    DomainObjectReader(PersistentEntities entities, Associations associationLinks)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    <T> T
    read(InputStream source, T target, com.fasterxml.jackson.databind.ObjectMapper mapper)
    Reads the given input stream into an ObjectNode 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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • read

      public <T> T read(InputStream source, T target, com.fasterxml.jackson.databind.ObjectMapper mapper)
      Reads the given input stream into an ObjectNode 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