@Test public void getString() { Properties props = new Properties(); props.setProperty("foo", "bar"); Configuration config = Configuration.create(props); assertThat(config.getString("foo")).isEqualTo("bar"); assertThat(config.getString("xxx")).isNull(); assertThat(config.getString("xxx", "default")).isEqualTo("default"); }
public String getString(String key) { if ("sonar.jdbc.dialect".equals(key) && "embedded".equalsIgnoreCase(props.get(key))) { return "h2"; } return props.get(key); }
Configuration { public String getString(String key) { if ("sonar.jdbc.dialect".equals(key) && "embedded".equalsIgnoreCase(props.get(key))) { return "h2"; } return props.get(key); } }
Configuration { public String getString(String key) { if ("sonar.jdbc.dialect".equals(key) && "embedded".equalsIgnoreCase(props.get(key))) { return "h2"; } return props.get(key); } private  Configuration(File homeDir, Map<String, String> props); }
Configuration { public String getString(String key) { if ("sonar.jdbc.dialect".equals(key) && "embedded".equalsIgnoreCase(props.get(key))) { return "h2"; } return props.get(key); } private  Configuration(File homeDir, Map<String, String> props); FileSystem fileSystem(); Locators locators(); FileLocation getFileLocationOfShared(String relativePath); String getString(String key); String getString(String key, @Nullable String defaultValue); @CheckForNull String getStringByKeys(String... keys); @CheckForNull String getStringByKeys(Predicate<String> validator, String... keys); int getInt(String key, int defaultValue); Map<String, String> asMap(); static Configuration createEnv(); static Configuration create(Properties properties); static Configuration create(Map<String, String> properties); static Configuration create(); static Builder builder(); }
Configuration { public String getString(String key) { if ("sonar.jdbc.dialect".equals(key) && "embedded".equalsIgnoreCase(props.get(key))) { return "h2"; } return props.get(key); } private  Configuration(File homeDir, Map<String, String> props); FileSystem fileSystem(); Locators locators(); FileLocation getFileLocationOfShared(String relativePath); String getString(String key); String getString(String key, @Nullable String defaultValue); @CheckForNull String getStringByKeys(String... keys); @CheckForNull String getStringByKeys(Predicate<String> validator, String... keys); int getInt(String key, int defaultValue); Map<String, String> asMap(); static Configuration createEnv(); static Configuration create(Properties properties); static Configuration create(Map<String, String> properties); static Configuration create(); static Builder builder();  }