@Test public void checkAbsentKey() { Properties properties = new Properties(); properties.put("abcde", "abcde"); properties.put("abc0", "abc0"); properties.put("ab", "ab"); properties.put("abd", "ab"); char[] array = "abc".toCharArray(); properties.put(array, "abc"); PropertiesUtil.checkAbsentKey(properties, "abc"); try { properties.put("abc", "abc"); PropertiesUtil.checkAbsentKey(properties, "abc"); fail(); } catch (IllegalArgumentException e) { } }
public static void checkAbsentKey(Properties properties, String key) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (key == null) { throw new IllegalArgumentException("key must not be null"); } if (properties.containsKey(key)) { throw new IllegalArgumentException(MessageFormat.format( "Target properties already contain \"{0}\"", key)); } }
PropertiesUtil { public static void checkAbsentKey(Properties properties, String key) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (key == null) { throw new IllegalArgumentException("key must not be null"); } if (properties.containsKey(key)) { throw new IllegalArgumentException(MessageFormat.format( "Target properties already contain \"{0}\"", key)); } } }
PropertiesUtil { public static void checkAbsentKey(Properties properties, String key) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (key == null) { throw new IllegalArgumentException("key must not be null"); } if (properties.containsKey(key)) { throw new IllegalArgumentException(MessageFormat.format( "Target properties already contain \"{0}\"", key)); } } private  PropertiesUtil(); }
PropertiesUtil { public static void checkAbsentKey(Properties properties, String key) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (key == null) { throw new IllegalArgumentException("key must not be null"); } if (properties.containsKey(key)) { throw new IllegalArgumentException(MessageFormat.format( "Target properties already contain \"{0}\"", key)); } } 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 checkAbsentKey(Properties properties, String key) { if (properties == null) { throw new IllegalArgumentException("properties must not be null"); } if (key == null) { throw new IllegalArgumentException("key must not be null"); } if (properties.containsKey(key)) { throw new IllegalArgumentException(MessageFormat.format( "Target properties already contain \"{0}\"", key)); } } 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);  }