class PropertySourcesUtils {

    public static Map<String, String> getSubProperties(Iterable<PropertySource<?>> propertySources, String prefix) {

        Map<String, String> subProperties = new LinkedHashMap<String, String>();

        String normalizedPrefix = normalizePrefix(prefix);

        PropertySourcesPropertyResolver propertyResolver = new PropertySourcesPropertyResolver((PropertySources) propertySources);

        for (PropertySource<?> source : propertySources) {
            if (source instanceof EnumerablePropertySource) {
                for (String name : ((EnumerablePropertySource<?>) source).getPropertyNames()) {
                    if (name.startsWith(normalizedPrefix)) {
                        String subName = name.substring(normalizedPrefix.length());
                        String value = propertyResolver.getProperty(name);
                        subProperties.putIfAbsent(subName, value);
                    }
                }
            }
        }

        return subProperties;

    }

}