Result result;
if (onProperty.hasValue())
{
String propertyName = onProperty.getValue().getUnderlyingResourceObject().getName();
AnnotationTargetSource field = javaSource.getField(propertyName);
addAnnotationToSource(field, annotation.getValue());
result = Results.success("Annotation \"" + annotation.getValue() + "\" was successfully added to \""
+ propertyName + "\" property declaration.");
}
else if (onMethod.hasValue())
{
List<Parameter> parameters = onMethod.getValue().getUnderlyingResourceObject().getParameters();
String[] stringParametersArray = new String[parameters.size()];
for (int i = 0; i < parameters.size(); i++)
{
stringParametersArray[i] = parameters.get(i).getType().getName();
}
String methodName = onMethod.getValue().getUnderlyingResourceObject().getName();
AnnotationTargetSource method = javaSource.getMethod(methodName, stringParametersArray);
addAnnotationToSource(method, annotation.getValue());
result = Results.success("Annotation \"" + annotation.getValue() + "\" was successfully added to the \""
+ methodName + "\" method declaration.");