Extras

interface Extras

An abstraction layer over Map used by MeasureContext and ChartDrawContext to store and retrieve data.

Extras are kept in memory while measuring or drawing is taking place. Afterwards, they are removed.

Inheritors

Functions

Link copied to clipboard
abstract fun clearExtras()

Removes all stored extras.

Link copied to clipboard
abstract fun <T> consumeExtra(key: Any): T

Retrieves the value of the extra with the given key, unless no such extra exists. Once the value of the extra is retrieved, the extra is removed. Use getExtra to prevent the extra from being removed.

Link copied to clipboard
open operator fun <T> get(key: Any): T

Operator function for consumeExtra.

Link copied to clipboard
abstract fun <T> getExtra(key: Any): T

Retrieves the value of the extra with the given key, unless no such extra exists.

Link copied to clipboard
fun <T : Any> Extras.getExtraOr(key: Any, block: () -> T): T

Returns the value of the extra with the given key if such an extra exists. Otherwise, returns the result of block.

Link copied to clipboard
fun <T : Any> Extras.getOrPutExtra(key: Any, block: () -> T): T

Returns the value of the extra with the given key if such an extra exists. Otherwise, returns the result of block and saves it as an extra with the given key.

Link copied to clipboard
abstract fun hasExtra(key: Any): Boolean

Checks whether an extra with the given key exists.

Link copied to clipboard
abstract fun putExtra(key: Any, value: Any)

Saves an extra.

Link copied to clipboard
open operator fun set(key: Any, value: Any)

Operator function for putExtra.