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

DownCaster

class DownCaster<T : Any, TSub : T>
Deprecated: Use AssertImpl.any.typeTransformation.downcast; will be removed with 1.0.0

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

Parameters

T - The type of BaseAssertionPlant.subject.

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

Constructors

<init>

DownCaster(failureHandler: AnyTypeTransformation.TypeTransformationFailureHandler<T, TSub>)

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

Functions

downCast

fun downCast(description: Translatable, subType: KClass<TSub>, subjectPlant: BaseAssertionPlant<T?, *>, assertionCreator: AssertionPlant<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 a AnyTypeTransformation.TypeTransformationFailureHandler otherwise.