Exemple #1
0
 @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());
 }
Exemple #2
0
 @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)));
 }
Exemple #3
0
 @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() + ")");
   }
 }