Attributes

interface Attributes

Map of attributes accessible by AttributeKey in a typed manner

Properties

allKeys

abstract val allKeys: List<AttributeKey<*>>

Returns List of all AttributeKey instances in this map

Functions

computeIfAbsent

abstract fun <T : Any> computeIfAbsent(
    key: AttributeKey<T>,
    block: () -> T
): T

Gets a value of the attribute for the specified key, or calls supplied block to compute its value

contains

abstract operator fun contains(key: AttributeKey<*>): Boolean

Checks if an attribute with the specified key exists

get

open operator fun <T : Any> get(key: AttributeKey<T>): T

Gets a value of the attribute for the specified key, or throws an exception if an attribute doesn’t exist

getOrNull

abstract fun <T : Any> getOrNull(key: AttributeKey<T>): T?

Gets a value of the attribute for the specified key, or return null if an attribute doesn’t exist

put

abstract fun <T : Any> put(
    key: AttributeKey<T>,
    value: T
): Unit

Creates or changes an attribute with the specified key using value

remove

abstract fun <T : Any> remove(key: AttributeKey<T>): Unit

Removes an attribute with the specified key

take

open fun <T : Any> take(key: AttributeKey<T>): T

Removes an attribute with the specified key and returns its current value, throws an exception if an attribute doesn’t exist

takeOrNull

open fun <T : Any> takeOrNull(key: AttributeKey<T>): T?

Removes an attribute with the specified key and returns its current value, returns null if an attribute doesn’t exist