All Downloads are FREE. Search and download functionalities are using the official Maven repository.

website.automate.waml.io.WamlConfig Maven / Gradle / Ivy

There is a newer version: 2.1.3
Show newest version
package website.automate.waml.io;

import website.automate.waml.io.deserializer.ActionDeserializer;
import website.automate.waml.io.model.action.Action;
import website.automate.waml.io.serliazer.WamlSerializerModifier;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

public class WamlConfig {
    
    private static final String MODULE_NAME = "waml-io";

    private static final WamlConfig INSTANCE = new WamlConfig();
    
    private ObjectMapper mapper = createMapper();
    
    public static WamlConfig getInstance(){
        return INSTANCE;
    }
    
    private ObjectMapper createMapper(){
        SimpleModule module = new SimpleModule(MODULE_NAME, Version.unknownVersion());
        module.addDeserializer(Action.class, new ActionDeserializer()); 
        module.setSerializerModifier(new WamlSerializerModifier());

        ObjectMapper mapper = new ObjectMapper(new YAMLFactory());  
        mapper.registerModule(module);
        mapper.setSerializationInclusion(Include.NON_NULL);
        return mapper;
    }
    
    public ObjectMapper getMapper(){
        return mapper;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy