From 27d1ce84a3232bdf9d2944b8b04db8de3748c573 Mon Sep 17 00:00:00 2001 From: Sam Brannen Date: Sat, 20 Jun 2015 01:45:46 +0200 Subject: [PATCH] Polishing --- .../ScheduledAnnotationBeanPostProcessor.java | 2 +- .../core/annotation/AnnotationUtils.java | 34 +++++++++---------- .../core/annotation/AnnotationUtilsTests.java | 16 ++++----- .../jdbc/SqlScriptsTestExecutionListener.java | 8 ++--- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java b/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java index 591ae6a350..70b34a6aab 100644 --- a/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java +++ b/spring-context/src/main/java/org/springframework/scheduling/annotation/ScheduledAnnotationBeanPostProcessor.java @@ -224,7 +224,7 @@ public class ScheduledAnnotationBeanPostProcessor implements BeanPostProcessor, @Override public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException { for (Scheduled scheduled : - AnnotationUtils.getRepeatableAnnotations(method, Schedules.class, Scheduled.class)) { + AnnotationUtils.getRepeatableAnnotations(method, Scheduled.class, Schedules.class)) { processScheduled(scheduled, method, bean); annotatedMethods.add(method); } diff --git a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java index d6f2082c79..0b3c20c3c9 100644 --- a/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java +++ b/spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java @@ -257,7 +257,7 @@ public abstract class AnnotationUtils { @Deprecated public static Set getRepeatableAnnotation(Method method, Class containerAnnotationType, Class annotationType) { - return getRepeatableAnnotations(method, containerAnnotationType, annotationType); + return getRepeatableAnnotations(method, annotationType, containerAnnotationType); } /** @@ -269,7 +269,7 @@ public abstract class AnnotationUtils { @Deprecated public static Set getRepeatableAnnotation(AnnotatedElement annotatedElement, Class containerAnnotationType, Class annotationType) { - return getRepeatableAnnotations(annotatedElement, containerAnnotationType, annotationType); + return getRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType); } /** @@ -287,9 +287,9 @@ public abstract class AnnotationUtils { *

Meta-annotations will be searched if the annotation is not * present on the supplied element. * @param annotatedElement the element to look for annotations on; never {@code null} + * @param annotationType the annotation type to look for; never {@code null} * @param containerAnnotationType the type of the container that holds * the annotations; may be {@code null} if a container is not supported - * @param annotationType the annotation type to look for; never {@code null} * @return the annotations found or an empty set; never {@code null} * @since 4.2 * @see #getDeclaredRepeatableAnnotations(AnnotatedElement, Class, Class) @@ -298,14 +298,14 @@ public abstract class AnnotationUtils { * @see java.lang.reflect.AnnotatedElement#getAnnotationsByType */ public static Set getRepeatableAnnotations(AnnotatedElement annotatedElement, - Class containerAnnotationType, Class annotationType) { + Class annotationType, Class containerAnnotationType) { - Set annotations = getDeclaredRepeatableAnnotations(annotatedElement, containerAnnotationType, annotationType); + Set annotations = getDeclaredRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType); if (!annotations.isEmpty()) { return annotations; } - return getRepeatableAnnotations(annotatedElement, containerAnnotationType, annotationType, false); + return getRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType, false); } /** @@ -323,9 +323,9 @@ public abstract class AnnotationUtils { *

Meta-annotations will be searched if the annotation is not * present on the supplied element. * @param annotatedElement the element to look for annotations on; never {@code null} + * @param annotationType the annotation type to look for; never {@code null} * @param containerAnnotationType the type of the container that holds * the annotations; may be {@code null} if a container is not supported - * @param annotationType the annotation type to look for; never {@code null} * @return the annotations found or an empty set; never {@code null} * @since 4.2 * @see #getRepeatableAnnotations(AnnotatedElement, Class, Class) @@ -334,8 +334,8 @@ public abstract class AnnotationUtils { * @see java.lang.reflect.AnnotatedElement#getDeclaredAnnotationsByType */ public static Set getDeclaredRepeatableAnnotations(AnnotatedElement annotatedElement, - Class containerAnnotationType, Class annotationType) { - return getRepeatableAnnotations(annotatedElement, containerAnnotationType, annotationType, true); + Class annotationType, Class containerAnnotationType) { + return getRepeatableAnnotations(annotatedElement, annotationType, containerAnnotationType, true); } /** @@ -347,9 +347,9 @@ public abstract class AnnotationUtils { * present on the supplied element. * * @param annotatedElement the element to look for annotations on; never {@code null} + * @param annotationType the annotation type to look for; never {@code null} * @param containerAnnotationType the type of the container that holds * the annotations; may be {@code null} if a container is not supported - * @param annotationType the annotation type to look for; never {@code null} * @param declaredMode {@code true} if only declared annotations (i.e., * directly or indirectly present) should be considered. * @return the annotations found or an empty set; never {@code null} @@ -358,7 +358,7 @@ public abstract class AnnotationUtils { * @see java.lang.annotation.Repeatable */ private static Set getRepeatableAnnotations(AnnotatedElement annotatedElement, - Class containerAnnotationType, Class annotationType, boolean declaredMode) { + Class annotationType, Class containerAnnotationType, boolean declaredMode) { Assert.notNull(annotatedElement, "annotatedElement must not be null"); Assert.notNull(annotationType, "annotationType must not be null"); @@ -367,7 +367,7 @@ public abstract class AnnotationUtils { if (annotatedElement instanceof Method) { annotatedElement = BridgeMethodResolver.findBridgedMethod((Method) annotatedElement); } - return new AnnotationCollector(containerAnnotationType, annotationType, declaredMode).getResult(annotatedElement); + return new AnnotationCollector(annotationType, containerAnnotationType, declaredMode).getResult(annotatedElement); } catch (Exception ex) { handleIntrospectionFailure(annotatedElement, ex); @@ -1665,10 +1665,10 @@ public abstract class AnnotationUtils { private static class AnnotationCollector { - private final Class containerAnnotationType; - private final Class annotationType; + private final Class containerAnnotationType; + private final boolean declaredMode; private final Set visited = new HashSet(); @@ -1676,9 +1676,9 @@ public abstract class AnnotationUtils { private final Set result = new LinkedHashSet(); - AnnotationCollector(Class containerAnnotationType, Class annotationType, boolean declaredMode) { - this.containerAnnotationType = containerAnnotationType; + AnnotationCollector(Class annotationType, Class containerAnnotationType, boolean declaredMode) { this.annotationType = annotationType; + this.containerAnnotationType = containerAnnotationType; this.declaredMode = declaredMode; } @@ -1691,7 +1691,7 @@ public abstract class AnnotationUtils { private void process(AnnotatedElement element) { if (this.visited.add(element)) { try { - Annotation[] annotations = (declaredMode ? element.getDeclaredAnnotations() : element.getAnnotations()); + Annotation[] annotations = (this.declaredMode ? element.getDeclaredAnnotations() : element.getAnnotations()); for (Annotation ann : annotations) { Class currentAnnotationType = ann.annotationType(); if (ObjectUtils.nullSafeEquals(this.annotationType, currentAnnotationType)) { diff --git a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java index 02fcc385c8..3feb22c125 100644 --- a/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java +++ b/spring-core/src/test/java/org/springframework/core/annotation/AnnotationUtilsTests.java @@ -501,7 +501,7 @@ public class AnnotationUtilsTests { @Test public void getRepeatableAnnotationsDeclaredOnMethod() throws Exception { Method method = InterfaceWithRepeated.class.getMethod("foo"); - Set annotations = getRepeatableAnnotations(method, MyRepeatableContainer.class, MyRepeatable.class); + Set annotations = getRepeatableAnnotations(method, MyRepeatable.class, MyRepeatableContainer.class); assertNotNull(annotations); List values = annotations.stream().map(MyRepeatable::value).collect(toList()); assertThat(values, is(Arrays.asList("A", "B", "C", "meta1"))); @@ -513,14 +513,14 @@ public class AnnotationUtilsTests { exception.expectMessage(containsString("Attribute [value] in")); exception.expectMessage(containsString(BrokenContextConfig.class.getName())); exception.expectMessage(containsString("must be declared as an @AliasFor [locations]")); - getRepeatableAnnotations(BrokenConfigHierarchyTestCase.class, BrokenHierarchy.class, BrokenContextConfig.class); + getRepeatableAnnotations(BrokenConfigHierarchyTestCase.class, BrokenContextConfig.class, BrokenHierarchy.class); } @Test public void getRepeatableAnnotationsDeclaredOnClassWithAttributeAliases() throws Exception { final List expectedLocations = Arrays.asList("A", "B"); - Set annotations = getRepeatableAnnotations(ConfigHierarchyTestCase.class, Hierarchy.class, ContextConfig.class); + Set annotations = getRepeatableAnnotations(ConfigHierarchyTestCase.class, ContextConfig.class, Hierarchy.class); assertNotNull(annotations); List locations = annotations.stream().map(ContextConfig::locations).collect(toList()); @@ -542,7 +542,7 @@ public class AnnotationUtilsTests { assertThat(values, is(expectedValuesJava)); // Spring - Set set = getRepeatableAnnotations(MyRepeatableClass.class, MyRepeatableContainer.class, MyRepeatable.class); + Set set = getRepeatableAnnotations(MyRepeatableClass.class, MyRepeatable.class, MyRepeatableContainer.class); assertNotNull(set); values = set.stream().map(MyRepeatable::value).collect(toList()); assertThat(values, is(expectedValuesSpring)); @@ -561,7 +561,7 @@ public class AnnotationUtilsTests { assertThat(values, is(expectedValuesJava)); // Spring - Set set = getRepeatableAnnotations(clazz, MyRepeatableContainer.class, MyRepeatable.class); + Set set = getRepeatableAnnotations(clazz, MyRepeatable.class, MyRepeatableContainer.class); assertNotNull(set); values = set.stream().map(MyRepeatable::value).collect(toList()); assertThat(values, is(expectedValuesSpring)); @@ -580,7 +580,7 @@ public class AnnotationUtilsTests { assertThat(values, is(expectedValuesJava)); // Spring - Set set = getRepeatableAnnotations(clazz, MyRepeatableContainer.class, MyRepeatable.class); + Set set = getRepeatableAnnotations(clazz, MyRepeatable.class, MyRepeatableContainer.class); assertNotNull(set); values = set.stream().map(MyRepeatable::value).collect(toList()); assertThat(values, is(expectedValuesSpring)); @@ -598,7 +598,7 @@ public class AnnotationUtilsTests { assertThat(values, is(expectedValuesJava)); // Spring - Set set = getDeclaredRepeatableAnnotations(MyRepeatableClass.class, MyRepeatableContainer.class, MyRepeatable.class); + Set set = getDeclaredRepeatableAnnotations(MyRepeatableClass.class, MyRepeatable.class, MyRepeatableContainer.class); assertNotNull(set); values = set.stream().map(MyRepeatable::value).collect(toList()); assertThat(values, is(expectedValuesSpring)); @@ -614,7 +614,7 @@ public class AnnotationUtilsTests { assertThat(array.length, is(0)); // Spring - Set set = getDeclaredRepeatableAnnotations(clazz, MyRepeatableContainer.class, MyRepeatable.class); + Set set = getDeclaredRepeatableAnnotations(clazz, MyRepeatable.class, MyRepeatableContainer.class); assertNotNull(set); assertThat(set.size(), is(0)); } diff --git a/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java b/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java index d6d6a5c8f8..a7de607193 100644 --- a/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java +++ b/spring-test/src/main/java/org/springframework/test/context/jdbc/SqlScriptsTestExecutionListener.java @@ -123,11 +123,11 @@ public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListen private void executeSqlScripts(TestContext testContext, ExecutionPhase executionPhase) throws Exception { boolean classLevel = false; - Set sqlAnnotations = AnnotationUtils.getRepeatableAnnotations(testContext.getTestMethod(), SqlGroup.class, - Sql.class); + Set sqlAnnotations = AnnotationUtils.getRepeatableAnnotations(testContext.getTestMethod(), Sql.class, + SqlGroup.class); if (sqlAnnotations.isEmpty()) { - sqlAnnotations = AnnotationUtils.getRepeatableAnnotations(testContext.getTestClass(), SqlGroup.class, - Sql.class); + sqlAnnotations = AnnotationUtils.getRepeatableAnnotations(testContext.getTestClass(), Sql.class, + SqlGroup.class); if (!sqlAnnotations.isEmpty()) { classLevel = true; } -- GitLab