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

Add new Number and Temporal type validations #10

Merged
merged 4 commits into from
Jan 13, 2025
Merged

Conversation

ThoSap
Copy link
Contributor

@ThoSap ThoSap commented Jan 10, 2025

This PR adds the following new types for the Number and Temporal validations:

  • Number
    • Byte (byte)
    • Short (short)
    • BigInteger
  • Temporal
    • Instant
    • LocalTime
    • OffsetTime
    • Year
    • YearMonth
    • ZonedDateTime

It also refactors the code in LessThanValueSource and BiggerThanValueSource, as

new Random().<numberType>(<numberType> randomNumberOrigin, <numberType> randomNumberBound).limit(1)

can be replaced with

new Random().<numberType>(long streamSize /* 1 */, <numberType> randomNumberOrigin, <numberType> randomNumberBound)

and doing our own bounds calculation in LessThanValueSource methods getFloatStream, getDoubleStream, getBigDecimalStream and getScaledBigDecimalStream using

new Random().doubles(1).map(d -> minValue + (maxValue - minValue) * d)

is not necessary as the following signature exists:

DoubleStream doubles(long streamSize /* 1 */, double randomNumberOrigin /* inclusive */, double randomNumberBound /* exclusive */)

@ThoSap ThoSap requested a review from SirCotare January 10, 2025 11:28
@ThoSap ThoSap self-assigned this Jan 10, 2025
Copy link
Contributor

@SirCotare SirCotare left a comment

Choose a reason for hiding this comment

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

well done! 👍

@ThoSap ThoSap merged commit f165ea4 into main Jan 13, 2025
1 check passed
@ThoSap ThoSap deleted the add-number-and-date-types branch January 13, 2025 08:05
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.

2 participants