NavType.EnumType


public final class NavType.EnumType<D extends Enum<@NonNull ?>> extends NavType.SerializableType


EnumType is used for NavArguments holding enum values.

Null values are not supported. To specify a default value in a Navigation XML file, simply use the enum constant without the class name, e.g. app:defaultValue="MONDAY".

Summary

Public constructors

<D extends Enum<@NonNull ?>> EnumType(@NonNull Class<@NonNull D> type)

Public methods

@NonNull String

The name of this type.

@NonNull D

Parse a value of this type from a String.

Inherited methods

From androidx.navigation.NavType
boolean

Check if an argument with this type can hold a null value.

@NonNull D
parseValue(@NonNull String value, @NonNull D previousValue)

Parse a value of this type from a String and then combine that parsed value with the given previousValue of the same type to provide a new value that contains both the new and previous value.

@NonNull String

Serialize a value of this NavType into a String.

@NonNull String
boolean
valueEquals(@NonNull D value, @NonNull D other)

Compares two values of type T and returns true if values are equal.

From androidx.navigation.NavType.SerializableType
boolean
equals(Object other)
D
get(@NonNull Bundle bundle, @NonNull String key)

Get a value of this type from the bundle

int
void
put(@NonNull Bundle bundle, @NonNull String key, @NonNull D value)

Put a value of this type in the bundle

Public constructors

EnumType

public <D extends Enum<@NonNull ?>> EnumType(@NonNull Class<@NonNull D> type)
Parameters
@NonNull Class<@NonNull D> type

the Enum class that is supported by this NavType

Public methods

getName

public @NonNull String getName()

The name of this type.

This is the same value that is used in Navigation XML argType attribute.

Returns
@NonNull String

name of this type

parseValue

public @NonNullparseValue(@NonNull String value)

Parse a value of this type from a String.

Parameters
@NonNull String value

string representation of a value of this type

Returns
@NonNull D

parsed value of the type represented by this NavType

Throws
kotlin.IllegalArgumentException

if value cannot be parsed into this type