Class JacksonTranslationService

java.lang.Object
org.springframework.data.couchbase.core.convert.translation.JacksonTranslationService
All Implemented Interfaces:
InitializingBean, TranslationService

public class JacksonTranslationService extends Object implements TranslationService, InitializingBean
A Jackson JSON Translator that implements the TranslationService contract.
Author:
Michael Nitschinger, Simon Baslé, Anastasiia Smirnova, Mark Paluch
  • Constructor Details

    • JacksonTranslationService

      public JacksonTranslationService()
  • Method Details

    • encode

      public final String encode(CouchbaseStorable source)
      Encode a CouchbaseStorable to a JSON string.
      Specified by:
      encode in interface TranslationService
      Parameters:
      source - the source document to encode.
      Returns:
      the encoded JSON String.
    • decode

      public final CouchbaseStorable decode(String source, CouchbaseStorable target)
      Decode a JSON string into the CouchbaseStorable structure.
      Specified by:
      decode in interface TranslationService
      Parameters:
      source - the source formatted document.
      target - the target of the populated data.
      Returns:
      the decoded structure.
    • decodeFragment

      public <T> T decodeFragment(String source, Class<T> target)
      Description copied from interface: TranslationService
      Decodes an ad-hoc JSON object into a corresponding "case" class.
      Specified by:
      decodeFragment in interface TranslationService
      Type Parameters:
      T - the target class.
      Parameters:
      source - the JSON for the ad-hoc JSON object (from a N1QL query for instance).
      target - the target class information.
      Returns:
      an ad-hoc instance of the decoded JSON into the corresponding "case" class.
    • setObjectMapper

      public void setObjectMapper(com.fasterxml.jackson.databind.ObjectMapper objectMapper)
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface InitializingBean