/** * Gets a property value as a {@link BigDecimal}. * * @param configurationValue the {@link BigDecimal} configuration value * @param environment the environment containing the property * * @return the {@link BigDecimal} property value */ public BigDecimal getBigDecimalRequiredProperty(ConfigurationValue configurationValue, Environment environment) { String bigDecimalStringValue = getRequiredProperty(configurationValue, environment); BigDecimal bigDecimalValue = null; try { // Converts the string value to BigDecimal bigDecimalValue = new BigDecimal(bigDecimalStringValue); } catch (NumberFormatException numberFormatException) { logErrorAndThrowIllegalStateException(configurationValue, "BigDecimal", bigDecimalStringValue, numberFormatException); } return bigDecimalValue; }
/** * Gets a property value as a {@link BigDecimal}. * * @param configurationValue the {@link BigDecimal} configuration value * @param environment the environment containing the property * * @return the {@link BigDecimal} property value */ public BigDecimal getBigDecimalRequiredProperty(ConfigurationValue configurationValue, Environment environment) { String bigDecimalStringValue = getRequiredProperty(configurationValue, environment); BigDecimal bigDecimalValue = null; try { // Converts the string value to BigDecimal bigDecimalValue = new BigDecimal(bigDecimalStringValue); } catch (NumberFormatException numberFormatException) { logErrorAndThrowIllegalStateException(configurationValue, "BigDecimal", bigDecimalStringValue, numberFormatException); } return bigDecimalValue; }
/** * Gets a property value as a boolean. * * @param configurationValue the boolean configuration value * @param environment the environment containing the property * * @return the boolean property value */ public Boolean getBooleanProperty(ConfigurationValue configurationValue, Environment environment) { String booleanStringValue = getProperty(configurationValue, environment); // Use custom boolean editor without allowed empty strings to convert the value of the argument to a boolean value. CustomBooleanEditor customBooleanEditor = new CustomBooleanEditor(false); try { customBooleanEditor.setAsText(booleanStringValue); } catch (IllegalArgumentException e) { logErrorAndThrowIllegalStateException(configurationValue, "boolean", booleanStringValue, e); } // Return the boolean value. return (Boolean) customBooleanEditor.getValue(); }
/** * Gets a property value as a boolean. * * @param configurationValue the boolean configuration value * @param environment the environment containing the property * * @return the boolean property value */ public Boolean getBooleanProperty(ConfigurationValue configurationValue, Environment environment) { String booleanStringValue = getProperty(configurationValue, environment); // Use custom boolean editor without allowed empty strings to convert the value of the argument to a boolean value. CustomBooleanEditor customBooleanEditor = new CustomBooleanEditor(false); try { customBooleanEditor.setAsText(booleanStringValue); } catch (IllegalArgumentException e) { logErrorAndThrowIllegalStateException(configurationValue, "boolean", booleanStringValue, e); } // Return the boolean value. return (Boolean) customBooleanEditor.getValue(); }