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

downCast

fun downCast(description: ITranslatable, subType: KClass<TSub>, subjectPlant: IBaseAssertionPlant<T?, *>, assertionCreator: IAssertionPlant<TSub>.() -> Unit): Unit

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

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

Parameters

description - The description of the resulting IBasicAssertion. 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 failureHandler.