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

net.jqwik.api.domains.DomainContext Maven / Gradle / Ivy

The newest version!
package net.jqwik.api.domains;

import java.util.*;

import org.apiguardian.api.*;

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

import static org.apiguardian.api.API.Status.*;

/**
 * Class that implement this interface are used to annotate property methods or containers like this:
 * {@code Domain(MyDomainContext.class)}. They must have a constructor without parameters
 * to be usable in this way.
 *
 * 

* Lifecycle: Instantiate exactly once per property, then {@linkplain #initialize(PropertyLifecycleContext)} * will be called before providers and configurators will be retrieved. *

* *

* Most implementing class will subclass {@linkplain DomainContextBase}. *

* * @see Domain * @see DomainContextBase */ @API(status = MAINTAINED, since = "1.2.0") public interface DomainContext { @API(status = INTERNAL) static DomainContext global() { return DomainContextFacade.implementation.global(); } default void setDefaultPriority(int priority) { // ignore } @API(status = MAINTAINED, since = "1.1") class Global implements DomainContext { @Override public Collection getArbitraryProviders() { return global().getArbitraryProviders(); } @Override public Collection getArbitraryConfigurators() { return global().getArbitraryConfigurators(); } } @API(status = INTERNAL) abstract class DomainContextFacade { protected static DomainContextFacade implementation; static { implementation = FacadeLoader.load(DomainContextFacade.class); } public abstract DomainContext global(); public abstract Collection getArbitraryProviders(DomainContextBase base, int priority); public abstract Collection getArbitraryConfigurators(DomainContextBase base); public abstract Collection getReportingFormats(DomainContextBase base); } Collection getArbitraryProviders(); Collection getArbitraryConfigurators(); /** * Provide additional {@linkplain SampleReportingFormat reporting formats} that are used * to format objects that are reported in property results or when using a {@linkplain Reporter}. * * @return Collection of {@linkplain SampleReportingFormat} instances */ @API(status = MAINTAINED, since = "1.6.4") default Collection getReportingFormats() { return Collections.emptySet(); } /** * This method will be called exactly once after instantiation of a given domain context class. * The call will happen before any calls to {@linkplain #getArbitraryProviders()} and {@linkplain #getArbitraryConfigurators()}. * *

* Override this message if your domain context needs access to the * {@linkplain PropertyLifecycleContext context of a property}. *

*/ @API(status = MAINTAINED, since = "1.5.4") default void initialize(PropertyLifecycleContext context) { } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy