Custom Annotation Aliases
See original GitHub issueProvide an API to allow users to register their own annotations to be aliases to default ACF annotations + Configurations: Flags, Conditions, CommandPermission, Subcommand
Something like
manager.registerAnnotation(CustomAnnotation.class, Conditions.class, "conditionname:conditionconfig");
manager.registerParameterAnnotation(ParameterType.class, CustomAnnotation.class, Conditions.class, "conditionname:conditionconfig");
manager.registerParameterAnnotation(ParameterType.class, CustomAnnotation.class, Flags.class, "flagconfig=flagvalue");
Then using @CustomAnnotation
will be same as putting
@Conditions("conditionname:conditionconfig") @Flags("flagconfig=flagvalue")
on a parameter or method
I will be personally working this issue, not looking for PR’s on it.
Issue Analytics
- State:
- Created 6 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
AliasFor Annotation in Spring - Baeldung
In the same annotation, we use @AliasFor to declare aliases for ... Then, we'll see the explicit usage of aliases in the custom...
Read more >Create custom Annotation as alias for Framework-Annotation?
One approach is to write an annotation processor that transforms the AST (the compiler's internal representation of the source code).
Read more >How to declare aliases for annotation attributes in java?
HI, When I am going through the @AliasFor annotation in spring, they have introduced the topic "declare aliases for annotation attributes" ?
Read more >@AliasFor annotation Examples - LogicBig
@AliasFor annotation is used to declare aliases for annotation elements. Spring framework uses this annotation internally with a lot of ...
Read more >AliasFor - Spring
Aliases within an annotation: within a single annotation, @AliasFor can be declared on a pair of attributes to signal that they are interchangeable...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Have you considered using meta-annotations (so using annotations on annotations) for this instead? Not to mention, basic support would be trivial to implement (given the current state of the code):
In
Annotations.java#L53
if we change this:and define that function like so:
it would already find the necessary annotations. So we could implement your given example like this:
(The only additional thing that would be needed to change for
@Flags
to work like in the example is to allow that annotation to be present on annotation types, which it currently isn’t allowed to.@Conditions
would already work like this.)This is used quite extensively in Spring/Spring Boot (a little bit of reference here), though Spring goes quite a bit further (for example, also allowing for properties of the combined annotation to alias for properties on the composing annotations).
yes and no, work is actively being done in master for it.