class ResourceHelper {

    public static Stream<String> getResourcesFromDirectory(File directory, Pattern pattern) {
        if (directory == null || directory.listFiles() == null) {
            return Stream.empty();
        }
        return Arrays.stream(directory.listFiles()).flatMap(elem -> {
            if (elem.isDirectory()) {
                return getResourcesFromDirectory(elem, pattern);
            } else {
                try {
                    String fileName = elem.getCanonicalPath();
                    if (pattern.matcher(fileName).matches()) {
                        return Stream.of(fileName);
                    }
                } catch (final IOException e) {
                    throw new ScenarioException("Impossible to access to resources", e);
                }
            }
            return Stream.empty();
        });
    }

    private  ResourceHelper();

}