Skip to content

Add typed UUID generators#7

Merged
Liam-DeVoe merged 6 commits into
hegeldev:mainfrom
ivan-kripakov-m10:common-java-generators
Jun 29, 2026
Merged

Add typed UUID generators#7
Liam-DeVoe merged 6 commits into
hegeldev:mainfrom
ivan-kripakov-m10:common-java-generators

Conversation

@ivan-kripakov-m10

@ivan-kripakov-m10 ivan-kripakov-m10 commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Closes #6

- change uuids() to return java.util.UUID values
- add uuidStrings() alongside version configuration support
- default UUID generation to version 4 and validate versions in [1, 8]
- derive UUID.class via Generators.forType
- move UUID coverage into dedicated generator tests
@ivan-kripakov-m10

ivan-kripakov-m10 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor Author

noticed jacoco failure in CI, took a quick look, the problem is in the not clearly defined API for anyVersion() behaviour (doing so client can tell hegel-core to generate uuid with any version) - currently it can be done via uuids().version(null) - looks a bit awkard

while working on the fix, found hegeldev/hegel-core#140 (comment)

@Liam-DeVoe

Copy link
Copy Markdown
Member

Thanks Ivan! I made a few API changes, otherwise this looks great.

@Liam-DeVoe Liam-DeVoe merged commit 1257915 into hegeldev:main Jun 29, 2026
7 checks passed
@Liam-DeVoe

Liam-DeVoe commented Jun 29, 2026

Copy link
Copy Markdown
Member

uuids() became typed, would it still make sense to have a separate uuidStrings() generator, or would it be preferable to let clients call toString() on values produced by uuids()?

I prefer the latter, as it results in a more principled API surface

@ivan-kripakov-m10

Copy link
Copy Markdown
Contributor Author

I prefer the latter, as it results in a more principled API surface

totally agree, but I anyway decided to be a bit more conservative during making the changes because I wasn't sure about the intuition behind generating uuids as strings in the lib

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.

Add first-class UUID support to hegel-java

2 participants