@Test public void defaultValueIsUsedWhenPropertyIsNotDefined() throws ComponentLookupException { Assert.assertEquals("right", this.mocker.getComponentUnderTest().getProperty("not.defined", "right")); Assert.assertNull(this.mocker.getComponentUnderTest().getProperty("not.defined", (String) null)); }
@SuppressWarnings("unchecked") @Override public <T> T getProperty(String key, T defaultValue) { String property = this.properties.getProperty(key); if (property == null) { return defaultValue; } if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } }
LegacyXWikiConfigurationSource implements ConfigurationSource, Initializable { @SuppressWarnings("unchecked") @Override public <T> T getProperty(String key, T defaultValue) { String property = this.properties.getProperty(key); if (property == null) { return defaultValue; } if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } } }
LegacyXWikiConfigurationSource implements ConfigurationSource, Initializable { @SuppressWarnings("unchecked") @Override public <T> T getProperty(String key, T defaultValue) { String property = this.properties.getProperty(key); if (property == null) { return defaultValue; } if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } }  }
LegacyXWikiConfigurationSource implements ConfigurationSource, Initializable { @SuppressWarnings("unchecked") @Override public <T> T getProperty(String key, T defaultValue) { String property = this.properties.getProperty(key); if (property == null) { return defaultValue; } if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } }  @Override void initialize(); @SuppressWarnings("unchecked") @Override T getProperty(String key, T defaultValue); @SuppressWarnings("unchecked") @Override T getProperty(String key, Class<T> valueClass); @SuppressWarnings("unchecked") @Override T getProperty(String key); @Override List<String> getKeys(); @Override boolean containsKey(String key); @Override boolean isEmpty(); }
LegacyXWikiConfigurationSource implements ConfigurationSource, Initializable { @SuppressWarnings("unchecked") @Override public <T> T getProperty(String key, T defaultValue) { String property = this.properties.getProperty(key); if (property == null) { return defaultValue; } if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } }  @Override void initialize(); @SuppressWarnings("unchecked") @Override T getProperty(String key, T defaultValue); @SuppressWarnings("unchecked") @Override T getProperty(String key, Class<T> valueClass); @SuppressWarnings("unchecked") @Override T getProperty(String key); @Override List<String> getKeys(); @Override boolean containsKey(String key); @Override boolean isEmpty();  }