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

com.alibaba.spring.util.PropertyValuesUtils Maven / Gradle / Ivy

package com.alibaba.spring.util;

import org.springframework.beans.MutablePropertyValues;
import org.springframework.beans.PropertyValues;
import org.springframework.core.env.ConfigurableEnvironment;

import java.util.Map;

import static com.alibaba.spring.util.PropertySourcesUtils.getSubProperties;

/**
 * {@link PropertyValues} Utilities
 *
 * @author Mercy
 * @see PropertyValues
 * @since 2017.01.19
 */
public abstract class PropertyValuesUtils {

    /**
     * Get Sub {@link PropertyValues} from {@link ConfigurableEnvironment}
     *
     * @param environment {@link ConfigurableEnvironment}
     * @param prefix      the prefix of property name
     * @return {@link PropertyValues}
     */
    public static PropertyValues getSubPropertyValues(ConfigurableEnvironment environment, String prefix) {

        Map subProperties = getSubProperties(environment.getPropertySources(), environment, prefix);

        PropertyValues subPropertyValues = new MutablePropertyValues(subProperties);

        return subPropertyValues;

    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy