doc / ch.tutteli.atrium.creating / DownCastBuilder

DownCastBuilder

class DownCastBuilder<out T : Any, out TSub : T> (source)

A builder for creating a down-casting IAssertion.

Or in other words, helps to make an assertion about IAssertionPlant.subject that it can be down-casted to subType.

Constructors

<init> DownCastBuilder(description: String, subType: KClass<TSub>, commonFields: CommonFields<T?>)

Functions

cast fun cast(): IAssertionPlant<TSub>

Performs the down-cast if possible; reports a failure otherwise.

withLazyAssertions fun withLazyAssertions(createAssertions: IAssertionPlant<TSub>.() -> Unit): DownCastBuilder<T, TSub>

Use this method if you want to add several assertions which are checked lazily after the down cast is performed.

withNullRepresentation fun withNullRepresentation(representation: String): DownCastBuilder<T, TSub>

Use this method if you want to use your own null representation in error reporting (default is RawString.NULL).