ActionParameters
abstract class ActionParameters
MutableActionParameters |
Mutable version of |
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 |
|---|
class ActionParameters.Key<T : Any>Key for |
class ActionParameters.Pair<T : Any>Key Value pairs for Parameters. |
Public functions |
|
|---|---|
abstract Map<ActionParameters.Key<Any>, Any> |
asMap()Retrieves a map of all key value pairs. |
abstract operator Boolean |
<T : Any> contains(key: ActionParameters.Key<T>)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: T)Get a parameter with a key. |
abstract Boolean |
isEmpty()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
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
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
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 | |
|---|---|
ClassCastException |
if there is something stored with the same name as |
getOrDefault
abstract fun <T : Any> getOrDefault(key: ActionParameters.Key<T>, defaultValue: 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: T |
the default value to return if key is missing |
| Throws | |
|---|---|
ClassCastException |
if there is something stored with the same name as |
Extension functions
ActionParameters.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 |
ActionParameters.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 |