1
0
Fork 0
This commit is contained in:
Miriam Baglioni 2020-04-21 18:00:53 +02:00
parent 676ba49324
commit 30e53261d0
1 changed files with 14 additions and 10 deletions

View File

@ -1,25 +1,29 @@
package eu.dnetlib.dhp.selectioncriteria;
import org.reflections.Reflections;
import java.io.Serializable;
import java.lang.reflect.InvocationTargetException;
import java.util.Map;
import java.util.stream.Collectors;
import org.reflections.Reflections;
public class VerbResolver implements Serializable {
private final Map<String, Class<Selection>> map;
public VerbResolver(){
this.map = new Reflections("eu.dnetlib").getTypesAnnotatedWith(VerbClass.class).stream()
.collect(Collectors.toMap(v -> v.getAnnotation(VerbClass.class).value(), v->(Class<Selection>)v));
public VerbResolver() {
this.map =
new Reflections("eu.dnetlib")
.getTypesAnnotatedWith(VerbClass.class).stream()
.collect(
Collectors.toMap(
v -> v.getAnnotation(VerbClass.class).value(),
v -> (Class<Selection>) v));
}
public Selection getSelectionCriteria(String name, String param) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
public Selection getSelectionCriteria(String name, String param)
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
InstantiationException {
return map.get(name).getDeclaredConstructor((String.class)).newInstance(param);
}
}
}