public static AnnotationValue generateElementValueForConstantExpression(Expression defaultValue, TypeBinding defaultValueBinding) {
if (defaultValueBinding != null) {
Constant c = defaultValue.constant;
if (c instanceof IntConstant) {
IntConstant iConstant = (IntConstant) c;
return new SimpleAnnotationValue(ElementValue.PRIMITIVE_INT, new Integer(iConstant.intValue()));
} else if (c instanceof BooleanConstant) {
BooleanConstant iConstant = (BooleanConstant) c;
return new SimpleAnnotationValue(ElementValue.PRIMITIVE_BOOLEAN, new Boolean(iConstant.booleanValue()));
} else if (c instanceof StringConstant) {
StringConstant sConstant = (StringConstant) c;
return new SimpleAnnotationValue(ElementValue.STRING, sConstant.stringValue());
}
}
return null;
}