Polishing

This commit is contained in:
Sam Brannen 2017-04-26 18:59:43 +02:00
parent c668d9a473
commit c855182e03
2 changed files with 14 additions and 9 deletions

View File

@ -1282,7 +1282,9 @@ public abstract class AnnotationUtils {
* Retrieve the <em>value</em> of the {@code value} attribute of a
* single-element Annotation, given an annotation instance.
* @param annotation the annotation instance from which to retrieve the value
* @return the attribute value, or {@code null} if not found
* @return the attribute value, or {@code null} if not found unless the attribute
* value cannot be retrieved due to an {@link AnnotationConfigurationException}, in
* which case such an exception will be rethrown
* @see #getValue(Annotation, String)
*/
public static Object getValue(Annotation annotation) {
@ -1293,9 +1295,9 @@ public abstract class AnnotationUtils {
* Retrieve the <em>value</em> of a named attribute, given an annotation instance.
* @param annotation the annotation instance from which to retrieve the value
* @param attributeName the name of the attribute value to retrieve
* @return the attribute value, or {@code null} if not found unless the the attribute value
* can not be retrieved due to {@link AnnotationConfigurationException}, in which case it
* will be re-thrown
* @return the attribute value, or {@code null} if not found unless the attribute
* value cannot be retrieved due to an {@link AnnotationConfigurationException}, in
* which case such an exception will be rethrown
* @see #getValue(Annotation)
* @see #rethrowAnnotationConfigurationException(Throwable)
*/
@ -1311,7 +1313,7 @@ public abstract class AnnotationUtils {
catch (InvocationTargetException ex) {
rethrowAnnotationConfigurationException(ex.getTargetException());
throw new IllegalStateException(
"Could not obtain value for annotation attribute '" + attributeName + "' on " + annotation, ex);
"Could not obtain value for annotation attribute '" + attributeName + "' in " + annotation, ex);
}
catch (Throwable ex) {
return null;

View File

@ -1240,10 +1240,13 @@ public class AnnotationUtilsTests {
assertEquals("value: ", "", contextConfig.value());
assertEquals("location: ", "", contextConfig.location());
}
@Test(expected = AnnotationConfigurationException.class)
public void synthesizeAnnotationWithAttributeAliasesDifferentValues() throws Exception {
getValue(synthesizeAnnotation(ContextConfigMismatch.class.getAnnotation(ContextConfig.class)));
@Test
public void synthesizeAnnotationWithAttributeAliasesWithDifferentValues() throws Exception {
ContextConfig contextConfig = synthesizeAnnotation(ContextConfigMismatch.class.getAnnotation(ContextConfig.class));
exception.expect(AnnotationConfigurationException.class);
getValue(contextConfig);
}
@Test