@Test void testStringPropertyWhenConversionError() { this.configuration.setProperty("string", "value"); Exception exception = assertThrows(ConversionException.class, () -> this.source.getProperty("string", Boolean.class)); assertEquals("Key [string] is not compatible with type [java.lang.Boolean]", exception.getMessage()); }
@Override @SuppressWarnings("unchecked") public <T> T getProperty(String key, T defaultValue) { T result; if (containsKey(key)) { if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } } else { result = defaultValue; } return result; }
CommonsConfigurationSource implements ConfigurationSource { @Override @SuppressWarnings("unchecked") public <T> T getProperty(String key, T defaultValue) { T result; if (containsKey(key)) { if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } } else { result = defaultValue; } return result; } }
CommonsConfigurationSource implements ConfigurationSource { @Override @SuppressWarnings("unchecked") public <T> T getProperty(String key, T defaultValue) { T result; if (containsKey(key)) { if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } } else { result = defaultValue; } return result; }  }
CommonsConfigurationSource implements ConfigurationSource { @Override @SuppressWarnings("unchecked") public <T> T getProperty(String key, T defaultValue) { T result; if (containsKey(key)) { if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } } else { result = defaultValue; } return result; }  @Override @SuppressWarnings("unchecked") T getProperty(String key, T defaultValue); @Override @SuppressWarnings("unchecked") T getProperty(String key); @Override @SuppressWarnings("unchecked") T getProperty(String key, Class<T> valueClass); @Override List<String> getKeys(); @Override boolean containsKey(String key); @Override boolean isEmpty(); }
CommonsConfigurationSource implements ConfigurationSource { @Override @SuppressWarnings("unchecked") public <T> T getProperty(String key, T defaultValue) { T result; if (containsKey(key)) { if (defaultValue != null) { return getProperty(key, (Class<T>) defaultValue.getClass()); } else { return getProperty(key); } } else { result = defaultValue; } return result; }  @Override @SuppressWarnings("unchecked") T getProperty(String key, T defaultValue); @Override @SuppressWarnings("unchecked") T getProperty(String key); @Override @SuppressWarnings("unchecked") T getProperty(String key, Class<T> valueClass); @Override List<String> getKeys(); @Override boolean containsKey(String key); @Override boolean isEmpty();  }