public Set<SystemProperty> parseProperties(String fileName) { Set<SystemProperty> result = new HashSet<>(); File file = new File(fileName); Extension.validatePropertiesFileExtension(file.getName()); SlangSource source = SlangSource.fromFile(new File(fileName)); result.addAll(slang.loadSystemProperties(source)); return result; } }
private Set<SystemProperty> loadPropertiesFromFiles(List<File> files, String[] extensions, String directory) { Collection<File> fileCollection; if (CollectionUtils.isEmpty(files)) { fileCollection = loadDefaultFiles(extensions, directory, true); if (CollectionUtils.isEmpty(fileCollection)) { return new HashSet<>(); } } else { fileCollection = files; for (File propertyFileCandidate : fileCollection) { Extension.validatePropertiesFileExtension(propertyFileCandidate.getName()); } } Map<File, Set<SystemProperty>> loadedProperties = new HashMap<>(); for (File propFile : fileCollection) { try { SlangSource source = SlangSource.fromFile(propFile); logger.info("Loading file: " + propFile); Set<SystemProperty> propsFromFile = slang.loadSystemProperties(source); mergeSystemProperties(loadedProperties, propsFromFile, propFile); } catch (Throwable ex) { String errorMessage = "Error loading file: " + propFile + " nested exception is " + ex.getMessage(); logger.error(errorMessage, ex); throw new RuntimeException(errorMessage, ex); } } return SetUtils.mergeSets(loadedProperties.values()); }