@Test public void testSubset() { PropertiesFile propertiesFile= new PropertiesFile(FILE); PropertiesFile subset = propertiesFile.subset("mapping"); assertEquals(5, subset.getProperties().size()); }
public PropertiesFile subset(String keyPrefix) { PropertiesFile subset= new PropertiesFile(); subset.props= Maps.newLinkedHashMap(); subset.allowInLineComments= allowInLineComments; for (Map.Entry<String, String> e: props.entrySet()) { String k= e.getKey(); if (startsWith(k, keyPrefix)) subset.props.put(k, e.getValue()); } return subset; }
PropertiesFile { public PropertiesFile subset(String keyPrefix) { PropertiesFile subset= new PropertiesFile(); subset.props= Maps.newLinkedHashMap(); subset.allowInLineComments= allowInLineComments; for (Map.Entry<String, String> e: props.entrySet()) { String k= e.getKey(); if (startsWith(k, keyPrefix)) subset.props.put(k, e.getValue()); } return subset; } }
PropertiesFile { public PropertiesFile subset(String keyPrefix) { PropertiesFile subset= new PropertiesFile(); subset.props= Maps.newLinkedHashMap(); subset.allowInLineComments= allowInLineComments; for (Map.Entry<String, String> e: props.entrySet()) { String k= e.getKey(); if (startsWith(k, keyPrefix)) subset.props.put(k, e.getValue()); } return subset; } private  PropertiesFile();  PropertiesFile(String fileName, boolean allowInLineComments);  PropertiesFile(String fileName); }
PropertiesFile { public PropertiesFile subset(String keyPrefix) { PropertiesFile subset= new PropertiesFile(); subset.props= Maps.newLinkedHashMap(); subset.allowInLineComments= allowInLineComments; for (Map.Entry<String, String> e: props.entrySet()) { String k= e.getKey(); if (startsWith(k, keyPrefix)) subset.props.put(k, e.getValue()); } return subset; } private  PropertiesFile();  PropertiesFile(String fileName, boolean allowInLineComments);  PropertiesFile(String fileName); static Map<String, String> read(String fileName); Map<String, String> getProperties(); String getString(String key); Integer getInteger(String key); Long getLong(String key); Boolean getBoolean(String key); PropertiesFile subset(String keyPrefix); Set<String> keys(); }
PropertiesFile { public PropertiesFile subset(String keyPrefix) { PropertiesFile subset= new PropertiesFile(); subset.props= Maps.newLinkedHashMap(); subset.allowInLineComments= allowInLineComments; for (Map.Entry<String, String> e: props.entrySet()) { String k= e.getKey(); if (startsWith(k, keyPrefix)) subset.props.put(k, e.getValue()); } return subset; } private  PropertiesFile();  PropertiesFile(String fileName, boolean allowInLineComments);  PropertiesFile(String fileName); static Map<String, String> read(String fileName); Map<String, String> getProperties(); String getString(String key); Integer getInteger(String key); Long getLong(String key); Boolean getBoolean(String key); PropertiesFile subset(String keyPrefix); Set<String> keys();  }