net.jqwik.engine.execution.DefaultPropertyLifecycleContext 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.api.lifecycle.*;
import net.jqwik.api.lifecycle.ResolveParameterHook.*;
import net.jqwik.engine.descriptor.*;
import net.jqwik.engine.execution.lifecycle.*;
import net.jqwik.engine.support.*;
public class DefaultPropertyLifecycleContext extends AbstractLifecycleContext implements PropertyLifecycleContext {
private final PropertyMethodDescriptor methodDescriptor;
private final ContainerInstances testInstances;
private final ParameterSupplierResolver parameterSupplierResolver;
public DefaultPropertyLifecycleContext(
PropertyMethodDescriptor methodDescriptor,
Object testInstance,
Reporter reporter,
ResolveParameterHook resolveParameterHook
) {
this(methodDescriptor, new ContainerInstances(testInstance), reporter, resolveParameterHook);
}
public DefaultPropertyLifecycleContext(
PropertyMethodDescriptor methodDescriptor,
ContainerInstances testInstances,
Reporter reporter,
ResolveParameterHook resolveParameterHook
) {
super(reporter, methodDescriptor);
this.parameterSupplierResolver = new ParameterSupplierResolver(resolveParameterHook, this);
this.methodDescriptor = methodDescriptor;
this.testInstances = testInstances;
}
@Override
public Method targetMethod() {
return methodDescriptor.getTargetMethod();
}
@Override
public Class> containerClass() {
return methodDescriptor.getContainerClass();
}
@Override
public Optional optionalElement() {
return Optional.of(targetMethod());
}
@Override
public Optional> optionalContainerClass() {
return Optional.of(containerClass());
}
@Override
public Object testInstance() {
return testInstances.target();
}
@Override
public List