Question: Migration 0.9.x to 0.10.x Resource scanner
Hi,
I currently can't manage to migrate my 0.9.x code to 0.10.x:
# 0.9.x code
String location = "test.";
Collection<URL> urls = ClasspathHelper.forPackage(location);
Reflections reflections = new Reflections(new ConfigurationBuilder()
.setScanners(new ResourcesScanner())
.filterInputsBy(new FilterBuilder().includePackage(location))
.setUrls(urls));
Set<String> resources = reflections.getResources(this::isValidFilename);
private boolean isValidFilename(String fileName) {
return hasValidSuffix(fileName)
&& fileName.startsWith(this.prefix);
}
private boolean hasValidSuffix(String fileName) {
return this.suffixes
.stream()
.anyMatch(suffix -> fileName.toLowerCase().endsWith(suffix.toLowerCase()));
}
I tried a lot different options in 0.10.x but nothing worked like in 0.9.x and creating a regexp pattern matching my isValidFilename logic would be really complex. Isn't there any option to do something like reflections.getResources(<predicate>) which was possible in 0.9.x?
Thanks for your help
Nobody any hint or suggestion how to do this?
I also do not see any easy way to do that here. I guess you need to choose two steps:
- Getting all files with file prefix
- Post process this list of files with isValidFilename method.
Otherwise did you try to go over reflections.get method with following signature?
>public <T> Set<T> get(QueryFunction<Store, T> query)
这是来自QQ邮箱的自动回复邮件。 您好,我已经收到您的邮件