DefaultPool

object DefaultPool : ObjectPool<Any>

Object Pool Design Pattern

The pool stores commonly used objects that must be created throughout the project and take a long time to build.

Example:

DefaultPool["key"] = value

Since

1.4.0

See also

Properties

Link copied to clipboard
var objects: HashMap<String, Any>
Link copied to clipboard
val size: Int

Pool size

Functions

Link copied to clipboard
fun first(): Any

Returns the first value or throws an exception if pool is empty.

Link copied to clipboard
inline fun firstOrElse(defaultValue: () -> Any): Any

Returns the first value, or the result of the defaultValue function if there was no entry.

Link copied to clipboard
fun firstOrNull(): Any?

Returns the first value, or null if this pool contains no entry.

Link copied to clipboard
operator fun get(key: String): Any

Returns the value for the given key or throws an exception if there is no such key in the pool.

Link copied to clipboard
inline fun getOrElse(key: String, defaultValue: () -> Any): Any

Returns the value for the given key, or the result of the defaultValue function if there was no entry for the given key.

Link copied to clipboard
fun getOrNull(key: String): Any?

Returns the value to which the specified key is mapped, or null if this pool contains no mapping for the key.

Link copied to clipboard
fun last(): Any

Returns the last value or throws an exception if pool is empty.

Link copied to clipboard
inline fun lastOrElse(defaultValue: () -> Any): Any

Returns the last value, or the result of the defaultValue function if there was no entry.

Link copied to clipboard
fun lastOrNull(): Any?

Returns the last value, or null if this pool contains no entry.

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

Allows to use the index operator for storing values in a pool.