Example usage for org.springframework.core.env MapPropertySource containsProperty

List of usage examples for org.springframework.core.env MapPropertySource containsProperty

Introduction

In this page you can find the example usage for org.springframework.core.env MapPropertySource containsProperty.

Prototype

@Override
    public boolean containsProperty(String name) 

Source Link

Usage

From source file:io.spring.initializr.web.autoconfigure.CloudfoundryEnvironmentPostProcessor.java

private static void addOrReplace(MutablePropertySources propertySources, Map<String, Object> map) {
    MapPropertySource target = null;
    if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
        PropertySource<?> source = propertySources.get(PROPERTY_SOURCE_NAME);
        if (source instanceof MapPropertySource) {
            target = (MapPropertySource) source;
            for (String key : map.keySet()) {
                if (!target.containsProperty(key)) {
                    target.getSource().put(key, map.get(key));
                }/*from  ww  w . ja v  a  2s  . c o m*/
            }
        }
    }
    if (target == null) {
        target = new MapPropertySource(PROPERTY_SOURCE_NAME, map);
    }
    if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
        propertySources.addLast(target);
    }
}

From source file:com.example.journal.env.JournalEnvironmentPostProcessor.java

private void addOrReplace(MutablePropertySources propertySources, Map<String, Object> map) {
    MapPropertySource target = null;
    if (propertySources.contains(PROPERTY_SOURCE_NAME)) {
        PropertySource<?> source = propertySources.get(PROPERTY_SOURCE_NAME);
        if (source instanceof MapPropertySource) {
            target = (MapPropertySource) source;
            for (String key : map.keySet()) {
                if (!target.containsProperty(key)) {
                    target.getSource().put(key, map.get(key));
                }//  w  ww.j  a  v  a 2 s .co m
            }
        }
    }
    if (target == null) {
        target = new MapPropertySource(PROPERTY_SOURCE_NAME, map);
    }
    if (!propertySources.contains(PROPERTY_SOURCE_NAME)) {
        propertySources.addLast(target);
    }
}