@Test public void throwsMissingRequired() { IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> new Env(ImmutableSet.of("OUTPUT")).getString("OUTPUT")); assertEquals("Missing required env var: OUTPUT", thrown.getMessage()); }
public String getString(String key) { return optString(key) .orElseThrow(() -> new IllegalArgumentException("Missing required env var: " + key)); }
Env { public String getString(String key) { return optString(key) .orElseThrow(() -> new IllegalArgumentException("Missing required env var: " + key)); } }
Env { public String getString(String key) { return optString(key) .orElseThrow(() -> new IllegalArgumentException("Missing required env var: " + key)); } Env(Set<String> include);  Env(Set<String> include, String prefix); }
Env { public String getString(String key) { return optString(key) .orElseThrow(() -> new IllegalArgumentException("Missing required env var: " + key)); } Env(Set<String> include);  Env(Set<String> include, String prefix); void requireAllVarsUsed(); boolean isEmpty(); boolean containsKey(String key); Optional<String> optString(String key); String getString(String key); String getString(String key, String defaultValue); List<String> getStrings(String key, List<String> defaultValue); Integer getInt(String key, Integer defaultValue); Long getLong(String key, Long defaultValue); Duration getDuration(String key, String defaultValue); Pattern getPattern(String key); }
Env { public String getString(String key) { return optString(key) .orElseThrow(() -> new IllegalArgumentException("Missing required env var: " + key)); } Env(Set<String> include);  Env(Set<String> include, String prefix); void requireAllVarsUsed(); boolean isEmpty(); boolean containsKey(String key); Optional<String> optString(String key); String getString(String key); String getString(String key, String defaultValue); List<String> getStrings(String key, List<String> defaultValue); Integer getInt(String key, Integer defaultValue); Long getLong(String key, Long defaultValue); Duration getDuration(String key, String defaultValue); Pattern getPattern(String key);  }