doc / ch.tutteli.atrium.domain.creating.collectors / AssertionCollector / collectOrExplain

collectOrExplain

open fun <T : Any> collectOrExplain(safeToCollect: Boolean, warningCannotEvaluate: Translatable, plant: AssertionPlant<T>, assertionCreator: CollectingAssertionPlant<T>.() -> Unit): AssertionGroup (source)

Depending on the given safeToCollect it either AssertionCollector.collects the assertions the given assertionCreator might create or it uses it to create an AssertionGroup with an ExplanatoryAssertionGroupType.

Parameters

safeToCollect - Indicates whether it is safe to use the AssertionPlant.subjectProvider (means it does not throw a PlantHasNoSubjectException if called)

warningCannotEvaluate - The translatable used to explain why the assertions could not be evaluated.

plant - The plant from which the AssertionPlant.subject will be used as subject of the CollectingAssertionPlant.

assertionCreator - A lambda which typically creates a sub AssertionPlant and adds assertions to it. For instance, if you create a feature assertion or a type transformation assertion, you will typically end up creating a sub assertion plant which delegates created Assertions to the CollectingAssertionPlant.

open fun <T : Any> collectOrExplain(safeToCollect: Boolean, warningCannotEvaluate: Translatable, subjectProvider: () -> T, assertionCreator: CollectingAssertionPlant<T>.() -> Unit): AssertionGroup (source)

Depending on the given safeToCollect it either AssertionCollector.collects the assertions the given assertionCreator might create or it uses it to create an AssertionGroup with an ExplanatoryAssertionGroupType.

Parameters

safeToCollect - Indicates whether it is safe to use the subjectProvider (means it does not throw a PlantHasNoSubjectException if called)

warningCannotEvaluate - The translatable used to explain why the assertions could not be evaluated.

subjectProvider - Provides the subject which is used as CollectingAssertionPlant.subject.

assertionCreator - A lambda which typically creates a sub AssertionPlant and adds assertions to it. For instance, if you create a feature assertion or a type transformation assertion, you will typically end up creating a sub assertion plant which delegates created Assertions to the CollectingAssertionPlant.

abstract fun <T, A : BaseAssertionPlant<T, A>, C : BaseCollectingAssertionPlant<T, A, C>> collectOrExplain(safeToCollect: Boolean, warningCannotEvaluate: Translatable, subjectProvider: () -> T, collectingPlantFactory: (() -> T) -> C, assertionCreator: C.() -> Unit): AssertionGroup (source)

Depending on the given safeToCollect it either AssertionCollector.collects the assertions the given assertionCreator might create or it uses it to create an AssertionGroup with an ExplanatoryAssertionGroupType.

Parameters

safeToCollect - Indicates whether it is safe to use the subjectProvider (means it does not throw a PlantHasNoSubjectException)

warningCannotEvaluate - The Translatable used to explain why the assertions could not be evaluated.

subjectProvider - Provides the subject which is used as BaseCollectingAssertionPlant.subject.

collectingPlantFactory - The factory method which creates the appropriate collecting plant which is suitable for the given assertionCreator.

assertionCreator - A lambda which typically creates a sub AssertionPlant and adds assertions to it. For instance, if you create a feature assertion or a type transformation assertion, you will typically end up creating a sub assertion plant which delegates created Assertions to the BaseCollectingAssertionPlant.