doc / ch.tutteli.atrium.assertions.any.typetransformation / DownCaster / downCast

downCast

fun downCast(description: Translatable, subType: KClass<TSub>, subjectPlant: BaseAssertionPlant<T?, *>, assertionCreator: AssertionPlant<TSub>.() -> Unit): Unit (source)
Deprecated: Use AssertImpl.any.typeTransformation.downcast; will be removed with 1.0.0

Performs the down-cast and applies the given assertionCreator to the down-casted subject of subjectPlant if successful or passes it to a AnyTypeTransformation.TypeTransformationFailureHandler otherwise.

It also adds a DescriptiveAssertion, representing the down-cast as such (succeeding or failing), to the given subjectPlant using the given description.

Parameters

description - The description of the resulting DescriptiveAssertion.

subType - The type to which the subjectPlant's subject should be down-casted.

subjectPlant - The plant to which additional assertions will be added.

assertionCreator - The lambda function which can create subsequent assertions for the down-casted subject.

Exceptions

AssertionError - Might throw an AssertionError in case the down-cast cannot be performed, depending on the subjectPlant and the defined AnyTypeTransformation.TypeTransformationFailureHandler.