@Override public Optional<String> getString(String elementKey) { ConfigElement element = elements.get(elementKey); if (element == null || isNullOrEmpty(element.getValue())) { return Optional.absent(); } return Optional.of(element.getValue()); }
@Override public Optional<Boolean> getBoolean(String elementKey) { ConfigElement element = elements.get(elementKey); if (element == null || isNullOrEmpty(element.getValue())) { return Optional.absent(); } return Optional.of(TRUE_VALUES.contains(element.getValue().toLowerCase(Locale.ENGLISH))); }
@Override public Optional<Integer> getInt(String elementKey) { ConfigElement element = elements.get(elementKey); if (element == null || isNullOrEmpty(element.getValue())) { return Optional.absent(); } try { return Optional.of(Integer.parseInt(element.getValue())); } catch (NumberFormatException e) { throw new RuntimeException( "can't access " + element + " as int" + " (parse exception " + e.getMessage() + ")"); } }