private static ObjectMapper createObjectMapper()

in aws-lambda-java-serialization/src/main/java/com/amazonaws/services/lambda/runtime/serialization/factories/JacksonFactory.java [57:121]


    private static ObjectMapper createObjectMapper() {
        ObjectMapper mapper = JsonMapper.builder(createJsonFactory())
                .enable(MapperFeature.ALLOW_FINAL_FIELDS_AS_MUTATORS)                       // this is default as of 2.2.0
                .enable(MapperFeature.AUTO_DETECT_FIELDS)                                   // this is default as of 2.0.0
                .enable(MapperFeature.AUTO_DETECT_GETTERS)                                  // this is default as of 2.0.0
                .enable(MapperFeature.AUTO_DETECT_IS_GETTERS)                               // this is default as of 2.0.0
                .enable(MapperFeature.AUTO_DETECT_SETTERS)                                  // this is default as of 2.0.0
                .enable(MapperFeature.CAN_OVERRIDE_ACCESS_MODIFIERS)                        // this is default as of 2.0.0
                .enable(MapperFeature.USE_STD_BEAN_NAMING)
                .enable(MapperFeature.USE_ANNOTATIONS)                                      // this is default as of 2.0.0
                .disable(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)                  // this is default as of 2.5.0
                .disable(MapperFeature.AUTO_DETECT_CREATORS)
                .disable(MapperFeature.INFER_PROPERTY_MUTATORS)
                .disable(MapperFeature.SORT_PROPERTIES_ALPHABETICALLY)                      // this is default as of 2.0.0
                .disable(MapperFeature.USE_GETTERS_AS_SETTERS)
                .disable(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME)                   // this is default as of 2.1.0
                .disable(MapperFeature.USE_STATIC_TYPING)                                   // this is default as of 2.0.0
                .disable(MapperFeature.REQUIRE_SETTERS_FOR_GETTERS)                         // this is default as of 2.0.0
                .build();

        SerializationConfig scfg = mapper.getSerializationConfig();
        scfg = scfg.withFeatures(
                SerializationFeature.FAIL_ON_SELF_REFERENCES,                               // this is default as of 2.4.0
                SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS,                    // this is default as of 2.4.0
                SerializationFeature.WRAP_EXCEPTIONS                                        // this is default as of 2.0.0
        );
        scfg = scfg.withoutFeatures(
                SerializationFeature.CLOSE_CLOSEABLE,                                       // this is default as of 2.0.0
                SerializationFeature.EAGER_SERIALIZER_FETCH,
                SerializationFeature.FAIL_ON_EMPTY_BEANS,
                SerializationFeature.FLUSH_AFTER_WRITE_VALUE,
                SerializationFeature.INDENT_OUTPUT,                                         // this is default as of 2.5.0
                SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS,                             // this is default as of 2.0.0
                SerializationFeature.USE_EQUALITY_FOR_OBJECT_ID,                            // this is default as of 2.3.0
                SerializationFeature.WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS,                      // this is default as of 2.0.0
                SerializationFeature.WRAP_ROOT_VALUE                                        // this is default as of 2.2.0
        );
        mapper.setConfig(scfg);

        DeserializationConfig dcfg = mapper.getDeserializationConfig();
        dcfg = dcfg.withFeatures(
                DeserializationFeature.ACCEPT_EMPTY_ARRAY_AS_NULL_OBJECT,
                DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT,
                DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY,
                DeserializationFeature.FAIL_ON_INVALID_SUBTYPE,                             // this is default as of 2.2.0
                DeserializationFeature.FAIL_ON_UNRESOLVED_OBJECT_IDS,                       // this is default as of 2.5.0
                DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL,
                DeserializationFeature.UNWRAP_SINGLE_VALUE_ARRAYS,
                DeserializationFeature.WRAP_EXCEPTIONS                                      // this is default as of 2.0.0
        );
        dcfg = dcfg.withoutFeatures(
                DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES,                          // this is default as of 2.3.0
                DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES,                         // this is default as of 2.0.0
                DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS,                           // this is default as of 2.0.0
                DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY,                        // this is default as of 2.3.0
                DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES
        );
        mapper.setConfig(dcfg);
        mapper.setSerializationInclusion(Include.NON_NULL);

        mapper.registerModule(new JavaTimeModule());
        mapper.registerModule(new Jdk8Module());

        return mapper;
    }