return null;
}
addImportToCompilationUnit(annotation.getCanonicalName(), cu);
Annotation result = null;
Name annotationTypeName = isClassImported(annotation.getCanonicalName(), cu) ? ast.newSimpleName(annotationType.getElementName()) : createQualifiedName(ast, annotationType.getFullyQualifiedName());
if (properties != null) {
result = ast.newNormalAnnotation();
Method[] methods = annotation.getDeclaredMethods();
for (Method method : methods) {
Class<?> returnType = method.getReturnType();
// get the matching value in the properties
Object value = properties.get(method.getName());
if (value == null && method.getDefaultValue() == null) {
// TODO: throw an exception here
}
if (value == null) {
// no need to do anything - the default will be used
continue;
}
if (value.getClass().isArray() != returnType.isArray()) {
// TODO: throw an exception here
}
MemberValuePair annotationProperty = ast.newMemberValuePair();
annotationProperty.setName(ast.newSimpleName(method.getName()));
Expression expression = createAnnotationPropertyValueExpression(cu, returnType, value);
if (expression != null) {
annotationProperty.setValue(expression);
((NormalAnnotation) result).values().add(annotationProperty);
}
}
} else {
result = ast.newMarkerAnnotation();
}
result.setTypeName(annotationTypeName);
return result;
}