Skip to content

Introduce 'value' alias for 'attribute' in @AliasFor [SPR-13289] #17879

Closed

Description

@spring-projects-issues

Sam Brannen opened SPR-13289 and commented

Status Quo

#16137 introduced support for annotation attribute aliases via @AliasFor. For example, this support allows @ContextConfiguration from the spring-test module to declare aliases as follows:

public @interface ContextConfiguration {

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

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

    // ...
}

For greater readability, it would be beneficial to be able to omit the attribute = "..." declaration by providing a value alias for attribute.

Deliverables

  1. Introduce a value alias for attribute in @AliasFor.

Affects: 4.2 RC1

Issue Links:

Referenced from: commits 7252920, 1c8ac2b

Activity

  1. spring-projects-issues commented on Jul 29, 2015

    @spring-projects-issues
    CollaboratorAuthor

    Sam Brannen commented

    Implemented in GitHub commit 7252920:

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

    #16137 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 {};
    
        // ...
    }
  2. added
    type: enhancement
    in: core
    on Jan 11, 2019
  3. added this to the 4.2 GA milestone on Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

in: coretype: enhancement

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions