MutableCreationExtras


public final class MutableCreationExtras extends CreationExtras


A modifiable CreationExtras that holds pairs of CreationExtras.Key and Any, allowing efficient value retrieval for each key.

Each key in CreationExtras is unique, storing only one value per key.

See also
CreationExtras

Summary

Public constructors

Constructs a MutableCreationExtras containing the elements of the specified initialExtras, in the order they are returned by the CreationExtras's iterator.

Public methods

T
<T extends Object> get(@NonNull CreationExtras.Key<@NonNull T> key)

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

final void
<T extends Object> set(@NonNull CreationExtras.Key<@NonNull T> key, @NonNull T t)

Associates the specified t with the specified key in this CreationExtras.

Extension functions

final void
CreationExtrasKt.plusAssign(
    @NonNull MutableCreationExtras receiver,
    @NonNull CreationExtras creationExtras
)

Appends or replaces all entries from the given creationExtras in this mutable extras.

Inherited methods

From androidx.lifecycle.viewmodel.CreationExtras
boolean
equals(Object other)

Compares the specified object with this CreationExtras for equality.

int

Returns the hash code value for this CreationExtras.

@NonNull String

Returns a string representation of this CreationExtras.

Public constructors

MutableCreationExtras

Added in 2.5.0
public MutableCreationExtras(@NonNull CreationExtras initialExtras)

Constructs a MutableCreationExtras containing the elements of the specified initialExtras, in the order they are returned by the CreationExtras's iterator.

Public methods

get

Added in 2.9.0-alpha08
public T <T extends Object> get(@NonNull CreationExtras.Key<@NonNull T> key)

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

set

Added in 2.5.0
public final void <T extends Object> set(@NonNull CreationExtras.Key<@NonNull T> key, @NonNull T t)

Associates the specified t with the specified key in this CreationExtras.

Extension functions

CreationExtrasKt.plusAssign

public final void CreationExtrasKt.plusAssign(
    @NonNull MutableCreationExtras receiver,
    @NonNull CreationExtras creationExtras
)

Appends or replaces all entries from the given creationExtras in this mutable extras.