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

DownCaster

class DownCaster<T : Any, TSub : T>

Helps to make an assertion about the IBaseAssertionPlant.subject, that it is of type T and can be down-casted to type TSub.

Parameters

T - The type of IBaseAssertionPlant.subject. TSub - The type to which IBaseAssertionPlant.subject can be down-casted, hence needs to be a subtype of T.

Constructors

<init>

DownCaster(failureHandler: IDownCastFailureHandler<T, TSub>)

Helps to make an assertion about the IBaseAssertionPlant.subject, that it is of type T and can be down-casted to type TSub.

Functions

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.