use of org.talend.sdk.component.api.processor.Output in project component-runtime by Talend.
the class ModelVisitor method validateProcessor.
private void validateProcessor(final Class<?> input) {
final List<Method> producers = Stream.of(input.getMethods()).filter(m -> m.isAnnotationPresent(ElementListener.class)).collect(toList());
if (producers.size() != 1) {
throw new IllegalArgumentException(input + " must have a single @ElementListener method");
}
if (Stream.of(producers.get(0).getParameters()).filter(p -> {
if (p.isAnnotationPresent(Output.class)) {
if (!ParameterizedType.class.isInstance(p.getParameterizedType())) {
throw new IllegalArgumentException("@Output parameter must be of type OutputEmitter");
}
final ParameterizedType pt = ParameterizedType.class.cast(p.getParameterizedType());
if (OutputEmitter.class != pt.getRawType()) {
throw new IllegalArgumentException("@Output parameter must be of type OutputEmitter");
}
return false;
}
return true;
}).count() < 1) {
throw new IllegalArgumentException(input + " doesn't have the input parameter on its producer method");
}
Stream.of(input.getMethods()).filter(m -> m.isAnnotationPresent(BeforeGroup.class) || m.isAnnotationPresent(AfterGroup.class)).forEach(m -> {
if (m.getParameterCount() > 0) {
throw new IllegalArgumentException(m + " must not have any parameter");
}
});
}
Aggregations