use of org.codehaus.jackson.map.type.TypeFactory in project motech by motech.
the class TaskDeserializer method deserialize.
@Override
public Task deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {
jsonNode = jsonParser.readValueAsTree();
task = new Task();
ObjectCodec codec = jsonParser.getCodec();
if (codec instanceof ObjectMapper) {
mapper = (ObjectMapper) codec;
} else {
mapper = new ObjectMapper();
}
TypeFactory typeFactory = mapper.getTypeFactory();
JavaType stringType = typeFactory.constructType(String.class);
JavaType longType = typeFactory.constructType(Long.class);
JavaType intType = typeFactory.constructType(Integer.class);
JavaType dateTime = typeFactory.constructType(DateTime.class);
JavaType booleanType = typeFactory.constructType(boolean.class);
JavaType timeType = typeFactory.constructType(Time.class);
setProperty("id", longType);
setProperty("owner", stringType);
setProperty("creator", stringType);
setProperty("creationDate", dateTime);
setProperty("modificationDate", dateTime);
setProperty("modifiedBy", stringType);
setProperty("description", stringType);
setProperty("name", stringType);
setProperty("enabled", stringType);
setProperty("hasRegisteredChannel", stringType);
setProperty("taskConfig", typeFactory.constructType(TaskConfig.class));
setProperty("trigger", typeFactory.constructType(TaskTriggerInformation.class));
setProperty("numberOfRetries", intType);
setProperty("retryIntervalInMilliseconds", intType);
setProperty("retryTaskOnFailure", stringType);
setProperty("useTimeWindow", booleanType);
setProperty("startTime", timeType);
setProperty("endTime", timeType);
setProperty("validationErrors", typeFactory.constructCollectionType(Set.class, TaskError.class));
setProperty("actions", typeFactory.constructCollectionType(List.class, TaskActionInformation.class));
setProperty("days", typeFactory.constructCollectionType(List.class, String.class));
return task;
}
use of org.codehaus.jackson.map.type.TypeFactory in project incubator-gobblin by apache.
the class KafkaCheckpoint method deserialize.
public static KafkaCheckpoint deserialize(InputStream inputStream) throws IOException {
TypeFactory typeFactory = _mapper.getTypeFactory();
MapType mapType = typeFactory.constructMapType(HashMap.class, Integer.class, Long.class);
HashMap<Integer, Long> checkpoint = _mapper.readValue(inputStream, mapType);
return new KafkaCheckpoint(checkpoint);
}
Aggregations