withCanvasSource

fun <T : Any, V : T> withCanvasSource(clazz: KClass<T>, obj: V): TestMosaicBuilder(source)

Adds a source to the canvas with the specified class and object. Allows for passing in a superclass as the retrieval type.

Return

This builder for method chaining

val testMosaic = mosaicBuilder()
.withCanvasSource(User::class, User("test-user"))
.withMockTile(MyTile, "test data")
.build()

Parameters

clazz

The class of the object to register

obj

The object to register


Adds a source to the canvas with the specified object.

Return

This builder for method chaining

val testMosaic = mosaicBuilder()
.withCanvasSource(User("test-user"))
.withMockTile(MyTile, "test data")
.build()

Parameters

obj

The object to register


fun <T : Any, V : T> withCanvasSource(clazz: KClass<T>, qualifier: String, obj: V): TestMosaicBuilder(source)

Adds a source to the canvas with the specified class, qualifier, and object.

Return

This builder for method chaining

val testMosaic = mosaicBuilder()
.withCanvasSource(DatabaseService::class, "primary", primaryDb)
.withCanvasSource(DatabaseService::class, "secondary", secondaryDb)
.build()

Parameters

clazz

The class of the object to register

qualifier

The qualifier to distinguish this instance

obj

The object to register


inline fun <T : Any> withCanvasSource(qualifier: String, obj: T): TestMosaicBuilder(source)

Adds a source to the canvas with the specified object and qualifier.

Return

This builder for method chaining

val testMosaic = mosaicBuilder()
.withCanvasSource("primary", primaryDb)
.withCanvasSource("secondary", secondaryDb)
.build()

Parameters

qualifier

The qualifier to distinguish this instance

obj

The object to register


Adds a source to the canvas using a CanvasKey.

Return

This builder for method chaining

val dbKey = CanvasKey(DatabaseService::class, "primary")
val testMosaic = mosaicBuilder()
.withCanvasSource(dbKey, primaryDb)
.build()

Parameters

key

The canvas key to register under

obj

The object to register