Example usage for org.springframework.beans.factory.config YamlPropertiesFactoryBean setMatchDefault

List of usage examples for org.springframework.beans.factory.config YamlPropertiesFactoryBean setMatchDefault

Introduction

In this page you can find the example usage for org.springframework.beans.factory.config YamlPropertiesFactoryBean setMatchDefault.

Prototype

public void setMatchDefault(boolean matchDefault) 

Source Link

Document

Flag indicating that a document for which all the #setDocumentMatchers(DocumentMatcher) document matchers abstain will nevertheless match.

Usage

From source file:org.zalando.crypto.spring.boot.EncryptedYamlPropertySourceLoader.java

@Override
public PropertySource<?> load(final String name, final Resource resource, final String profile)
        throws IOException {
    validateDecrypter();/*  w w w.  ja va 2  s  .c  o  m*/
    if (ClassUtils.isPresent("org.yaml.snakeyaml.Yaml", null)) {
        YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean();
        if (profile == null) {
            factory.setMatchDefault(true);
            factory.setDocumentMatchers(new SpringProfileDocumentMatcher());
        } else {
            factory.setMatchDefault(false);
            factory.setDocumentMatchers(new SpringProfileDocumentMatcher(profile));
        }

        factory.setResources(new Resource[] { resource });

        Properties properties = factory.getObject();
        if (!properties.isEmpty()) {
            return new PropertiesPropertySource(name,
                    new EncryptableProperties(properties, decrypter, getPrefix()));
        }
    }

    return null;
}