Skip to content

Add getProperty(propertyNamesList, defaultValue) #326

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

bact
Copy link
Collaborator

@bact bact commented May 5, 2025

Add a new method to return the value of the first found configuration property from a list of names.

Can be useful to use with deprecated names.

Add a new method to return the value of the first found configuration property from a list of names. Can be useful to use with deprecated names.

Signed-off-by: Arthit Suriyawongkul <[email protected]>
@bact bact added the enhancement New feature or request label May 5, 2025
@bact bact requested a review from goneall May 5, 2025 22:39
@bact
Copy link
Collaborator Author

bact commented May 5, 2025

With this, the code in #325 can be something like this:

List<String> properties = Arrays.asList(
    "org.spdx.useJARLicenseInfoOnly",
    "SPDXParser.OnlyUseLocalLicenses",
    "OnlyUseLocalLicenses");
onlyUseLocalLicenses = Boolean.parseBoolean(Configuration.getInstance().getProperty(properties, "false"));

Copy link
Member

@goneall goneall left a comment

Choose a reason for hiding this comment

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

This does improve the conciseness of the code

@goneall goneall requested a review from pmonks May 5, 2025 23:34
Signed-off-by: Arthit Suriyawongkul <[email protected]>
@pmonks
Copy link
Collaborator

pmonks commented May 6, 2025

Alternatively, v2.0 of the library may provide a good opportunity to do some spring cleaning and remove the old / deprecated property names (making sure to mention this in the upgrade readme). v2.0 already breaks backwards compatibility in other ways, so I don't think this is unreasonable, and we may not have another opportunity to sort this out for quite some time (i.e. until v3.0 of the library).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants