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
Support an alias for a bunch of annotations #1560
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1560 +/- ##
============================================
+ Coverage 72.56% 72.59% +0.03%
- Complexity 7353 7360 +7
============================================
Files 684 685 +1
Lines 29714 29769 +55
Branches 3616 3628 +12
============================================
+ Hits 21562 21612 +50
- Misses 6267 6271 +4
- Partials 1885 1886 +1
Continue to review full report at Codecov.
|
Motivation: A user may want to define his or her annotations as a custom annotation in order to apply the custom annotation to his or her annotated HTTP services. e.g: ``` // Define a custom annotation: @ProducesJson @LoggingDecorator @interface MyApiSpecification {} // Apply it to the annotated HTTP service: @get("/api") @MyApiSpecification public Something getSomething() {} ``` Modifications: - Add `AnnotationUtil` for finding a specific annotation or getting all annotations from an `AnnotatedElement`. - Use `AnnotationUtil` instead of `ReflectionUtils.getAllAnnotations()`. The old one does not respect the order of the annotations because its return type is a `Set<Annotation>` (more specifically it's `HashSet`). Result: - Won't depend on the `ReflectionUtils`'s implementation when getting annotations.
25d4d35
to
3e23aa0
Compare
core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotationUtil.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotationUtil.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotationUtil.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotationUtil.java
Outdated
Show resolved
Hide resolved
core/src/main/java/com/linecorp/armeria/internal/annotation/AnnotationUtil.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Motivation: Follow-up work after line#1560. Modifications: - `AnnotationUtil` will lookup meta-annotations of a meta-annotation to support the following case: ``` @ProducesJson @produces("text/plain") @interface MyPostServiceSpecifications {} ``` - `@ProducesJson` will also be found with this PR, which wasn't found before. - Add `ElementType.ANNOTATION_TYPE` to `Target` annotation for `@Order` and `@StatusCode` so that a user can use them as a meta-annotation for his or her custom annotation.
Motivation: Follow-up work after line#1560. Modifications: - `AnnotationUtil` will lookup meta-annotations of a meta-annotation to support the following case: ``` @ProducesJson @produces("text/plain") @interface MyPostServiceSpecifications {} ``` - `@ProducesJson` will also be found with this PR, which wasn't found before. - Add `ElementType.ANNOTATION_TYPE` to `Target` annotation for `@Order` and `@StatusCode` so that a user can use them as a meta-annotation for his or her custom annotation.
Motivation: Follow-up work after line#1560. Modifications: - `AnnotationUtil` will lookup meta-annotations of a meta-annotation to support the following case: ``` @ProducesJson @produces("text/plain") @interface MyPostServiceSpecifications {} ``` - `@ProducesJson` will also be found with this PR, which wasn't found before. - Add `ElementType.ANNOTATION_TYPE` to `Target` annotation for `@Order` and `@StatusCode` so that a user can use them as a meta-annotation for his or her custom annotation.
Motivation: Follow-up work after #1560. Modifications: - `AnnotationUtil` will lookup meta-annotations of a meta-annotation to support the following case: ``` @ProducesJson @produces("text/plain") @interface MyPostServiceSpecifications {} ``` - `@ProducesJson` will also be found with this PR, which wasn't found before. - Add `ElementType.ANNOTATION_TYPE` to `Target` annotation for `@Order` and `@StatusCode` so that a user can use them as a meta-annotation for his or her custom annotation. - Add @AdditionalHeader/Trailer to annotation alias test
Motivation: A user may want to define his or her annotations as a custom annotation in order to apply the custom annotation to his or her annotated HTTP services. e.g: ``` // Define a custom annotation: @ProducesJson @LoggingDecorator @interface MyApiSpecification {} // Apply it to the annotated HTTP service: @get("/api") @MyApiSpecification public Something getSomething() {} ``` Modifications: - Add `AnnotationUtil` for finding a specific annotation or getting all annotations from an `AnnotatedElement`. - Use `AnnotationUtil` instead of `ReflectionUtils.getAllAnnotations()`. The old one does not respect the order of the annotations because its return type is a `Set<Annotation>` (more specifically it's `HashSet`). Result: - Won't depend on the `ReflectionUtils`'s implementation when getting annotations.
Motivation: Follow-up work after line#1560. Modifications: - `AnnotationUtil` will lookup meta-annotations of a meta-annotation to support the following case: ``` @ProducesJson @produces("text/plain") @interface MyPostServiceSpecifications {} ``` - `@ProducesJson` will also be found with this PR, which wasn't found before. - Add `ElementType.ANNOTATION_TYPE` to `Target` annotation for `@Order` and `@StatusCode` so that a user can use them as a meta-annotation for his or her custom annotation. - Add @AdditionalHeader/Trailer to annotation alias test
Motivation:
A user may want to define his or her annotations as a custom annotation in order to apply the custom annotation to his or her annotated HTTP services. e.g:
Modifications:
AnnotationUtil
for finding a specific annotation or getting all annotations from anAnnotatedElement
.AnnotationUtil
instead ofReflectionUtils.getAllAnnotations()
. The old one does not respect the order of the annotations because its return type is aSet<Annotation>
(more specifically it'sHashSet
).Result:
ReflectionUtils
's implementation when getting annotations.