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

[Allow the randomizer override by order] #516

Open
trinhnx opened this issue Aug 27, 2024 · 0 comments
Open

[Allow the randomizer override by order] #516

trinhnx opened this issue Aug 27, 2024 · 0 comments

Comments

@trinhnx
Copy link

trinhnx commented Aug 27, 2024

Assume i have a pojo class

record UserProfile(String homeUrl, String imageUrl) {}

and I want to have custom url link generator for field containing url. About imageUrl then i will need another generator.
With current API, we have to use

#randomize(field -> field.contains(url) but not (imageUrl)
#randomize(field -> field contain imageUrl)

I think it will be better to keep the randomizer order registration, so just define the

#randomize(field -> field contain url)
#randomize(field -> field contain imageUrl) 

by changing customFieldRandomizersRegistry and customTypeRandomizersRegistry from HashMap to LinkedHashMap, hence when after adding, we know which one will be applied.

https://github.com/j-easy/easy-random/blob/master/src/main/java/org/jeasy/random/randomizers/registry/CustomRandomizerRegistry.java#L45-L46

  • If you are reporting a bug, the best way is to provide a failing test.
  • If you are requesting a feature, don't hesitate to explain in detail your suggestion with code examples.
  • If you have a question, please first check if there is no (closed) issue about it. You may ask your question on the Gitter channel of the project.

Many thanks upfront!

@github-staff github-staff deleted a comment from mayank785 Oct 23, 2024
@github-staff github-staff deleted a comment from mayank785 Oct 23, 2024
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

No branches or pull requests

4 participants
@trinhnx and others