@Test public void fromFileAndClasspath() { DefinitionFinder definitionFinder = new DefinitionFinder(of(new File("src/test/resources/definitions"))); Properties find = definitionFinder.find("test"); assertThat(find).hasSize(4).includes( entry("rezenerator.val.mdpi", "42"), entry("rezenerator.def.hdpi", "xxhdpi.divide(2)"), entry("rezenerator.def.xhdpi", "mdpi.multiply(2)"), entry("rezenerator.def.xxhdpi", "mdpi.multiply(3)")); }
public Properties find(String definitionName) { String fileName = definitionName + ".properties"; for (File dir : searchedDirs) { File file = FileUtils.getFile(dir, fileName); if (file.exists()) { return loadFromFile(file, new Properties()); } } Properties loadFromClasspath = loadFromClasspath(fileName); if (loadFromClasspath != null) { return loadFromClasspath; } throw new IllegalArgumentException("Could not find definition " + definitionName); }
DefinitionFinder { public Properties find(String definitionName) { String fileName = definitionName + ".properties"; for (File dir : searchedDirs) { File file = FileUtils.getFile(dir, fileName); if (file.exists()) { return loadFromFile(file, new Properties()); } } Properties loadFromClasspath = loadFromClasspath(fileName); if (loadFromClasspath != null) { return loadFromClasspath; } throw new IllegalArgumentException("Could not find definition " + definitionName); } }
DefinitionFinder { public Properties find(String definitionName) { String fileName = definitionName + ".properties"; for (File dir : searchedDirs) { File file = FileUtils.getFile(dir, fileName); if (file.exists()) { return loadFromFile(file, new Properties()); } } Properties loadFromClasspath = loadFromClasspath(fileName); if (loadFromClasspath != null) { return loadFromClasspath; } throw new IllegalArgumentException("Could not find definition " + definitionName); } DefinitionFinder(List<File> searchedDirs); }
DefinitionFinder { public Properties find(String definitionName) { String fileName = definitionName + ".properties"; for (File dir : searchedDirs) { File file = FileUtils.getFile(dir, fileName); if (file.exists()) { return loadFromFile(file, new Properties()); } } Properties loadFromClasspath = loadFromClasspath(fileName); if (loadFromClasspath != null) { return loadFromClasspath; } throw new IllegalArgumentException("Could not find definition " + definitionName); } DefinitionFinder(List<File> searchedDirs); Properties find(String definitionName); }
DefinitionFinder { public Properties find(String definitionName) { String fileName = definitionName + ".properties"; for (File dir : searchedDirs) { File file = FileUtils.getFile(dir, fileName); if (file.exists()) { return loadFromFile(file, new Properties()); } } Properties loadFromClasspath = loadFromClasspath(fileName); if (loadFromClasspath != null) { return loadFromClasspath; } throw new IllegalArgumentException("Could not find definition " + definitionName); } DefinitionFinder(List<File> searchedDirs); Properties find(String definitionName);  }