Skip to content

Instantly share code, notes, and snippets.

@wsoczynski
Last active December 15, 2015 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wsoczynski/5236723 to your computer and use it in GitHub Desktop.
Save wsoczynski/5236723 to your computer and use it in GitHub Desktop.
class HierarchyAwareResourceLoader {
private final List<String> searchPaths;
public HierarchyAwareResourceLoader(List<String> searchPaths){
this.searchPaths = searchPaths;
}
public Optional<File> load(String name){
Optional<File> result = FluentIterable.from(searchPaths).
transform(ConcatPath.with(name)).
transform(File.createFromPath()).
filter(File.ifExists()).
first();
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment