Search in sources :

Example 1 with ReaderPriority

use of com.devonfw.cobigen.api.annotation.ReaderPriority in project cobigen by devonfw.

the class PluginRegistry method getPriority.

/**
 * Extracts the {@link ReaderPriority} of a trigger interpreter
 *
 * @param clazz class to get the {@link ReaderPriority} annotation from (commonly the TriggerInterpreter classes)
 * @return the priority of the input reader
 */
private static Priority getPriority(Class<? extends TriggerInterpreter> clazz) {
    Priority priority;
    if (clazz.getClass().isAnnotationPresent(ReaderPriority.class)) {
        ReaderPriority[] annotation = clazz.getClass().getAnnotationsByType(ReaderPriority.class);
        priority = annotation[0].value();
    } else {
        try {
            priority = (Priority) ReaderPriority.class.getMethod("value").getDefaultValue();
        } catch (NoSuchMethodException | SecurityException e) {
            LOG.error("Could not find value() method of ReaderPriority. This should be an invalid case. Setting priority to hardcoded LOW to proceed. Please anyhow report a bug please.");
            priority = Priority.LOW;
        }
    }
    return priority;
}
Also used : ReaderPriority(com.devonfw.cobigen.api.annotation.ReaderPriority) ReaderPriority(com.devonfw.cobigen.api.annotation.ReaderPriority) Priority(com.devonfw.cobigen.api.extension.Priority)

Aggregations

ReaderPriority (com.devonfw.cobigen.api.annotation.ReaderPriority)1 Priority (com.devonfw.cobigen.api.extension.Priority)1