package com.lanyuanxiaoyao.service.sync.utils;

import cn.hutool.core.util.ObjectUtil;
import java.io.Serializable;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.DeserializationFeature;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.MapperFeature;
import org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Json 解析相关工具
 *
 * @author ZhangJiacheng
 * @date 2022-06-12
 */
public class JacksonUtils implements Serializable {
    private static final Logger logger = LoggerFactory.getLogger(JacksonUtils.class);

    private static ObjectMapper INSTANCE = null;

    public static ObjectMapper getMapper() {
        if (ObjectUtil.isNull(INSTANCE)) {
            INSTANCE = new ObjectMapper();
            INSTANCE.configure(MapperFeature.ACCEPT_CASE_INSENSITIVE_PROPERTIES, true);
            INSTANCE.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
            INSTANCE.configure(DeserializationFeature.FAIL_ON_IGNORED_PROPERTIES, false);
        }
        return INSTANCE;
    }
}
