Class ModelTypeProcessor


  • public class ModelTypeProcessor
    extends Object
    Helper class to deal with nested nature of modelType property in JSON. As Jackson can not natively deal with such nested type information, this class offers functions to unwrapp the modelType information via the preprocess(...) method and wrap it again via postprocess(...).
    • Constructor Detail

      • ModelTypeProcessor

        public ModelTypeProcessor()
    • Method Detail

      • preprocess

        public static com.fasterxml.jackson.databind.JsonNode preprocess​(String json)
                                                                  throws com.fasterxml.jackson.core.JsonProcessingException
        Unwrapps type information recursively, e.g. converts
         "modelType": {
              "name": "Foo"
         }
         
        to
         "modelType": "Foo"
         
        Parameters:
        json - json as string
        Returns:
        root node with unwrapped type information
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException - parsing JSON fails
      • postprocess

        public static com.fasterxml.jackson.databind.JsonNode postprocess​(com.fasterxml.jackson.databind.JsonNode node)
                                                                   throws com.fasterxml.jackson.core.JsonProcessingException
        Wraps type information recursively, e.g. converts
         "modelType": "Foo"
         
        to
         "modelType": {
              "name": "Foo"
         }
         
        Parameters:
        node - root node
        Returns:
        transformed root node
        Throws:
        com.fasterxml.jackson.core.JsonProcessingException - parsing JSON fails