Skip to content

[Allow the randomizer override by order]  #516

@trinhnx

Description

@trinhnx

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions