Search in sources :

Example 1 with DocumentPermutation

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;
}
Also used : TypeMetadata(datawave.query.util.TypeMetadata) ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) DocumentPermutation(datawave.query.function.DocumentPermutation)

Aggregations

DocumentPermutation (datawave.query.function.DocumentPermutation)1 TypeMetadata (datawave.query.util.TypeMetadata)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1