if (exceptionNames.isEmpty()) {
MarkerAnnotation mAnnotation = ast.newMarkerAnnotation();
annotation = mAnnotation;
}
else {
SingleMemberAnnotation sAnnotation = ast.newSingleMemberAnnotation();
annotation = sAnnotation;
Expression value;
if (exceptionNames.size() == 1) {
TypeLiteral typeLiteral = getTypeLiteral(exceptionNames.get(0), ast);
value = typeLiteral;
addLinkedPosition(astRewrite.track(typeLiteral.getType()), true, "ExceptionHandler");
}
else {
ArrayInitializer arrayInitializer = ast.newArrayInitializer();
List<Expression> expressions = arrayInitializer.expressions();
for (int i = 0; i < exceptionNames.size(); i++) {
String exceptionName = exceptionNames.get(i);
TypeLiteral typeLiteral = getTypeLiteral(exceptionName, ast);
addLinkedPosition(astRewrite.track(typeLiteral.getType()), i == 0, "ExceptionHandler" + i);
expressions.add(typeLiteral);
}
value = arrayInitializer;
}
sAnnotation.setValue(value);
}
SimpleName name = ast.newSimpleName("ExceptionHandler");
annotation.setTypeName(name);