return new MemberValuePair(value.getName().getSymbolName(),
convertedValue);
}
if (value instanceof EnumAttributeValue) {
final EnumDetails castValue = ((EnumAttributeValue) value)
.getValue();
// This isn't as elegant as it could be (ie loss of type
// parameters), but it will do for now
final FieldAccessExpr convertedValue = new FieldAccessExpr(
JavaParserUtils.getNameExpr(castValue.getType()
.getFullyQualifiedTypeName()), castValue.getField()
.getSymbolName());
return new MemberValuePair(value.getName().getSymbolName(),
convertedValue);
}
if (value instanceof ClassAttributeValue) {
final JavaType castValue = ((ClassAttributeValue) value).getValue();
// This doesn't preserve type parameters
final NameExpr nameExpr = JavaParserUtils.getNameExpr(castValue
.getFullyQualifiedTypeName());
final ClassExpr convertedValue = new ClassExpr(
JavaParserUtils.getReferenceType(nameExpr));
return new MemberValuePair(value.getName().getSymbolName(),
convertedValue);
}
if (value instanceof ArrayAttributeValue) {
final ArrayAttributeValue<AnnotationAttributeValue<?>> castValue = (ArrayAttributeValue<AnnotationAttributeValue<?>>) value;
final List<Expression> arrayElements = new ArrayList<Expression>();
for (final AnnotationAttributeValue<?> v : castValue.getValue()) {
MemberValuePair converted = convert(v);
if (converted != null) {
arrayElements.add(converted.getValue());
}
}