All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.jqwik.engine.execution.CachingArbitraryResolver Maven / Gradle / Ivy

The newest version!
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 LinkedHashMap<>();

	private final 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