From cc917de24de5a99ac51c1cdd15eab0d7ccdf6430 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 26 Jun 2014 11:44:07 +0200 Subject: [PATCH] Polishing --- .../annotation/AnnotationConfigUtils.java | 6 +++--- .../springframework/test/context/jdbc/Sql.java | 16 +++++++--------- .../web/util/UriComponentsBuilder.java | 2 +- ...nConfigDispatcherServletInitializerTests.java | 10 +++------- 4 files changed, 14 insertions(+), 20 deletions(-) diff --git a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java index 7bd49f97ca..2298a429ac 100644 --- a/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java +++ b/spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java @@ -367,14 +367,15 @@ public class AnnotationConfigUtils { static Set attributesForRepeatable(AnnotationMetadata metadata, Class containerClass, Class annotationClass) { + return attributesForRepeatable(metadata, containerClass.getName(), annotationClass.getName()); } @SuppressWarnings("unchecked") static Set attributesForRepeatable(AnnotationMetadata metadata, String containerClassName, String annotationClassName) { - Set result = new LinkedHashSet(); + Set result = new LinkedHashSet(); addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false)); Map container = metadata.getAnnotationAttributes(containerClassName, false); @@ -386,8 +387,7 @@ public class AnnotationConfigUtils { return Collections.unmodifiableSet(result); } - private static void addAttributesIfNotNull(Set result, - Map attributes) { + private static void addAttributesIfNotNull(Set result, Map attributes) { if (attributes != null) { result.add(AnnotationAttributes.fromMap(attributes)); } diff --git a/spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java b/spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java index 7668048fc4..e64603bd22 100644 --- a/spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java +++ b/spring-test/src/main/java/org/springframework/test/context/jdbc/Sql.java @@ -38,10 +38,11 @@ import static java.lang.annotation.RetentionPolicy.*; * which is enabled by default. * *

The configuration options provided by this annotation are equivalent to - * those supported by {@link ScriptUtils} and {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator - * ResourceDatabasePopulator} but are a superset of those provided by the - * {@code } XML namespace element. Consult the - * Javadoc of individual attributes in this annotation for details. + * those supported by {@link ScriptUtils} and + * {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator} + * but are a superset of those provided by the {@code } + * XML namespace element. Consult the javadocs of individual attributes in this + * annotation for details. * *

Beginning with Java 8, {@code @Sql} can be used as a * {@linkplain Repeatable repeatable} annotation. Otherwise, @@ -66,7 +67,7 @@ import static java.lang.annotation.RetentionPolicy.*; @Documented @Inherited @Retention(RUNTIME) -@Target({ TYPE, METHOD }) +@Target({TYPE, METHOD}) @Repeatable(SqlGroup.class) public @interface Sql { @@ -85,7 +86,7 @@ public @interface Sql { * The configured SQL scripts will be executed after the * corresponding test method. */ - AFTER_TEST_METHOD; + AFTER_TEST_METHOD } @@ -98,10 +99,8 @@ public @interface Sql { /** * The paths to the SQL scripts to execute. - * *

This attribute may not be used in conjunction with * {@link #value}, but it may be used instead of {@link #value}. - * *

Path Resource Semantics

*

Each path will be interpreted as a Spring * {@link org.springframework.core.io.Resource Resource}. A plain path @@ -114,7 +113,6 @@ public @interface Sql { * {@link ResourceUtils#CLASSPATH_URL_PREFIX classpath:}, * {@link ResourceUtils#FILE_URL_PREFIX file:}, {@code http:}, etc.) will be * loaded using the specified resource protocol. - * *

Default Script Detection

*

If no SQL scripts are specified, an attempt will be made to detect a * default script depending on where this annotation is declared. diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index ec6c96f50a..e6a3c2f022 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -231,7 +231,7 @@ public class UriComponentsBuilder { builder.scheme((scheme != null) ? scheme.toLowerCase() : scheme); builder.userInfo(m.group(4)); String host = m.group(5); - if(StringUtils.hasLength(scheme) && !StringUtils.hasLength(host)) { + if (StringUtils.hasLength(scheme) && !StringUtils.hasLength(host)) { throw new IllegalArgumentException("[" + httpUrl + "] is not a valid HTTP URL"); } builder.host(host); diff --git a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java index c4acf15b58..843b703749 100644 --- a/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java +++ b/spring-webmvc/src/test/java/org/springframework/web/servlet/support/AnnotationConfigDispatcherServletInitializerTests.java @@ -224,7 +224,7 @@ public class AnnotationConfigDispatcherServletInitializerTests { @Override protected Class[] getServletConfigClasses() { - return new Class[]{MyConfiguration.class}; + return new Class[] {MyConfiguration.class}; } @Override @@ -254,16 +254,12 @@ public class AnnotationConfigDispatcherServletInitializerTests { } - private static class MyBean { + public static class MyBean { } @Configuration - @SuppressWarnings("unused") - private static class MyConfiguration { - - public MyConfiguration() { - } + public static class MyConfiguration { @Bean public MyBean bean() {