use of com.serotonin.m2m2.web.mvc.rest.v1.model.dataPoint.PointLocatorModel in project ma-core-public by infiniteautomation.
the class PointLocatorModelDeserializer method deserialize.
/* (non-Javadoc)
* @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext)
*/
@Override
public PointLocatorModel<?> deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JsonProcessingException {
ObjectMapper mapper = (ObjectMapper) jp.getCodec();
JsonNode tree = jp.readValueAsTree();
if (!tree.hasNonNull("modelType"))
throw new IOException("No modelType field found for point locator model.");
ModelDefinition definition = findModelDefinition(tree.get("modelType").asText());
return (PointLocatorModel<?>) mapper.treeToValue(tree, definition.getModelClass());
}
Aggregations