Skip to content

Refactor Options as Selection#1885

Merged
kingthorin merged 7 commits into
datafaker-net:mainfrom
deluxe:feature/refactor-options-api
Jul 20, 2026
Merged

Refactor Options as Selection#1885
kingthorin merged 7 commits into
datafaker-net:mainfrom
deluxe:feature/refactor-options-api

Conversation

@deluxe

@deluxe deluxe commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Address #1883 by creating a whole new Selection class

@codecov-commenter

codecov-commenter commented Jul 17, 2026

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

❌ Patch coverage is 93.75000% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 92.59%. Comparing base (4455309) to head (4b87498).

Files with missing lines Patch % Lines
...ain/java/net/datafaker/providers/base/Options.java 46.66% 8 Missing ⚠️
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1885      +/-   ##
============================================
+ Coverage     92.55%   92.59%   +0.04%     
- Complexity     3562     3573      +11     
============================================
  Files           346      347       +1     
  Lines          7053     7051       -2     
  Branches        678      675       -3     
============================================
+ Hits           6528     6529       +1     
  Misses          364      364              
+ Partials        161      158       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@deluxe

deluxe commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

I first renamed subset as manyOf but settled for setOf to keep the Set reference.

@deluxe

deluxe commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

I also chose to deprecate random().nextEnum(Enum) to direct users to selection().oneOf(Enum) and help selection discoverability.

With this much of a change, i did not mark any class or method as forRemoval.

@asolntsev asolntsev added the enhancement New feature or request label Jul 20, 2026
@asolntsev asolntsev added this to the 3.0.0 milestone Jul 20, 2026

@asolntsev asolntsev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

If we all like the name faker.selection().oneOf(...), then this PR is totally fine.

* @since 0.8.0
* @deprecated Use {@link Selection} instead
*/
@Deprecated(since = "3.0.0")

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.

Should this have the forRemoval=true flag on it? And possibly on a few other spots as well?

@bodiam

bodiam commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

I left a tiny comment, not 100% sure about it, but I'd think it would make sense to mark it for removal?

@deluxe

deluxe commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

I left a tiny comment, not 100% sure about it, but I'd think it would make sense to mark it for removal?

I'm ok with it. Will do.

@bodiam

bodiam commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Thanks! Looks good to me. Anyone else feedback?

@SuppressWarnings("removal")
@Deprecated(since = "3.0.0", forRemoval = true)
default Options options() {
return getProvider(Options.class, Options::new);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Instead of suppressing the removal warning why don't we just actually use selection internally?

@deluxe deluxe Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because it will not return the same class (and Selection.class does not extend Options.class).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Right okay, sorry. Coffee needed 🙄

@deluxe

deluxe commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

Is there something left for me to do for this PR?

@kingthorin
kingthorin merged commit 0c0e3a6 into datafaker-net:main Jul 20, 2026
17 checks passed
@deluxe
deluxe deleted the feature/refactor-options-api branch July 20, 2026 19:34
@deluxe deluxe mentioned this pull request Jul 20, 2026
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.

5 participants