1
|
package eu.dnetlib.data.bulktag.selectioncriteria;
|
2
|
|
3
|
import org.reflections.Reflections;
|
4
|
|
5
|
import java.io.Serializable;
|
6
|
import java.lang.reflect.InvocationTargetException;
|
7
|
import java.util.Map;
|
8
|
import java.util.stream.Collectors;
|
9
|
|
10
|
public class VerbResolver implements Serializable {
|
11
|
private final Map<String, Class<Selection>> map;
|
12
|
|
13
|
public VerbResolver(){
|
14
|
this.map = new Reflections("eu.dnetlib").getTypesAnnotatedWith(VerbClass.class).stream()
|
15
|
.collect(Collectors.toMap(v -> v.getAnnotation(VerbClass.class).value(), v->(Class<Selection>)v));
|
16
|
}
|
17
|
|
18
|
|
19
|
public Selection getSelectionCriteria(String name, String param) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
20
|
|
21
|
return map.get(name).getDeclaredConstructor((String.class)).newInstance(param);
|
22
|
|
23
|
}
|
24
|
}
|
25
|
|