-
Notifications
You must be signed in to change notification settings - Fork 236
Description
Hi,
Im trying to implement custom RandomizerRegistry with low priority(e.g -100) in order to check if class contains builder() method.
If so construct relevant Builder class(generated by Immutable project), then populate fields within Buider class with internal EasyRandom and finally call his build() method to return original requested class to be randomized.
Everything is implemented via java reflection and it seems that works but what I found is that RegistriesRandomizerProvider goes accross all registries to check if any randomizer exists. And then returns first one.
My problem is that my registry class is always checked also when for instance String field is incoming and it could cause performance issues.
My question is why following method always evaluate all registries and not stop when first one if found?
private Randomizer<?> getRandomizer(final Provider provider) {
return registries.stream()//it should be already sorted by priority
.map(provider::getRandomizer)//it always goes for each registered registry, why not to stop loop when first one is found?
.filter(Objects::nonNull)
.sorted(priorityComparator) //what does it mean, we sort all found randomizers
.findFirst().orElse(null);
}
thanks