Search in sources :

Example 1 with SuperclassModel

use of com.serotonin.m2m2.web.mvc.rest.v1.model.SuperclassModel in project ma-core-public by infiniteautomation.

the class SuperclassModelDeserializer method deserialize.

/* (non-Javadoc)
	 * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext)
	 */
@Override
public SuperclassModel<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
    ObjectMapper mapper = (ObjectMapper) jp.getCodec();
    JsonNode tree = jp.readValueAsTree();
    ModelDefinition definition = findModelDefinition(tree.get("type").asText());
    return (SuperclassModel<?>) mapper.treeToValue(tree, definition.getModelClass());
}
Also used : ModelDefinition(com.serotonin.m2m2.module.ModelDefinition) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) SuperclassModel(com.serotonin.m2m2.web.mvc.rest.v1.model.SuperclassModel)

Aggregations

JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ModelDefinition (com.serotonin.m2m2.module.ModelDefinition)1 SuperclassModel (com.serotonin.m2m2.web.mvc.rest.v1.model.SuperclassModel)1