Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
spring-projects-issues opened this issue Jul 29, 2015 · 1 comment
Closed
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Jul 29, 2015

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

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues commented Jul 29, 2015

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 {};

    // ...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants