Skip to content
Snippets Groups Projects
Commit bffcff97 authored by Simon Barner's avatar Simon Barner
Browse files

- Factor out creation of Exception to raiseCouldNotFindAnnotationValueProviderException(clazz);

refs 2255
parent 8a9084bb
No related branches found
No related tags found
No related merge requests found
......@@ -86,6 +86,15 @@ public final class AnnotationEntry {
return specification != null && specification.getSpecificationOf() != null;
}
/**
* Helper method used to raise an {@link Exception} in case an {@link IAnnotationValueProvider}
* could not be found for the {@link IAnnotatedSpecification} represented by {@code clazz}.
*/
private void raiseCouldNotFindAnnotationValueProviderException(
Class<? extends IAnnotatedSpecification> clazz) throws Exception {
throw new Exception("Could not find an AnnotationValueProvider for " + clazz.toString());
}
/** Adds a new tuple {@link IAnnotationValueProvider} {@link IAnnotatedSpecification}. */
public void addNewSpecification(IAnnotationValueProvider<IAnnotatedSpecification> provider,
IAnnotatedSpecification spec) {
......@@ -117,7 +126,7 @@ public final class AnnotationEntry {
getAnnotationValueProvider(clazz).setAnnotationName(name, specification);
}
throw new Exception("Could not find an AnnotationValueProvider for " + clazz.toString());
raiseCouldNotFindAnnotationValueProviderException(clazz);
}
/** Predicate if the given annotation can be edited. */
......@@ -189,9 +198,7 @@ public final class AnnotationEntry {
if(isOperationEnabled(specification)) {
getAnnotationValueProvider(clazz).setAnnotationValue(value, specification, instanceKey);
} else {
// TODO(VA) The following exception and message are repeated many times. Would be worth
// factorizing? e.g., using a method "couldNotFindProviderExn(Class clazz)"
throw new Exception("Could not find a AnnotationValueProvider for " + clazz.toString());
raiseCouldNotFindAnnotationValueProviderException(clazz);
}
}
......@@ -207,7 +214,7 @@ public final class AnnotationEntry {
if(isOperationEnabled(specification)) {
getAnnotationValueProvider(clazz).setAnnotationValue(value, specification, instanceKey);
} else {
throw new Exception("Could not find a AnnotationValueProvider for " + clazz.toString());
raiseCouldNotFindAnnotationValueProviderException(clazz);
}
}
......@@ -219,7 +226,7 @@ public final class AnnotationEntry {
if(isOperationEnabled(specification)) {
getAnnotationValueProvider(clazz).setAnnotationValue(value, specification);
} else {
throw new Exception("Could not find a AnnotationValueProvider for " + clazz.toString());
raiseCouldNotFindAnnotationValueProviderException(clazz);
}
}
......@@ -235,7 +242,7 @@ public final class AnnotationEntry {
if(isOperationEnabled(specification)) {
getAnnotationValueProvider(clazz).setAnnotationValue(value, specification);
} else {
throw new Exception("Could not find a AnnotationValueProvider for " + clazz.toString());
raiseCouldNotFindAnnotationValueProviderException(clazz);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment