@Test public void shouldDeserializeJson() throws IOException { Assert.assertEquals(EXPECTED_TASK, new TaskDeserializer().deserialize(jsonParser, null)); }
@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; }
TaskDeserializer extends JsonDeserializer<Task> { @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; } }
TaskDeserializer extends JsonDeserializer<Task> { @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; }  }
TaskDeserializer extends JsonDeserializer<Task> { @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; }  @Override Task deserialize(JsonParser jsonParser,
                            DeserializationContext deserializationContext); }
TaskDeserializer extends JsonDeserializer<Task> { @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; }  @Override Task deserialize(JsonParser jsonParser,
                            DeserializationContext deserializationContext);  }