Introduce 'value' alias for 'attribute' in @AliasFor

SPR-11512 introduced support for annotation attribute aliases via
@AliasFor, requiring the explicit declaration of the 'attribute'
attribute. However, for aliases within an annotation, this explicit
declaration is unnecessary.

This commit improves the readability of alias pairs declared within an
annotation by introducing a 'value' attribute in @AliasFor that is an
alias for the existing 'attribute' attribute. This allows annotations
such as @ContextConfiguration from the spring-test module to declare
aliases as follows.

public @interface ContextConfiguration {

     @AliasFor("locations")
     String[] value() default {};

     @AliasFor("value")
     String[] locations() default {};

    // ...
}

Issue: SPR-13289
This commit is contained in:
Sam Brannen
2015-07-29 15:27:06 +02:00
parent 90493f49e6
commit 725292081e
35 changed files with 170 additions and 84 deletions

View File

@@ -55,7 +55,7 @@ public @interface ActiveProfiles {
* <p>This attribute may <strong>not</strong> be used in conjunction with
* {@link #profiles}, but it may be used <em>instead</em> of {@link #profiles}.
*/
@AliasFor(attribute = "profiles")
@AliasFor("profiles")
String[] value() default {};
/**
@@ -64,7 +64,7 @@ public @interface ActiveProfiles {
* <p>This attribute may <strong>not</strong> be used in conjunction with
* {@link #value}, but it may be used <em>instead</em> of {@link #value}.
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String[] profiles() default {};
/**

View File

@@ -98,7 +98,7 @@ public @interface ContextConfiguration {
* @since 3.0
* @see #inheritLocations
*/
@AliasFor(attribute = "locations")
@AliasFor("locations")
String[] value() default {};
/**
@@ -129,7 +129,7 @@ public @interface ContextConfiguration {
* @since 2.5
* @see #inheritLocations
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String[] locations() default {};
/**

View File

@@ -87,7 +87,7 @@ public @interface TestExecutionListeners {
* <p>This attribute may <strong>not</strong> be used in conjunction with
* {@link #listeners}, but it may be used instead of {@link #listeners}.
*/
@AliasFor(attribute = "listeners")
@AliasFor("listeners")
Class<? extends TestExecutionListener>[] value() default {};
/**
@@ -103,7 +103,7 @@ public @interface TestExecutionListeners {
* @see org.springframework.test.context.transaction.TransactionalTestExecutionListener
* @see org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener
*/
@AliasFor(attribute = "value")
@AliasFor("value")
Class<? extends TestExecutionListener>[] listeners() default {};
/**

View File

@@ -96,7 +96,7 @@ public @interface TestPropertySource {
*
* @see #locations
*/
@AliasFor(attribute = "locations")
@AliasFor("locations")
String[] value() default {};
/**
@@ -144,7 +144,7 @@ public @interface TestPropertySource {
* @see #properties
* @see org.springframework.core.env.PropertySource
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String[] locations() default {};
/**

View File

@@ -98,7 +98,7 @@ public @interface Sql {
* @see #scripts
* @see #statements
*/
@AliasFor(attribute = "scripts")
@AliasFor("scripts")
String[] value() default {};
/**
@@ -139,7 +139,7 @@ public @interface Sql {
* @see #value
* @see #statements
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String[] scripts() default {};
/**