assert operatorClass != null;
assert methodName != null;
assert portKind != null;
assert portName != null;
Class<?> factoryClass = findFactoryClass(operatorClass);
OperatorFactory factory = factoryClass.getAnnotation(OperatorFactory.class);
assert factory != null;
Method factoryMethod = findFactoryMethod(factoryClass, methodName);
OperatorInfo info = factoryMethod.getAnnotation(OperatorInfo.class);
assert info != null;
if (portKind == PortKind.INPUT) {
boolean found = false;
for (OperatorInfo.Input port : info.input()) {
if (port.name().equals(portName)) {
found = true;
break;
}
}
if (found == false) {
List<String> list = new ArrayList<String>();
for (OperatorInfo.Input port : info.input()) {
list.add(port.name());
}
throw new RewriteException(MessageFormat.format(
Messages.getString("TracepointWeaveRewriter.errorUnknownInputPort"), //$NON-NLS-1$
factoryClass.getName(),
factoryMethod.getName(),
portName,
list));
}
} else {
boolean found = false;
for (OperatorInfo.Output port : info.output()) {
if (port.name().equals(portName)) {
found = true;
break;
}
}
if (found == false) {
List<String> list = new ArrayList<String>();
for (OperatorInfo.Output port : info.output()) {
list.add(port.name());
}
throw new RewriteException(MessageFormat.format(
Messages.getString("TracepointWeaveRewriter.errorUnknownOutputPort"), //$NON-NLS-1$
factoryClass.getName(),
factoryMethod.getName(),
portName,
list));
}
}
return new Tracepoint(factory.value().getName(), factoryMethod.getName(), portKind, portName);
}