Registry

open class Registry<T : Any>(modifiable: Boolean = false)

A basic string to object registry.

Inheritors

Constructors

Link copied to clipboard
constructor(modifiable: Boolean = false)

Properties

Link copied to clipboard
val defaultValue: T? = null

The default value of this registry.

Link copied to clipboard
val size: Int

The amount of registered entries in this registry.

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun firstOrNull(predicate: (T) -> Boolean): T?

Filters the entries list to the given predicate.

Link copied to clipboard
fun forEach(block: (T) -> Unit)

Performs block on every registered entry.

Link copied to clipboard
fun forEachEntry(block: (String, T) -> Unit)

Performs block on every registered entry.

Link copied to clipboard
operator fun get(index: Int): T?
operator fun get(key: String): T?
Link copied to clipboard
fun getKey(entry: T): String?
Link copied to clipboard
fun indexOf(entry: T): Int
Link copied to clipboard
fun random(random: Random = Random, filter: (T) -> Boolean? = null): T?

Returns a random entry of the registry.

Link copied to clipboard
fun register(key: String, entry: T): T

Registers entry to the registry under key.