Skip to content

Define new enum ClassAccessibility#4071

Merged
hduelme merged 8 commits into
mapstruct:mainfrom
Chessray:main
Jun 24, 2026
Merged

Define new enum ClassAccessibility#4071
hduelme merged 8 commits into
mapstruct:mainfrom
Chessray:main

Conversation

@Chessray

Copy link
Copy Markdown
Contributor

Define new enum ClassAccessibility for controlling generated Mappers' declared accessibility.

Fixes #2513.

@hduelme hduelme left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Chessray, left a few small comments, implementation looks good overall. Could you also add the tests for @MapperConfig?

Comment thread core/src/main/java/org/mapstruct/ClassAccessibility.java Outdated
Comment thread core/src/main/java/org/mapstruct/ClassAccessibility.java Outdated
@Chessray Chessray requested a review from hduelme June 19, 2026 20:29
@Chessray

Copy link
Copy Markdown
Contributor Author

Hi @Chessray, left a few small comments, implementation looks good overall. Could you also add the tests for @MapperConfig?

Thanks @hduelme, I hope I've got them all. Could you please check again?

@hduelme hduelme left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chessray thanks for the adjustments.

One last thought: currently, DEFAULT is used to represent package-private visibility. Would something like PACKAGE_PRIVATE be more intuitive and make the intent clearer? Let me know what you think.

Out of curiosity, are you planning to use this feature mapstruct-spring-extensions?

@Chessray

Copy link
Copy Markdown
Contributor Author

@Chessray thanks for the adjustments.

One last thought: currently, DEFAULT is used to represent package-private visibility. Would something like PACKAGE_PRIVATE be more intuitive and make the intent clearer? Let me know what you think.

I had this exact mental discussion and ended up with DEFAULT because of the same terminology being used in Accessibility.java. I find PACKAGE_PRIVATE more descriptive myself. Maybe we can rename both places? Does @filiphr want to chime in here?

Out of curiosity, are you planning to use this feature mapstruct-spring-extensions?

I don't really see how. This influences the Mapper generation, not the Adapter.

@filiphr

filiphr commented Jun 22, 2026

Copy link
Copy Markdown
Member

Nice addition @Chessray. From the point of our API, I personally find the LIKE_ABSTRACTION a bit strange. What I would propose is to use DEFAULT for the mapstruct default (i.e. The current like abstraction) and use PACKAGE_PROTECTED for package protected.

@hduelme

hduelme commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

I had this exact mental discussion and ended up with DEFAULT because of the same terminology being used in Accessibility.java. I find PACKAGE_PRIVATE more descriptive myself

@Chessray Good point. I think we should rename Accessibility.java too. DEFAULT doesn't really fit.

@hduelme

hduelme commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

I don't really see how. This influences the Mapper generation, not the Adapter.

Makes sense. Do you think we should adjust the examples in the extension? My thoughts were based on the original issue mentioning Spring.

@Chessray

Copy link
Copy Markdown
Contributor Author

Thanks guys, this should be it now. @hduelme I'll take a look at the Spring Extension examples separately. Maybe I'll only mention it in the documentation.

@hduelme hduelme left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Chessray thanks for adjusting. The naming looks good to me now.
It seems like we currently don't enforce consistent enum formatting.

@filiphr I think the preferred formatting is to have spaces before and after enum constant parameters (e.g. PUBLIC( "public" )). Do you agree? Maybe we could add this rule to our Checkstyle configuration.

Comment thread processor/src/main/java/org/mapstruct/ap/internal/model/common/Accessibility.java Outdated
@Chessray Chessray requested a review from hduelme June 23, 2026 19:30
@hduelme hduelme merged commit f5253e8 into mapstruct:main Jun 24, 2026
9 checks passed
@hduelme

hduelme commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

@Chessray Nice one. Thanks

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated mappers for Spring can be package-private

3 participants