net.jqwik.engine.execution.CachingArbitraryResolver Maven / Gradle / Ivy
package net.jqwik.engine.execution;
import java.lang.reflect.*;
import java.util.*;
import net.jqwik.api.*;
import net.jqwik.engine.properties.*;
import net.jqwik.engine.support.*;
// Make sure that all property parameters are only resolved once per property run
public class CachingArbitraryResolver implements ArbitraryResolver {
private final Map>> cache = new HashMap<>();
private ArbitraryResolver resolver;
public CachingArbitraryResolver(ArbitraryResolver arbitraryResolver) {
resolver = arbitraryResolver;
}
@Override
public Set> forParameter(MethodParameter parameter) {
return cache.computeIfAbsent(
parameter.getRawParameter(),
ignore -> resolver.forParameter(parameter)
);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy