@Test public void removeKeyPrefix() { Properties properties = new Properties(); properties.put("abcde", "abcde"); properties.put("abc0", "abc0"); properties.put("abc", "abc"); properties.put("ab", "ab"); properties.put("abbde", "abbde"); properties.put("abd", "abd"); properties.put("bcdef", "bcdef"); char[] array = "abc[]".toCharArray(); properties.put(array, "abc[]"); properties.put("abc[]", array); Properties answer = new Properties(); answer.put("ab", "ab"); answer.put("abbde", "abbde"); answer.put("abd", "abd"); answer.put("bcdef", "bcdef"); answer.put(array, "abc[]"); PropertiesUtil.removeKeyPrefix(properties, "abc"); assertThat(properties, is(answer)); }
public static void removeKeyPrefix(Properties properties, String prefix) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (prefix == null) { throw new IllegalArgumentException("prefix must not be null"); } for (Iterator<?> iter = properties.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); if ((key instanceof String) == false) { continue; } String name = (String) key; if (name.startsWith(prefix)) { iter.remove(); } } }
PropertiesUtil { public static void removeKeyPrefix(Properties properties, String prefix) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (prefix == null) { throw new IllegalArgumentException("prefix must not be null"); } for (Iterator<?> iter = properties.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); if ((key instanceof String) == false) { continue; } String name = (String) key; if (name.startsWith(prefix)) { iter.remove(); } } } }
PropertiesUtil { public static void removeKeyPrefix(Properties properties, String prefix) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (prefix == null) { throw new IllegalArgumentException("prefix must not be null"); } for (Iterator<?> iter = properties.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); if ((key instanceof String) == false) { continue; } String name = (String) key; if (name.startsWith(prefix)) { iter.remove(); } } } private  PropertiesUtil(); }
PropertiesUtil { public static void removeKeyPrefix(Properties properties, String prefix) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (prefix == null) { throw new IllegalArgumentException("prefix must not be null"); } for (Iterator<?> iter = properties.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); if ((key instanceof String) == false) { continue; } String name = (String) key; if (name.startsWith(prefix)) { iter.remove(); } } } private  PropertiesUtil(); static void removeKeyPrefix(Properties properties, String prefix); static NavigableMap<String, String> createPrefixMap(Map<?, ?> properties, String prefix); static void checkAbsentKey(Properties properties, String key); static void checkAbsentKeyPrefix(Properties properties, String keyPrefix); }
PropertiesUtil { public static void removeKeyPrefix(Properties properties, String prefix) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (prefix == null) { throw new IllegalArgumentException("prefix must not be null"); } for (Iterator<?> iter = properties.keySet().iterator(); iter.hasNext();) { Object key = iter.next(); if ((key instanceof String) == false) { continue; } String name = (String) key; if (name.startsWith(prefix)) { iter.remove(); } } } private  PropertiesUtil(); static void removeKeyPrefix(Properties properties, String prefix); static NavigableMap<String, String> createPrefixMap(Map<?, ?> properties, String prefix); static void checkAbsentKey(Properties properties, String key); static void checkAbsentKeyPrefix(Properties properties, String keyPrefix);  }