Class JacksonMapper

    • Constructor Detail

      • JacksonMapper

        public JacksonMapper()
    • Method Detail

      • registerJacksonModule

        public void registerJacksonModule​(com.fasterxml.jackson.databind.Module module)
        Registers a Jackson module with the object mapper.
        Parameters:
        module - the Jackson module to register
        Throws:
        ValidationException - if the module is null
      • tryConvert

        public <Source,​Target> Object tryConvert​(Source source,
                                                       Class<Target> type)
        Tries to convert the given source object to the target type using Jackson ObjectMapper.

        If the source object is null, returns null. If the source object is a value node, returns the node value. If the target type is Document, converts the source object to a Document. If the source object is already a Document, converts it to the target type. If the conversion fails, throws an ObjectMappingException.

        Specified by:
        tryConvert in interface NitriteMapper
        Type Parameters:
        Source - the type of the source object
        Target - the type of the target object
        Parameters:
        source - the source object to convert
        type - the target type to convert to
        Returns:
        the converted object of the target type
        Throws:
        ObjectMappingException - if the conversion fails