SystemProperties { public static void overrideForSuffix(String suffix, Properties p) { for (Entry<Object, Object> e : Copy.list(p.entrySet())) { String key = (String) e.getKey(); if (key.endsWith("." + suffix)) { String actualKey = key.substring(0, key.length() - ("." + suffix).length()); p.setProperty(actualKey, (String) e.getValue()); } } }  static void loadFromFileIfExists(String path); static void loadFromClasspath(String path); static void overrideForSuffix(String suffix, Properties p);  }
@Test public void testOverride() { Properties p = new Properties(); p.setProperty("foo", "a"); p.setProperty("foo.dev", "b"); SystemProperties.overrideForSuffix("dev", p); Assert.assertEquals("b", p.getProperty("foo")); }
@Test public void testOverrideIsNullSafe() { Properties p = new Properties(); p.setProperty("foo", "a"); p.setProperty("foo.dev", "b"); p.setProperty("foo.", "b"); SystemProperties.overrideForSuffix(null, p); Assert.assertEquals("a", p.getProperty("foo")); }