DefaultBoundEntry

open class DefaultBoundEntry<P : Any, C : Any>(container: PersistentDataContainer, key: String, type: PersistentDataType<P, C>, val defaultValue: () -> C) : BoundEntry<P, C> (source)

Represents a bound entry with a default value for a key in a PersistentDataContainer.

This class extends BoundEntry and adds functionality to retrieve a value with a specified default value when the key does not exist in the container.

The default value is provided as a lambda to ensure it is lazily evaluated and only invoked when required.

Author

Fantamomo

Since

3.2-SNAPSHOT

Parameters

P

The primitive data type.

C

The complex data type.

Inheritors

Constructors

Link copied to clipboard
constructor(container: PersistentDataContainer, key: String, type: PersistentDataType<P, C>, defaultValue: () -> C)

Properties

Link copied to clipboard
val defaultValue: () -> C

A lambda function that provides the default value if the key does not exist.

Link copied to clipboard
val key: String

The key associated with the value in the container.

Link copied to clipboard

The type used to serialize/deserialize the value.

Functions

Link copied to clipboard
open override fun get(): C

Retrieves the value associated with the specified key and type from the container.

Link copied to clipboard
open operator override fun getValue(thisRef: Any?, property: KProperty<*>): C

Retrieves the value associated with the given key and type from the container.