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

net.jqwik.engine.providers.ArrayArbitraryProvider Maven / Gradle / Ivy

There is a newer version: 1.9.1
Show newest version
package net.jqwik.engine.providers;

import java.util.*;
import java.util.stream.*;

import net.jqwik.api.*;
import net.jqwik.api.providers.*;

public class ArrayArbitraryProvider implements ArbitraryProvider {
	@Override
	public boolean canProvideFor(TypeUsage targetType) {
		return targetType.isArray();
	}

	@Override
	public Set> provideFor(TypeUsage targetType, SubtypeProvider subtypeProvider) {
		TypeUsage componentType = targetType.getComponentType().orElse(TypeUsage.forType(Object.class));
		return subtypeProvider.apply(componentType) //
			.stream() //
			.map(elementArbitrary -> elementArbitrary.array(targetType.getRawType())) //
			.collect(Collectors.toSet());
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy