forked from D-Net/dnet-hadoop
minor
This commit is contained in:
parent
676ba49324
commit
30e53261d0
|
@ -1,25 +1,29 @@
|
||||||
package eu.dnetlib.dhp.selectioncriteria;
|
package eu.dnetlib.dhp.selectioncriteria;
|
||||||
|
|
||||||
|
|
||||||
import org.reflections.Reflections;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
import org.reflections.Reflections;
|
||||||
|
|
||||||
public class VerbResolver implements Serializable {
|
public class VerbResolver implements Serializable {
|
||||||
private final Map<String, Class<Selection>> map;
|
private final Map<String, Class<Selection>> map;
|
||||||
|
|
||||||
public VerbResolver() {
|
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));
|
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)
|
||||||
public Selection getSelectionCriteria(String name, String param) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
|
throws NoSuchMethodException, IllegalAccessException, InvocationTargetException,
|
||||||
|
InstantiationException {
|
||||||
|
|
||||||
return map.get(name).getDeclaredConstructor((String.class)).newInstance(param);
|
return map.get(name).getDeclaredConstructor((String.class)).newInstance(param);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue