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

liquibase.configuration.ConfigurationValueUtils Maven / Gradle / Ivy

The newest version!
package liquibase.configuration;

import liquibase.Scope;
import liquibase.util.ObjectUtil;

import java.util.concurrent.atomic.AtomicReference;

public class ConfigurationValueUtils {
    /**
     *
     * Call the convert method with the argument key in the current scope
     * so that it can be used in an error message
     * @param   key             The name of the argument
     * @param   value           The argument value
     * @param   converter       The converter method
     * @return  
     *
     */
    public static  T convertDataType(String key, T value, ConfigurationValueConverter converter) {
        AtomicReference reference = new AtomicReference<>();
        try {
            Scope.child(ObjectUtil.ARGUMENT_KEY, key, () ->
                    reference.set(converter.convert(value)));
        } catch (Exception e) {
            throw new IllegalArgumentException(e);
        }
        return reference.get();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy