package at.gv.egiz.eaaf.core.impl.utils; import at.gv.egiz.eaaf.core.api.idp.IConfiguration; import at.gv.egiz.eaaf.core.exceptions.EaafConfigurationException; import lombok.extern.slf4j.Slf4j; /** * Utils for configuration value mapping. * * @author tlenz * */ @Slf4j public class ConfigurationUtils { /** * Parse Integer value from configuration. * * @param basicConfig Configuration object * @param propertyKey Configuration key * @return Configuration value * @throws EaafConfigurationException If configuration value is not an Integer */ public static int parseInteger(IConfiguration basicConfig, String propertyKey) throws EaafConfigurationException { try { return Integer.parseInt(basicConfig.getBasicConfiguration(propertyKey)); } catch (NumberFormatException e) { log.error("Can not read Integer value from configuration: {}", propertyKey, e); throw new EaafConfigurationException("internal.configuration.02", new Object[] { propertyKey, Integer.class.getSimpleName() }, e); } } /** * Parse Long value from configuration. * * @param basicConfig Configuration object * @param propertyKey Configuration key * @return Configuration value * @throws EaafConfigurationException If configuration value is not an Long */ public static long parseLong(IConfiguration basicConfig, String propertyKey) throws EaafConfigurationException { try { return Long.parseLong(basicConfig.getBasicConfiguration(propertyKey)); } catch (NumberFormatException e) { log.error("Can not read Long value from configuration: {}", propertyKey, e); throw new EaafConfigurationException("internal.configuration.02", new Object[] { propertyKey, Long.class.getSimpleName() }, e); } } private ConfigurationUtils() { } }