SavedStateReader
value public final class SavedStateReader
An inline class that encapsulates an opaque SavedState, and provides an API for reading the platform specific state.
| See also | |
|---|---|
read |
Summary
Public methods |
|
|---|---|
final boolean |
Checks if the |
final boolean |
contentDeepEquals(@NonNull Bundle other) |
final boolean |
contentDeepEquals(@NonNull SavedState other)Checks if the two specified |
final int |
Returns a hash code based on the "deep contents" of specified |
final @NonNull String |
Returns a string representation of the contents of this |
final @NonNull IBinder |
Retrieves an |
final IBinder |
getBinderOrNull(@NonNull String key)Retrieves a |
final boolean |
getBoolean(@NonNull String key)Retrieves a |
final @NonNull boolean[] |
getBooleanArray(@NonNull String key)Retrieves a |
final boolean[] |
Retrieves a |
final Boolean |
getBooleanOrNull(@NonNull String key)Retrieves a |
final char |
Retrieves a |
final @NonNull char[] |
getCharArray(@NonNull String key)Retrieves a |
final char[] |
getCharArrayOrNull(@NonNull String key)Retrieves a |
final Character |
getCharOrNull(@NonNull String key)Retrieves a |
final @NonNull CharSequence |
getCharSequence(@NonNull String key)Retrieves a |
final @NonNull CharSequence[] |
Retrieves an |
final CharSequence[] |
Retrieves an |
final @NonNull List<@NonNull CharSequence> |
getCharSequenceList(@NonNull String key)Retrieves a |
final List<@NonNull CharSequence> |
Retrieves a |
final CharSequence |
Retrieves a |
final double |
Retrieves a |
final @NonNull double[] |
getDoubleArray(@NonNull String key)Retrieves a |
final double[] |
Retrieves a |
final Double |
getDoubleOrNull(@NonNull String key)Retrieves a |
final float |
Retrieves a |
final @NonNull float[] |
getFloatArray(@NonNull String key)Retrieves a |
final float[] |
getFloatArrayOrNull(@NonNull String key)Retrieves a |
final Float |
getFloatOrNull(@NonNull String key)Retrieves a |
final int |
Retrieves an |
final @NonNull int[] |
getIntArray(@NonNull String key)Retrieves a |
final int[] |
getIntArrayOrNull(@NonNull String key)Retrieves a |
final @NonNull List<@NonNull Integer> |
getIntList(@NonNull String key)Retrieves a |
final List<@NonNull Integer> |
getIntListOrNull(@NonNull String key)Retrieves a |
final Integer |
getIntOrNull(@NonNull String key)Retrieves an |
final @NonNull T |
<T extends Serializable> getJavaSerializable(@NonNull String key)Retrieves a |
final @NonNull T |
<T extends Serializable> getJavaSerializable(Retrieves a |
final T |
<T extends Serializable> getJavaSerializableOrNull(@NonNull String key)Retrieves a |
final T |
<T extends Serializable> getJavaSerializableOrNull(Retrieves a |
final long |
Retrieves a |
final @NonNull long[] |
getLongArray(@NonNull String key)Retrieves a |
final long[] |
getLongArrayOrNull(@NonNull String key)Retrieves a |
final Long |
getLongOrNull(@NonNull String key)Retrieves a |
final @NonNull T |
<T extends Parcelable> getParcelable(@NonNull String key)Retrieves a |
final @NonNull T |
<T extends Parcelable> getParcelable(Retrieves a |
final @NonNull T[] |
<T extends Parcelable> getParcelableArray(@NonNull String key)Retrieves an |
final @NonNull T[] |
<T extends Parcelable> getParcelableArray(Retrieves an |
final T[] |
<T extends Parcelable> getParcelableArrayOrNull(@NonNull String key)Retrieves an |
final T[] |
<T extends Parcelable> getParcelableArrayOrNull(Retrieves an |
final @NonNull List<@NonNull T> |
<T extends Parcelable> getParcelableList(@NonNull String key)Retrieves a |
final @NonNull List<@NonNull T> |
<T extends Parcelable> getParcelableList(Retrieves a |
final List<@NonNull T> |
<T extends Parcelable> getParcelableListOrNull(@NonNull String key)Retrieves a |
final List<@NonNull T> |
<T extends Parcelable> getParcelableListOrNull(Retrieves a |
final T |
<T extends Parcelable> getParcelableOrNull(@NonNull String key)Retrieves a |
final T |
<T extends Parcelable> getParcelableOrNull(Retrieves a |
final @NonNull SavedState |
getSavedState(@NonNull String key)Retrieves a |
final @NonNull SavedState[] |
getSavedStateArray(@NonNull String key)Retrieves an |
final SavedState[] |
Retrieves an |
final @NonNull List<@NonNull SavedState> |
getSavedStateList(@NonNull String key)Retrieves a |
final List<@NonNull SavedState> |
Retrieves a |
final SavedState |
getSavedStateOrNull(@NonNull String key)Retrieves a |
final @NonNull Size |
Retrieves a |
final @NonNull SizeF |
Retrieves a |
final SizeF |
getSizeFOrNull(@NonNull String key)Retrieves a |
final Size |
getSizeOrNull(@NonNull String key)Retrieves a |
final @NonNull SparseArray<@NonNull T> |
<T extends Parcelable> getSparseParcelableArray(@NonNull String key)Retrieves a |
final @NonNull SparseArray<@NonNull T> |
<T extends Parcelable> getSparseParcelableArray(Retrieves a |
final SparseArray<@NonNull T> |
<T extends Parcelable> getSparseParcelableArrayOrNull(@NonNull String key)Retrieves a |
final SparseArray<@NonNull T> |
<T extends Parcelable> getSparseParcelableArrayOrNull(Retrieves a |
final @NonNull String |
Retrieves a |
final @NonNull String[] |
getStringArray(@NonNull String key)Retrieves an |
final String[] |
Retrieves an |
final @NonNull List<@NonNull String> |
getStringList(@NonNull String key)Retrieves a |
final List<@NonNull String> |
getStringListOrNull(@NonNull String key)Retrieves a |
final String |
getStringOrNull(@NonNull String key)Retrieves a |
final boolean |
isEmpty()Checks if the |
final boolean |
Checks if the |
final int |
size()Returns the number of key-value pairs in the |
final @NonNull Map<@NonNull String, Object> |
toMap()Returns a new |
Public methods
contains
public final boolean contains(@NonNull String key)
Checks if the SavedState contains the specified key.
| Returns | |
|---|---|
boolean |
|
contentDeepEquals
public final boolean contentDeepEquals(@NonNull SavedState other)
Checks if the two specified SavedState are deeply equal to one another.
Two SavedState are considered deeply equal if they have the same size, and elements at corresponding keys are deeply equal. That is, if two corresponding elements are nested SavedState, they are also compared deeply.
If any of SavedState contains itself on any nesting level the behavior is undefined.
| Parameters | |
|---|---|
@NonNull SavedState other |
the object to compare deeply with this. |
| Returns | |
|---|---|
boolean |
|
contentDeepHashCode
public final int contentDeepHashCode()
Returns a hash code based on the "deep contents" of specified SavedState. If the SavedState contains other SavedState as elements, the hash code is based on their contents and so on.
The computation of the hash code returned is as if the SavedState is a List. Nested SavedState are treated as lists too.
If any of SavedState contains itself on any nesting level the behavior is undefined.
| Returns | |
|---|---|
int |
a deep-content-based hash code for |
contentDeepToString
public final @NonNull String contentDeepToString()
Returns a string representation of the contents of this SavedState as if it is a List. Nested SavedState are treated as lists too.
If any of SavedState contains itself on any nesting level that reference is rendered as "[...]" to prevent recursion.
getBinder
public final @NonNull IBinder getBinder(@NonNull String key)
Retrieves an IBinder value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getBinderOrNull
public final IBinder getBinderOrNull(@NonNull String key)
Retrieves a IBinder value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
getBoolean
public final boolean getBoolean(@NonNull String key)
Retrieves a Boolean value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
boolean |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getBooleanArray
public final @NonNull boolean[] getBooleanArray(@NonNull String key)
Retrieves a BooleanArray value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getBooleanArrayOrNull
public final boolean[] getBooleanArrayOrNull(@NonNull String key)
Retrieves a BooleanArray value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
boolean[] |
The value associated with the |
getBooleanOrNull
public final Boolean getBooleanOrNull(@NonNull String key)
Retrieves a Boolean value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
Note: This method returns a nullable primitive, causing auto-boxing on JVM targets.
getChar
public final char getChar(@NonNull String key)
Retrieves a Char value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
char |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getCharArray
public final @NonNull char[] getCharArray(@NonNull String key)
Retrieves a CharSequence value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getCharArrayOrNull
public final char[] getCharArrayOrNull(@NonNull String key)
Retrieves a CharArray value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
char[] |
The value associated with the |
getCharOrNull
public final Character getCharOrNull(@NonNull String key)
Retrieves a Char value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
Note: This method returns a nullable primitive, causing auto-boxing on JVM targets.
getCharSequence
public final @NonNull CharSequence getCharSequence(@NonNull String key)
Retrieves a CharSequence value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
@NonNull CharSequence |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getCharSequenceArray
public final @NonNull CharSequence[] getCharSequenceArray(@NonNull String key)
Retrieves an Array of CharSequence values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getCharSequenceArrayOrNull
public final CharSequence[] getCharSequenceArrayOrNull(@NonNull String key)
Retrieves an Array of CharSequence values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
CharSequence[] |
The values associated with the |
getCharSequenceList
public final @NonNull List<@NonNull CharSequence> getCharSequenceList(@NonNull String key)
Retrieves a List of CharSequence values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
@NonNull List<@NonNull CharSequence> |
The values associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getCharSequenceListOrNull
public final List<@NonNull CharSequence> getCharSequenceListOrNull(@NonNull String key)
Retrieves a List of CharSequence values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
List<@NonNull CharSequence> |
The values associated with the |
getCharSequenceOrNull
public final CharSequence getCharSequenceOrNull(@NonNull String key)
Retrieves a CharSequence value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
Note: This method returns a nullable primitive, causing auto-boxing on JVM targets.
| Returns | |
|---|---|
CharSequence |
The value associated with the |
getDouble
public final double getDouble(@NonNull String key)
Retrieves a Double value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
double |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getDoubleArray
public final @NonNull double[] getDoubleArray(@NonNull String key)
Retrieves a DoubleArray value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getDoubleArrayOrNull
public final double[] getDoubleArrayOrNull(@NonNull String key)
Retrieves a DoubleArray value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
double[] |
The value associated with the |
getDoubleOrNull
public final Double getDoubleOrNull(@NonNull String key)
Retrieves a Double value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
Note: This method returns a nullable primitive, causing auto-boxing on JVM targets.
getFloat
public final float getFloat(@NonNull String key)
Retrieves a Float value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
float |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getFloatArray
public final @NonNull float[] getFloatArray(@NonNull String key)
Retrieves a FloatArray value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getFloatArrayOrNull
public final float[] getFloatArrayOrNull(@NonNull String key)
Retrieves a FloatArray value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
float[] |
The value associated with the |
getFloatOrNull
public final Float getFloatOrNull(@NonNull String key)
Retrieves a Float value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
Note: This method returns a nullable primitive, causing auto-boxing on JVM targets.
getInt
public final int getInt(@NonNull String key)
Retrieves an Int value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
int |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getIntArray
public final @NonNull int[] getIntArray(@NonNull String key)
Retrieves a IntArray value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getIntArrayOrNull
public final int[] getIntArrayOrNull(@NonNull String key)
Retrieves a IntArray value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
int[] |
The value associated with the |
getIntList
public final @NonNull List<@NonNull Integer> getIntList(@NonNull String key)
Retrieves a List of String values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getIntListOrNull
public final List<@NonNull Integer> getIntListOrNull(@NonNull String key)
Retrieves a List of Int values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
getIntOrNull
public final Integer getIntOrNull(@NonNull String key)
Retrieves an Int value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
Note: This method returns a nullable primitive, causing auto-boxing on JVM targets.
getJavaSerializable
public final @NonNull T <T extends Serializable> getJavaSerializable(@NonNull String key)
Retrieves a Serializable value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Serializable> |
The expected type of the value. |
@NonNull String key |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getJavaSerializable
public final @NonNull T <T extends Serializable> getJavaSerializable(
@NonNull String key,
@NonNull KClass<@NonNull T> serializableClass
)
Retrieves a Serializable value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
@NonNull String key |
The |
@NonNull KClass<@NonNull T> serializableClass |
The expected type of the value. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getJavaSerializableOrNull
public final T <T extends Serializable> getJavaSerializableOrNull(@NonNull String key)
Retrieves a Serializable value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Serializable> |
The expected type of the value. |
@NonNull String key |
The |
| Returns | |
|---|---|
T |
The value associated with the |
getJavaSerializableOrNull
public final T <T extends Serializable> getJavaSerializableOrNull(
@NonNull String key,
@NonNull KClass<@NonNull T> serializableClass
)
Retrieves a Serializable value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
@NonNull String key |
The |
@NonNull KClass<@NonNull T> serializableClass |
The expected type of the value. |
| Returns | |
|---|---|
T |
The value associated with the |
getLong
public final long getLong(@NonNull String key)
Retrieves a Long value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
long |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getLongArray
public final @NonNull long[] getLongArray(@NonNull String key)
Retrieves a LongArray value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getLongArrayOrNull
public final long[] getLongArrayOrNull(@NonNull String key)
Retrieves a LongArray value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
long[] |
The value associated with the |
getLongOrNull
public final Long getLongOrNull(@NonNull String key)
Retrieves a Long value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
Note: This method returns a nullable primitive, causing auto-boxing on JVM targets.
getParcelable
public final @NonNull T <T extends Parcelable> getParcelable(@NonNull String key)
Retrieves a Parcelable value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Parcelable> |
The expected type of the value. |
@NonNull String key |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getParcelable
public final @NonNull T <T extends Parcelable> getParcelable(
@NonNull String key,
@NonNull KClass<@NonNull T> parcelableClass
)
Retrieves a Parcelable value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
@NonNull String key |
The |
@NonNull KClass<@NonNull T> parcelableClass |
The expected type of the value. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getParcelableArray
public final @NonNull T[] <T extends Parcelable> getParcelableArray(@NonNull String key)
Retrieves an Array of Parcelable values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Parcelable> |
The expected type of the values. |
@NonNull String key |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getParcelableArray
public final @NonNull T[] <T extends Parcelable> getParcelableArray(
@NonNull String key,
@NonNull KClass<@NonNull T> parcelableClass
)
Retrieves an Array of Parcelable values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
@NonNull String key |
The |
@NonNull KClass<@NonNull T> parcelableClass |
The expected type of the values. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getParcelableArrayOrNull
public final T[] <T extends Parcelable> getParcelableArrayOrNull(@NonNull String key)
Retrieves an Array of Parcelable values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Parcelable> |
The expected type of the values. |
@NonNull String key |
The |
| Returns | |
|---|---|
T[] |
The values associated with the |
getParcelableArrayOrNull
public final T[] <T extends Parcelable> getParcelableArrayOrNull(
@NonNull String key,
@NonNull KClass<@NonNull T> parcelableClass
)
Retrieves an Array of Parcelable values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
@NonNull String key |
The |
@NonNull KClass<@NonNull T> parcelableClass |
The expected type of the values. |
| Returns | |
|---|---|
T[] |
The values associated with the |
getParcelableList
public final @NonNull List<@NonNull T> <T extends Parcelable> getParcelableList(@NonNull String key)
Retrieves a List of Parcelable values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Parcelable> |
The expected type of the values. |
@NonNull String key |
The |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getParcelableList
public final @NonNull List<@NonNull T> <T extends Parcelable> getParcelableList(
@NonNull String key,
@NonNull KClass<@NonNull T> parcelableClass
)
Retrieves a List of Parcelable values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
@NonNull String key |
The |
@NonNull KClass<@NonNull T> parcelableClass |
The expected type of the values. |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getParcelableListOrNull
public final List<@NonNull T> <T extends Parcelable> getParcelableListOrNull(@NonNull String key)
Retrieves a List of Parcelable values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Parcelable> |
The expected type of the values. |
@NonNull String key |
The |
getParcelableListOrNull
public final List<@NonNull T> <T extends Parcelable> getParcelableListOrNull(
@NonNull String key,
@NonNull KClass<@NonNull T> parcelableClass
)
Retrieves a List of Parcelable values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
getParcelableOrNull
public final T <T extends Parcelable> getParcelableOrNull(@NonNull String key)
Retrieves a Parcelable value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Parcelable> |
The expected type of the value. |
@NonNull String key |
The |
| Returns | |
|---|---|
T |
The value associated with the |
getParcelableOrNull
public final T <T extends Parcelable> getParcelableOrNull(
@NonNull String key,
@NonNull KClass<@NonNull T> parcelableClass
)
Retrieves a Parcelable value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
@NonNull String key |
The |
@NonNull KClass<@NonNull T> parcelableClass |
The expected type of the value. |
| Returns | |
|---|---|
T |
The value associated with the |
getSavedState
public final @NonNull SavedState getSavedState(@NonNull String key)
Retrieves a SavedState value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
@NonNull SavedState |
The value associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getSavedStateArray
public final @NonNull SavedState[] getSavedStateArray(@NonNull String key)
Retrieves an Array of SavedState values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getSavedStateArrayOrNull
public final SavedState[] getSavedStateArrayOrNull(@NonNull String key)
Retrieves an Array of SavedState values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
SavedState[] |
The values associated with the |
getSavedStateList
public final @NonNull List<@NonNull SavedState> getSavedStateList(@NonNull String key)
Retrieves a List of SavedState values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
@NonNull List<@NonNull SavedState> |
The values associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getSavedStateListOrNull
public final List<@NonNull SavedState> getSavedStateListOrNull(@NonNull String key)
Retrieves a List of SavedState values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
List<@NonNull SavedState> |
The values associated with the |
getSavedStateOrNull
public final SavedState getSavedStateOrNull(@NonNull String key)
Retrieves a SavedState value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
SavedState |
The value associated with the |
getSize
public final @NonNull Size getSize(@NonNull String key)
Retrieves a Size value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getSizeF
public final @NonNull SizeF getSizeF(@NonNull String key)
Retrieves a SizeF value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getSizeFOrNull
public final SizeF getSizeFOrNull(@NonNull String key)
Retrieves a SizeF value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
getSizeOrNull
public final Size getSizeOrNull(@NonNull String key)
Retrieves a Size value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
getSparseParcelableArray
public final @NonNull SparseArray<@NonNull T> <T extends Parcelable> getSparseParcelableArray(@NonNull String key)
Retrieves a SparseArray of Parcelable values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Parcelable> |
The expected type of the values. |
@NonNull String key |
The |
| Returns | |
|---|---|
@NonNull SparseArray<@NonNull T> |
The values associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getSparseParcelableArray
public final @NonNull SparseArray<@NonNull T> <T extends Parcelable> getSparseParcelableArray(
@NonNull String key,
@NonNull KClass<@NonNull T> parcelableClass
)
Retrieves a SparseArray of Parcelable values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
@NonNull String key |
The |
@NonNull KClass<@NonNull T> parcelableClass |
The expected type of the values. |
| Returns | |
|---|---|
@NonNull SparseArray<@NonNull T> |
The values associated with the |
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getSparseParcelableArrayOrNull
public final SparseArray<@NonNull T> <T extends Parcelable> getSparseParcelableArrayOrNull(@NonNull String key)
Retrieves a Array of Parcelable values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
<T extends Parcelable> |
The expected type of the values. |
@NonNull String key |
The |
| Returns | |
|---|---|
SparseArray<@NonNull T> |
The values associated with the |
getSparseParcelableArrayOrNull
public final SparseArray<@NonNull T> <T extends Parcelable> getSparseParcelableArrayOrNull(
@NonNull String key,
@NonNull KClass<@NonNull T> parcelableClass
)
Retrieves a Array of Parcelable values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Parameters | |
|---|---|
@NonNull String key |
The |
@NonNull KClass<@NonNull T> parcelableClass |
The expected type of the values. |
| Returns | |
|---|---|
SparseArray<@NonNull T> |
The values associated with the |
getString
public final @NonNull String getString(@NonNull String key)
Retrieves a String value associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getStringArray
public final @NonNull String[] getStringArray(@NonNull String key)
Retrieves an Array of String values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getStringArrayOrNull
public final String[] getStringArrayOrNull(@NonNull String key)
Retrieves an Array of String values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Returns | |
|---|---|
String[] |
The values associated with the |
getStringList
public final @NonNull List<@NonNull String> getStringList(@NonNull String key)
Retrieves a List of String values associated with the specified key, or throws an IllegalArgumentException if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
| Throws | |
|---|---|
kotlin.IllegalArgumentException |
If the |
kotlin.IllegalArgumentException |
If associated value is |
kotlin.IllegalArgumentException |
if associated value has wrong type. |
getStringListOrNull
public final List<@NonNull String> getStringListOrNull(@NonNull String key)
Retrieves a List of String values associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
getStringOrNull
public final String getStringOrNull(@NonNull String key)
Retrieves a String value associated with the specified key, or null if this SavedState does not contain a valid value for the key.
More specifically, a SavedState is considered to contain a valid value for a key if the key exists, the associated value is not null, and it is of the expected type.
isEmpty
public final boolean isEmpty()
Checks if the SavedState is empty (contains no key-value pairs).
| Returns | |
|---|---|
boolean |
|
isNull
public final boolean isNull(@NonNull String key)
Checks if the SavedState contains a null reference for the specified key.
| Returns | |
|---|---|
boolean |
|
size
public final int size()
Returns the number of key-value pairs in the SavedState.
| Returns | |
|---|---|
int |
The size of the |
toMap
public final @NonNull Map<@NonNull String, Object> toMap()
Returns a new Map containing all key-value pairs from the SavedState.
The returned Map does not preserve the entry iteration order of the SavedState.
IMPORTANT: All values will be copied by reference, and values within the SavedState that are also a SavedState will NOT be converted to a Map.