Polishing

This commit is contained in:
Juergen Hoeller 2014-06-26 11:44:07 +02:00
parent b3e3c5312f
commit cc917de24d
4 changed files with 14 additions and 20 deletions

View File

@ -367,14 +367,15 @@ public class AnnotationConfigUtils {
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata, static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
Class<?> containerClass, Class<?> annotationClass) { Class<?> containerClass, Class<?> annotationClass) {
return attributesForRepeatable(metadata, containerClass.getName(), annotationClass.getName()); return attributesForRepeatable(metadata, containerClass.getName(), annotationClass.getName());
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata, static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
String containerClassName, String annotationClassName) { String containerClassName, String annotationClassName) {
Set<AnnotationAttributes> result = new LinkedHashSet<AnnotationAttributes>();
Set<AnnotationAttributes> result = new LinkedHashSet<AnnotationAttributes>();
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false)); addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName, false));
Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName, false); Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName, false);
@ -386,8 +387,7 @@ public class AnnotationConfigUtils {
return Collections.unmodifiableSet(result); return Collections.unmodifiableSet(result);
} }
private static void addAttributesIfNotNull(Set<AnnotationAttributes> result, private static void addAttributesIfNotNull(Set<AnnotationAttributes> result, Map<String, Object> attributes) {
Map<String, Object> attributes) {
if (attributes != null) { if (attributes != null) {
result.add(AnnotationAttributes.fromMap(attributes)); result.add(AnnotationAttributes.fromMap(attributes));
} }

View File

@ -38,10 +38,11 @@ import static java.lang.annotation.RetentionPolicy.*;
* which is enabled by default. * which is enabled by default.
* *
* <p>The configuration options provided by this annotation are equivalent to * <p>The configuration options provided by this annotation are equivalent to
* those supported by {@link ScriptUtils} and {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator * those supported by {@link ScriptUtils} and
* ResourceDatabasePopulator} but are a superset of those provided by the * {@link org.springframework.jdbc.datasource.init.ResourceDatabasePopulator}
* {@code <jdbc:initialize-database />} XML namespace element. Consult the * but are a superset of those provided by the {@code <jdbc:initialize-database/>}
* Javadoc of individual attributes in this annotation for details. * XML namespace element. Consult the javadocs of individual attributes in this
* annotation for details.
* *
* <p>Beginning with Java 8, {@code @Sql} can be used as a * <p>Beginning with Java 8, {@code @Sql} can be used as a
* <em>{@linkplain Repeatable repeatable}</em> annotation. Otherwise, * <em>{@linkplain Repeatable repeatable}</em> annotation. Otherwise,
@ -66,7 +67,7 @@ import static java.lang.annotation.RetentionPolicy.*;
@Documented @Documented
@Inherited @Inherited
@Retention(RUNTIME) @Retention(RUNTIME)
@Target({ TYPE, METHOD }) @Target({TYPE, METHOD})
@Repeatable(SqlGroup.class) @Repeatable(SqlGroup.class)
public @interface Sql { public @interface Sql {
@ -85,7 +86,7 @@ public @interface Sql {
* The configured SQL scripts will be executed <em>after</em> the * The configured SQL scripts will be executed <em>after</em> the
* corresponding test method. * corresponding test method.
*/ */
AFTER_TEST_METHOD; AFTER_TEST_METHOD
} }
@ -98,10 +99,8 @@ public @interface Sql {
/** /**
* The paths to the SQL scripts to execute. * The paths to the SQL scripts to execute.
*
* <p>This attribute may <strong>not</strong> be used in conjunction with * <p>This attribute may <strong>not</strong> be used in conjunction with
* {@link #value}, but it may be used instead of {@link #value}. * {@link #value}, but it may be used instead of {@link #value}.
*
* <h3>Path Resource Semantics</h3> * <h3>Path Resource Semantics</h3>
* <p>Each path will be interpreted as a Spring * <p>Each path will be interpreted as a Spring
* {@link org.springframework.core.io.Resource Resource}. A plain path * {@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#CLASSPATH_URL_PREFIX classpath:},
* {@link ResourceUtils#FILE_URL_PREFIX file:}, {@code http:}, etc.) will be * {@link ResourceUtils#FILE_URL_PREFIX file:}, {@code http:}, etc.) will be
* loaded using the specified resource protocol. * loaded using the specified resource protocol.
*
* <h3>Default Script Detection</h3> * <h3>Default Script Detection</h3>
* <p>If no SQL scripts are specified, an attempt will be made to detect a * <p>If no SQL scripts are specified, an attempt will be made to detect a
* <em>default</em> script depending on where this annotation is declared. * <em>default</em> script depending on where this annotation is declared.

View File

@ -231,7 +231,7 @@ public class UriComponentsBuilder {
builder.scheme((scheme != null) ? scheme.toLowerCase() : scheme); builder.scheme((scheme != null) ? scheme.toLowerCase() : scheme);
builder.userInfo(m.group(4)); builder.userInfo(m.group(4));
String host = m.group(5); 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"); throw new IllegalArgumentException("[" + httpUrl + "] is not a valid HTTP URL");
} }
builder.host(host); builder.host(host);

View File

@ -224,7 +224,7 @@ public class AnnotationConfigDispatcherServletInitializerTests {
@Override @Override
protected Class<?>[] getServletConfigClasses() { protected Class<?>[] getServletConfigClasses() {
return new Class[]{MyConfiguration.class}; return new Class<?>[] {MyConfiguration.class};
} }
@Override @Override
@ -254,16 +254,12 @@ public class AnnotationConfigDispatcherServletInitializerTests {
} }
private static class MyBean { public static class MyBean {
} }
@Configuration @Configuration
@SuppressWarnings("unused") public static class MyConfiguration {
private static class MyConfiguration {
public MyConfiguration() {
}
@Bean @Bean
public MyBean bean() { public MyBean bean() {