AttributeContainer

An immutable container that holds attribute keys and their values in a type-safe manner.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Returns the set of attribute keys currently stored in this container.

Link copied to clipboard
val size: Int

Returns the number of attributes stored in this container.

Functions

Link copied to clipboard
fun containsAll(vararg keys: AttributeKey<*>): Boolean

Returns true if this container contains all of the specified keys. If no keys are specified, this returns true (vacuous truth).

Link copied to clipboard
fun containsAny(vararg keys: AttributeKey<*>): Boolean

Returns true if this container contains any of the specified keys. If no keys are specified, this returns false.

Link copied to clipboard

Returns true if this container contains the specified key.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard

Returns a new AttributeContainer containing only the attributes whose keys match the predicate.

Link copied to clipboard
operator fun <T> get(key: AttributeKey<T>): T?

Retrieves the attribute value for the specified key. If not set, it returns null.

Link copied to clipboard
fun <T> getOrDefault(key: AttributeKey<T>): T

Retrieves the attribute value for the specified key. If not set, it returns the AttributeKey.defaultValue defined in the key.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Returns true if this container contains no attributes.

Link copied to clipboard

Returns true if this container has at least one attribute.

Link copied to clipboard
operator fun <T> minus(key: AttributeKey<T>): AttributeContainer

Returns a new AttributeContainer with the specified key removed.

Link copied to clipboard
operator fun <T> plus(pair: <Error class: unknown class><AttributeKey<T>, T>): AttributeContainer

Returns a new AttributeContainer with the specified key-value pair.

Returns a new AttributeContainer containing all attributes from this and the other. If keys collide, values from other take precedence (overwrite).

fun <T> plus(key: AttributeKey<T>, value: T): AttributeContainer

Returns a new AttributeContainer with the specified key mapped to the value.