@Test public void canRestorePrefix() { envVars.set("OUTPUT", "o"); envVars.set("ERROR_OUTPUT", "eo"); IllegalArgumentException thrown = assertThrows(IllegalArgumentException.class, () -> new Env(ImmutableSet.of("OUTPUT"), "ERROR_").requireAllVarsUsed()); assertEquals("Env vars set but not used: [ERROR_OUTPUT]", thrown.getMessage()); }
public void requireAllVarsUsed() { if (!unused.isEmpty()) { throw new IllegalArgumentException("Env vars set but not used: " + unused.stream().map(key -> prefix + key).collect(Collectors.toList()).toString()); } }
Env { public void requireAllVarsUsed() { if (!unused.isEmpty()) { throw new IllegalArgumentException("Env vars set but not used: " + unused.stream().map(key -> prefix + key).collect(Collectors.toList()).toString()); } } }
Env { public void requireAllVarsUsed() { if (!unused.isEmpty()) { throw new IllegalArgumentException("Env vars set but not used: " + unused.stream().map(key -> prefix + key).collect(Collectors.toList()).toString()); } } Env(Set<String> include);  Env(Set<String> include, String prefix); }
Env { public void requireAllVarsUsed() { if (!unused.isEmpty()) { throw new IllegalArgumentException("Env vars set but not used: " + unused.stream().map(key -> prefix + key).collect(Collectors.toList()).toString()); } } 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 void requireAllVarsUsed() { if (!unused.isEmpty()) { throw new IllegalArgumentException("Env vars set but not used: " + unused.stream().map(key -> prefix + key).collect(Collectors.toList()).toString()); } } 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);  }