package poussecafe.jackson;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectMapper.DefaultTyping;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import poussecafe.domain.Service;

public class JacksonObjectMapperFactory implements Service {

    public ObjectMapper buildMapper() {
        return staticBuildMapper();
    }

    public static ObjectMapper staticBuildMapper() {
        ObjectMapper mapper = new ObjectMapper();
        mapper.registerModule(new JavaTimeModule());
        mapper.setConfig(mapper.getSerializationConfig()
                .without(SerializationFeature.FAIL_ON_EMPTY_BEANS));
        mapper.setConfig(mapper.getDeserializationConfig()
                .without(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES));
        mapper.enableDefaultTyping(DefaultTyping.NON_FINAL, As.PROPERTY);
        mapper.setVisibility(mapper.getSerializationConfig().getDefaultVisibilityChecker()
                .withFieldVisibility(JsonAutoDetect.Visibility.ANY)
                .withGetterVisibility(JsonAutoDetect.Visibility.NONE)
                .withSetterVisibility(JsonAutoDetect.Visibility.NONE)
                .withCreatorVisibility(JsonAutoDetect.Visibility.NONE));
        return mapper;
    }
}

@@ -135,16 +135,122 @@
 nfo.As;%0A
+import com.fasterxml.jackson.core.JsonGenerator;%0Aimport com.fasterxml.jackson.core.json.JsonWriteFeature;%0A
 import c
@@ -295,32 +295,32 @@
 izationFeature;%0A
-
 import com.faste
@@ -874,24 +874,25 @@
 eModule());%0A
+%0A
         mapp
@@ -1001,24 +1001,229 @@
 TY_BEANS));%0A
+        mapper.setConfig(mapper.getSerializationConfig()%0A                .with(JsonWriteFeature.WRITE_NUMBERS_AS_STRINGS));%0A        mapper.configure(JsonGenerator.Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);%0A
         mapp
@@ -1343,24 +1343,25 @@
 OPERTIES));%0A
+%0A
         mapp
@@ -1367,13 +1367,15 @@
 per.
-enabl
+activat
 eDef
@@ -1385,16 +1385,54 @@
 tTyping(
+mapper.getPolymorphicTypeValidator(), 
 DefaultT

JSON-serialize numbers as string.