@Test(dataProvider = "getAsGroup") public void testGetAsGroup(Pattern pattern, Class<?> valueClass, Map<String, ?> expected) throws Exception { Map<String, ?> actual = this.pc.getAsGroup(pattern, valueClass); Assert.assertEquals(actual, expected); }
@SuppressWarnings("unchecked") public <T> Map<String, T> getAsGroup(Pattern pattern, Class<T> valueClass) throws ClassNotFoundException { Map<String, T> ret = new HashMap<String, T>(); for (String key : this.properties.stringPropertyNames()) { Matcher matcher = pattern.matcher(key); if (matcher.matches()) { Object value = null; if (valueClass == String.class) { value = get(key); } else if (valueClass == Boolean.class) { value = getBoolean(key); } else if (valueClass == Integer.class) { value = getInteger(key); } else if (valueClass == Long.class) { value = getLong(key); } else if (valueClass == Float.class) { value = getFloat(key); } else if (valueClass == Double.class) { value = getDouble(key); } else if (valueClass == File.class) { value = getFile(key); } else if (valueClass == URL.class) { value = getUrl(key); } else if (valueClass == Class.class) { value = getClass(key); } else { throw new IllegalArgumentException("value class of " + valueClass + " is not supported."); } ret.put(matcher.group(1), (T) value); } } return ret; }
PropertiesConfiguration implements PropertiesBean { @SuppressWarnings("unchecked") public <T> Map<String, T> getAsGroup(Pattern pattern, Class<T> valueClass) throws ClassNotFoundException { Map<String, T> ret = new HashMap<String, T>(); for (String key : this.properties.stringPropertyNames()) { Matcher matcher = pattern.matcher(key); if (matcher.matches()) { Object value = null; if (valueClass == String.class) { value = get(key); } else if (valueClass == Boolean.class) { value = getBoolean(key); } else if (valueClass == Integer.class) { value = getInteger(key); } else if (valueClass == Long.class) { value = getLong(key); } else if (valueClass == Float.class) { value = getFloat(key); } else if (valueClass == Double.class) { value = getDouble(key); } else if (valueClass == File.class) { value = getFile(key); } else if (valueClass == URL.class) { value = getUrl(key); } else if (valueClass == Class.class) { value = getClass(key); } else { throw new IllegalArgumentException("value class of " + valueClass + " is not supported."); } ret.put(matcher.group(1), (T) value); } } return ret; } }
PropertiesConfiguration implements PropertiesBean { @SuppressWarnings("unchecked") public <T> Map<String, T> getAsGroup(Pattern pattern, Class<T> valueClass) throws ClassNotFoundException { Map<String, T> ret = new HashMap<String, T>(); for (String key : this.properties.stringPropertyNames()) { Matcher matcher = pattern.matcher(key); if (matcher.matches()) { Object value = null; if (valueClass == String.class) { value = get(key); } else if (valueClass == Boolean.class) { value = getBoolean(key); } else if (valueClass == Integer.class) { value = getInteger(key); } else if (valueClass == Long.class) { value = getLong(key); } else if (valueClass == Float.class) { value = getFloat(key); } else if (valueClass == Double.class) { value = getDouble(key); } else if (valueClass == File.class) { value = getFile(key); } else if (valueClass == URL.class) { value = getUrl(key); } else if (valueClass == Class.class) { value = getClass(key); } else { throw new IllegalArgumentException("value class of " + valueClass + " is not supported."); } ret.put(matcher.group(1), (T) value); } } return ret; } PropertiesConfiguration(Properties properties); }
PropertiesConfiguration implements PropertiesBean { @SuppressWarnings("unchecked") public <T> Map<String, T> getAsGroup(Pattern pattern, Class<T> valueClass) throws ClassNotFoundException { Map<String, T> ret = new HashMap<String, T>(); for (String key : this.properties.stringPropertyNames()) { Matcher matcher = pattern.matcher(key); if (matcher.matches()) { Object value = null; if (valueClass == String.class) { value = get(key); } else if (valueClass == Boolean.class) { value = getBoolean(key); } else if (valueClass == Integer.class) { value = getInteger(key); } else if (valueClass == Long.class) { value = getLong(key); } else if (valueClass == Float.class) { value = getFloat(key); } else if (valueClass == Double.class) { value = getDouble(key); } else if (valueClass == File.class) { value = getFile(key); } else if (valueClass == URL.class) { value = getUrl(key); } else if (valueClass == Class.class) { value = getClass(key); } else { throw new IllegalArgumentException("value class of " + valueClass + " is not supported."); } ret.put(matcher.group(1), (T) value); } } return ret; } PropertiesConfiguration(Properties properties); @SuppressWarnings("unchecked") Map<String, T> getAsGroup(Pattern pattern, Class<T> valueClass); String get(String key); String get(String key, String defaultValue); Boolean getBoolean(String key, Boolean defaultValue); Boolean getBoolean(String key); Integer getInteger(String key, Integer defaultValue); Integer getInteger(String key); Long getLong(String key, Long defaultValue); Long getLong(String key); Float getFloat(String key, Float defaultValue); Float getFloat(String key); Double getDouble(String key, Double defaultValue); Double getDouble(String key); URL getUrl(String key, URL defaultValue); URL getUrl(String key); File getFile(String key, File defaultValue); File getFile(String key); @SuppressWarnings("unchecked") Class<? extends T> getClass(String key, Class<? extends T> defaultValue); Class<?> getClass(String key); Properties getProperties(); }
PropertiesConfiguration implements PropertiesBean { @SuppressWarnings("unchecked") public <T> Map<String, T> getAsGroup(Pattern pattern, Class<T> valueClass) throws ClassNotFoundException { Map<String, T> ret = new HashMap<String, T>(); for (String key : this.properties.stringPropertyNames()) { Matcher matcher = pattern.matcher(key); if (matcher.matches()) { Object value = null; if (valueClass == String.class) { value = get(key); } else if (valueClass == Boolean.class) { value = getBoolean(key); } else if (valueClass == Integer.class) { value = getInteger(key); } else if (valueClass == Long.class) { value = getLong(key); } else if (valueClass == Float.class) { value = getFloat(key); } else if (valueClass == Double.class) { value = getDouble(key); } else if (valueClass == File.class) { value = getFile(key); } else if (valueClass == URL.class) { value = getUrl(key); } else if (valueClass == Class.class) { value = getClass(key); } else { throw new IllegalArgumentException("value class of " + valueClass + " is not supported."); } ret.put(matcher.group(1), (T) value); } } return ret; } PropertiesConfiguration(Properties properties); @SuppressWarnings("unchecked") Map<String, T> getAsGroup(Pattern pattern, Class<T> valueClass); String get(String key); String get(String key, String defaultValue); Boolean getBoolean(String key, Boolean defaultValue); Boolean getBoolean(String key); Integer getInteger(String key, Integer defaultValue); Integer getInteger(String key); Long getLong(String key, Long defaultValue); Long getLong(String key); Float getFloat(String key, Float defaultValue); Float getFloat(String key); Double getDouble(String key, Double defaultValue); Double getDouble(String key); URL getUrl(String key, URL defaultValue); URL getUrl(String key); File getFile(String key, File defaultValue); File getFile(String key); @SuppressWarnings("unchecked") Class<? extends T> getClass(String key, Class<? extends T> defaultValue); Class<?> getClass(String key); Properties getProperties();  }