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

io.dropwizard.configuration.DefaultConfigurationFactoryFactory Maven / Gradle / Ivy

There is a newer version: 0.0.3
Show newest version
package io.dropwizard.configuration;

import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;

import javax.validation.Validator;

public class DefaultConfigurationFactoryFactory implements ConfigurationFactoryFactory {
    @Override
    public ConfigurationFactory create(
            Class     klass,
            Validator    validator,
            ObjectMapper objectMapper,
            String       propertyPrefix) {
        return new YamlConfigurationFactory<>(
            klass,
            validator,
            configureObjectMapper(objectMapper.copy()),
            propertyPrefix);
    }

    /**
     * Provides additional configuration for the {@link ObjectMapper} used to read
     * the configuration. By default {@link DeserializationFeature#FAIL_ON_UNKNOWN_PROPERTIES}
     * is enabled to protect against misconfiguration.
     *
     * @param objectMapper template to be configured
     * @return configured object mapper
     */
    protected ObjectMapper configureObjectMapper(ObjectMapper objectMapper) {
        return objectMapper.enable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy