website.automate.waml.io.WamlConfig Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of waml-io Show documentation
Show all versions of waml-io Show documentation
(De)Serializer of the web automation markup language (WAML) for Java
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;
}
}