Example usage for org.springframework.core.env MutablePropertySources forEach

List of usage examples for org.springframework.core.env MutablePropertySources forEach

Introduction

In this page you can find the example usage for org.springframework.core.env MutablePropertySources forEach.

Prototype

default void forEach(Consumer<? super T> action) 

Source Link

Document

Performs the given action for each element of the Iterable until all elements have been processed or the action throws an exception.

Usage

From source file:ch.sdi.core.TestUtils.java

/**
 * Removes all key/value pairs from environment
 * @param aEnv//from ww  w . j av a 2  s.co  m
 */
public static void removeAllFromEnvironment(ConfigurableEnvironment aEnv) {
    MutablePropertySources propertySources = aEnv.getPropertySources();
    List<PropertySource<?>> toRemove = new ArrayList<PropertySource<?>>();
    propertySources.forEach(p -> toRemove.add(p));
    toRemove.forEach(p -> propertySources.remove(p.getName()));
}