
com.github.akurilov.confuse.io.yaml.YamlConfigProviderBase Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of confuse-io-yaml Show documentation
Show all versions of confuse-io-yaml Show documentation
Configuration serialization/deserialization to/from YAML
The newest version!
package com.github.akurilov.confuse.io.yaml;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
import com.github.akurilov.confuse.Config;
import com.github.akurilov.confuse.ConfigProvider;
import com.github.akurilov.confuse.impl.BasicConfig;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
public abstract class YamlConfigProviderBase
implements ConfigProvider {
@Override
public Config config(final String pathSep, final Map schema)
throws IOException {
final var mapper = new YAMLMapper()
.enable(DeserializationFeature.FAIL_ON_NULL_FOR_PRIMITIVES)
.enable(DeserializationFeature.FAIL_ON_READING_DUP_TREE_KEY)
.enable(SerializationFeature.INDENT_OUTPUT);
final Map configTree;
try(final var input = configInputStream()) {
configTree = mapper.readValue(input, new TypeReference
© 2015 - 2025 Weber Informatics LLC | Privacy Policy