doc / ch.tutteli.atrium.creating / IDownCastBuilder

IDownCastBuilder

interface IDownCastBuilder<T : Any, TSub : T>

A builder for creating a down-casting IAssertion.

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

Parameters

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

Functions

cast

abstract fun cast(): IAssertionPlant<TSub>

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

withLazyAssertions

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

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

withNullRepresentation

abstract fun withNullRepresentation(representation: String): IDownCastBuilder<T, TSub>
abstract fun withNullRepresentation(translatableRepresentation: ITranslatable): IDownCastBuilder<T, TSub>

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