ActionParameters

abstract class ActionParameters

Known direct subclasses

Action parameters, used to pass information to an Action.

Construct action parameters using actionParametersOf or mutableActionParametersOf, with typed key-value pairs. The Key class enforces typing of the values inserted.

Summary

Nested types

Key for ActionParameters values.

Key Value pairs for Parameters.

Public functions

abstract Map<ActionParameters.Key<Any>, Any>

Retrieves a map of all key value pairs.

abstract operator Boolean

Returns true if the Parameters set contains the given Key.

abstract operator T?
<T : Any> get(key: ActionParameters.Key<T>)

Get a parameter with a key.

abstract T
<T : Any> getOrDefault(
    key: ActionParameters.Key<T>,
    defaultValue: @UnsafeVariance T
)

Get a parameter with a key.

abstract Boolean

Returns whether there are any keys stored in the parameters.

Extension functions

MutableActionParameters

Gets a mutable copy of Parameters, containing all key value pairs.

ActionParameters

Gets a read-only copy of Parameters, containing all key value pairs.

Public functions

asMap

Added in 1.0.0
abstract fun asMap(): Map<ActionParameters.Key<Any>, Any>

Retrieves a map of all key value pairs. The map is unmodifiable, and attempts to mutate it will throw runtime exceptions.

Returns
Map<ActionParameters.Key<Any>, Any>

a map of all parameters in this Parameters

contains

Added in 1.0.0
abstract operator fun <T : Any> contains(key: ActionParameters.Key<T>): Boolean

Returns true if the Parameters set contains the given Key.

Parameters
key: ActionParameters.Key<T>

the key to check for

get

Added in 1.0.0
abstract operator fun <T : Any> get(key: ActionParameters.Key<T>): T?

Get a parameter with a key. If the key is not set, returns null.

Parameters
<T : Any>

the type of the parameter

key: ActionParameters.Key<T>

the key for the parameter

Throws
kotlin.ClassCastException

if there is something stored with the same name as key but it cannot be cast to T

getOrDefault

Added in 1.0.0
abstract fun <T : Any> getOrDefault(
    key: ActionParameters.Key<T>,
    defaultValue: @UnsafeVariance T
): T

Get a parameter with a key. If the key is not set, returns the provided default value.

Parameters
<T : Any>

the type of the parameter

key: ActionParameters.Key<T>

the key for the parameter

defaultValue: @UnsafeVariance T

the default value to return if key is missing

Throws
kotlin.ClassCastException

if there is something stored with the same name as key but it cannot be cast to T

isEmpty

Added in 1.0.0
abstract fun isEmpty(): Boolean

Returns whether there are any keys stored in the parameters.

Extension functions

toMutableParameters

fun ActionParameters.toMutableParameters(): MutableActionParameters

Gets a mutable copy of Parameters, containing all key value pairs. This can be used to edit the parameter data without creating a new object.

This is similar to Map.toMutableMap.

Returns
MutableActionParameters

a MutableParameters with all the same parameters as this Parameters

toParameters

fun ActionParameters.toParameters(): ActionParameters

Gets a read-only copy of Parameters, containing all key value pairs.

This is similar to Map.toMap.

Returns
ActionParameters

a copy of this Parameters