Skip to content

Add support for repeatable annotations #1670

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
wants to merge 28 commits into from

Conversation

YangSiJun528
Copy link
Contributor

@YangSiJun528 YangSiJun528 commented Jul 9, 2025

Resolves issue #1624 by adding support for repeatable annotations of the same type.

Key changes:

  • Deprecates AnnotationContainer#add and replaces it with AnnotationContainer#addSingle and AnnotationContainer#customizeSingle
    • AnnotationContainer#addSingle handles adding single annotations
    • AnnotationContainer#customizeSingle handles customizing single annotations
  • Adds new AnnotationContainer#addRepeatable to support repeatable annotations
  • Fixes KotlinSourceCodeWriter#writeProperty to correctly write annotations
  • Refactors code to use the new methods instead of deprecated AnnotationContainer#add
  • Adds tests

Fixes gh-1624

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 9, 2025
@mhalbritter
Copy link
Contributor

Hello! The build is failing because of formatting violations. You can check them locally by running ./mvnw verify.

@YangSiJun528
Copy link
Contributor Author

I made the fix and confirmed it works locally.

@mhalbritter
Copy link
Contributor

Hello,

thanks for the PR! I might have missed something here, but why did you create a second implementation for the annotations? Is there a reason we couldn't add the functionality for repeated annotations into the AnnotationContainer itself?

@mhalbritter mhalbritter added the status: waiting-for-feedback We need additional information before we can continue label Jul 14, 2025
@YangSiJun528

This comment was marked as resolved.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Jul 14, 2025
@YangSiJun528
Copy link
Contributor Author

YangSiJun528 commented Jul 15, 2025

After thinking more about your previous comment, I realized there might be a better approach that allows AnnotationContainer itself to support repeated annotations.
This way, it adds support for repeatable annotations without many code changes.

You can see it in this commit — I've confirmed that it doesn't break any existing tests:
YangSiJun528@488ce5a

Sorry if my earlier proposal ended up taking unnecessary time.

Do you think this approach would be better?
If you agree, I can update the PR with this version.

@mhalbritter
Copy link
Contributor

Yes, please update the PR. Thanks!

@YangSiJun528
Copy link
Contributor Author

I've updated the PR. @mhalbritter

@mhalbritter mhalbritter added status: waiting-for-feedback We need additional information before we can continue and removed status: feedback-provided Feedback has been provided labels Jul 17, 2025
Signed-off-by: sijun-yang <[email protected]>
@mhalbritter mhalbritter added type: enhancement and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Jul 22, 2025
@mhalbritter mhalbritter added this to the 0.23.0 milestone Jul 22, 2025
@mhalbritter mhalbritter self-assigned this Jul 22, 2025
mhalbritter added a commit that referenced this pull request Jul 22, 2025
See gh-1670

Signed-off-by: sijun-yang <[email protected]>

Co-authored-by: Moritz Halbritter <[email protected]>
@mhalbritter
Copy link
Contributor

Thanks a lot @YangSiJun528 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support repeated annotations in AnnotationContainer
3 participants