use of datawave.query.function.DocumentPermutation in project datawave by NationalSecurityAgency.
the class QueryOptions method getDocumentPermutations.
public List<DocumentPermutation> getDocumentPermutations() {
if (documentPermutations == null) {
List<DocumentPermutation> list = new ArrayList<>();
TypeMetadata metadata = getTypeMetadata();
for (String classname : getDocumentPermutationClasses()) {
try {
Class<DocumentPermutation> clazz = (Class<DocumentPermutation>) Class.forName(classname);
try {
Constructor<DocumentPermutation> constructor = clazz.getConstructor(TypeMetadata.class);
list.add(constructor.newInstance(metadata));
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
log.error("Unable to construct " + classname + " as a DocumentPermutation", e);
throw new IllegalArgumentException("Unable to construct " + classname + " as a DocumentPermutation", e);
} catch (NoSuchMethodException e) {
try {
list.add(clazz.newInstance());
} catch (InstantiationException | IllegalAccessException e2) {
log.error("Unable to construct " + classname + " as a DocumentPermutation", e2);
throw new IllegalArgumentException("Unable to construct " + classname + " as a DocumentPermutation", e2);
}
}
} catch (ClassNotFoundException e) {
log.error("Unable to construct " + classname + " as a DocumentPermutation", e);
throw new IllegalArgumentException("Unable to construct " + classname + " as a DocumentPermutation", e);
}
}
this.documentPermutations = list;
}
return this.documentPermutations;
}
Aggregations