Skip to content
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

Use consistent style for Nested/Collection/Map properties in @ConfigurationProperties #43919

Open
quaff opened this issue Jan 22, 2025 · 1 comment
Labels
type: enhancement A general enhancement
Milestone

Comments

@quaff
Copy link
Contributor

quaff commented Jan 22, 2025

There are different styles in the codebase, even in a single source file, is it possible and worthy to force same style by ArchUnit?

Nested/Collection/Map configuration property

  1. implicit initialized with null and expose getter and setter
  2. explicit initialized and expose getter and setter
  3. explicit initialized and mark the field as final (no setter)

I vote for option 2, and it is more common in the codebase.

Set/Map configuration property

  1. initialized with HashSet/HashMap
  2. initialized with LinkedHashSet/LinkedHashMap

I think option 2 is meaningless since the Binder will create ordered Set/Map.

@quaff quaff changed the title About style of Nested/Collection/Map properties in @Configuration class About style of Nested/Collection/Map properties in @ConfigurationProperties class Jan 22, 2025
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 22, 2025
@philwebb
Copy link
Member

Although not technically public API, we have seen folks use configuration properties outside of the Binder. As such, I think I'd be in favor of option 2 in both cases. That should allow the most flexibility.

@philwebb philwebb changed the title About style of Nested/Collection/Map properties in @ConfigurationProperties class Use consistent style for Nested/Collection/Map properties in @ConfigurationProperties Jan 24, 2025
@philwebb philwebb added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 24, 2025
@philwebb philwebb added this to the 3.x milestone Jan 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants