Пример #1
0
  public static int getIntegerProperty(
      final String propertyName, final int defaultValue, final PropertyFileLoader fileLoader) {
    final String value = fileLoader.getProperty(propertyName);
    Integer returnValue = defaultValue;

    try {
      returnValue = Integer.valueOf(value);
    } catch (NumberFormatException e) {
      logger.error("Invalid number format " + value);
    }

    fileLoader.setProperty(propertyName, String.valueOf(returnValue));
    return returnValue;
  }
Пример #2
0
  public static boolean getBooleanProperty(
      final String propertyName, final boolean defaultValue, final PropertyFileLoader fileLoader) {
    final String value = fileLoader.getProperty(propertyName);
    Boolean returnValue = defaultValue;

    // Default, when non present is X
    if (value == null || value.isEmpty()) {
      returnValue = defaultValue;
    } else {
      try {
        returnValue = Boolean.valueOf(value);
      } catch (IllegalArgumentException e) {
        logger.error("Invalid format " + value);
      }
    }

    fileLoader.setProperty(propertyName, String.valueOf(returnValue));
    return returnValue;
  }