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

@@ -44,7 +44,7 @@ public @interface CacheEvict {
/**
* Alias for {@link #cacheNames}.
*/
@AliasFor(attribute = "cacheNames")
@AliasFor("cacheNames")
String[] value() default {};
/**
@@ -55,7 +55,7 @@ public @interface CacheEvict {
* @see #value
* @see CacheConfig#cacheNames
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String[] cacheNames() default {};
/**

View File

@@ -50,7 +50,7 @@ public @interface CachePut {
/**
* Alias for {@link #cacheNames}.
*/
@AliasFor(attribute = "cacheNames")
@AliasFor("cacheNames")
String[] value() default {};
/**
@@ -61,7 +61,7 @@ public @interface CachePut {
* @see #value
* @see CacheConfig#cacheNames
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String[] cacheNames() default {};
/**

View File

@@ -55,7 +55,7 @@ public @interface Cacheable {
/**
* Alias for {@link #cacheNames}.
*/
@AliasFor(attribute = "cacheNames")
@AliasFor("cacheNames")
String[] value() default {};
/**
@@ -66,7 +66,7 @@ public @interface Cacheable {
* @see #value
* @see CacheConfig#cacheNames
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String[] cacheNames() default {};
/**

View File

@@ -62,7 +62,7 @@ public @interface ComponentScan {
* are needed — for example, {@code @ComponentScan("org.my.pkg")}
* instead of {@code @ComponentScan(basePackages = "org.my.pkg")}.
*/
@AliasFor(attribute = "basePackages")
@AliasFor("basePackages")
String[] value() default {};
/**
@@ -72,7 +72,7 @@ public @interface ComponentScan {
* <p>Use {@link #basePackageClasses} for a type-safe alternative to
* String-based package names.
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String[] basePackages() default {};
/**
@@ -166,7 +166,7 @@ public @interface ComponentScan {
* Alias for {@link #classes}.
* @see #classes
*/
@AliasFor(attribute = "classes")
@AliasFor("classes")
Class<?>[] value() default {};
/**
@@ -190,7 +190,7 @@ public @interface ComponentScan {
* @see #value
* @see #type
*/
@AliasFor(attribute = "value")
@AliasFor("value")
Class<?>[] classes() default {};
/**

View File

@@ -59,7 +59,7 @@ public @interface ImportResource {
* @see #locations
* @see #reader
*/
@AliasFor(attribute = "locations")
@AliasFor("locations")
String[] value() default {};
/**
@@ -72,7 +72,7 @@ public @interface ImportResource {
* @see #value
* @see #reader
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String[] locations() default {};
/**

View File

@@ -61,7 +61,7 @@ public @interface Scope {
* Alias for {@link #scopeName}.
* @see #scopeName
*/
@AliasFor(attribute = "scopeName")
@AliasFor("scopeName")
String value() default "";
/**
@@ -75,7 +75,7 @@ public @interface Scope {
* @see org.springframework.web.context.WebApplicationContext#SCOPE_SESSION
* @see #value
*/
@AliasFor(attribute = "value")
@AliasFor("value")
String scopeName() default "";
/**

View File

@@ -69,7 +69,7 @@ public @interface EventListener {
/**
* Alias for {@link #classes}.
*/
@AliasFor(attribute = "classes")
@AliasFor("classes")
Class<?>[] value() default {};
/**
@@ -79,7 +79,7 @@ public @interface EventListener {
* attribute is specified with multiple values, the annotated method
* must <em>not</em> declare any parameters.
*/
@AliasFor(attribute = "value")
@AliasFor("value")
Class<?>[] classes() default {};
/**

View File

@@ -49,10 +49,10 @@ public @interface ManagedResource {
/**
* Alias for the {@link #objectName} attribute, for simple default usage.
*/
@AliasFor(attribute = "objectName")
@AliasFor("objectName")
String value() default "";
@AliasFor(attribute = "value")
@AliasFor("value")
String objectName() default "";
String description() default "";