Skip to content

Feature: new methods nextInt(Range) and nextLong(Range)#1416

Merged
kingthorin merged 2 commits intomainfrom
feature/1395-range
Oct 31, 2024
Merged

Feature: new methods nextInt(Range) and nextLong(Range)#1416
kingthorin merged 2 commits intomainfrom
feature/1395-range

Conversation

@asolntsev
Copy link
Collaborator

@asolntsev asolntsev commented Oct 31, 2024

Does the API look good?
I mean, these names are quite long (but explicit):

randomService.nextInt(Range.inclusive(2, 4));  // 2, 3, 4
randomService.nextInt(Range.inclusiveExclusive(2, 5)); // 2, 3, 4
randomService.nextLong(Range.exclusiveInclusive(2L, 5L)); // 3L, 4L, 5L
randomService.nextLong(Range.exclusive(2L, 5L)); // 3L, 4L

@asolntsev asolntsev linked an issue Oct 31, 2024 that may be closed by this pull request
@asolntsev asolntsev self-assigned this Oct 31, 2024
@asolntsev asolntsev added the enhancement New feature or request label Oct 31, 2024
@codecov
Copy link

codecov bot commented Oct 31, 2024

Codecov Report

Attention: Patch coverage is 95.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 92.30%. Comparing base (d5f4ffb) to head (47a9d0c).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...main/java/net/datafaker/providers/base/Number.java 83.33% 1 Missing ⚠️
...main/java/net/datafaker/service/RandomService.java 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1416      +/-   ##
============================================
+ Coverage     92.21%   92.30%   +0.09%     
- Complexity     3149     3168      +19     
============================================
  Files           319      320       +1     
  Lines          6149     6173      +24     
  Branches        591      592       +1     
============================================
+ Hits           5670     5698      +28     
+ Misses          334      333       -1     
+ Partials        145      142       -3     

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

to define explicitly if the min/max should be inclusive or exclusive
there is no point to call `randomNumber(strict = false)`. It's the same as just `faker.random().nextLong()`.
Copy link
Collaborator

@kingthorin kingthorin left a comment

Choose a reason for hiding this comment

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

I wish it followed Java naming standards but it isn't worth arguing about. Nice work!

@bodiam
Copy link
Contributor

bodiam commented Oct 31, 2024

I like it! Nice work!

@kingthorin kingthorin merged commit 6f00a78 into main Oct 31, 2024
@kingthorin kingthorin deleted the feature/1395-range branch October 31, 2024 14:56
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.

inconsistent behaviour of nextInt and nextLong

3 participants