NavType.EnumType

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

Object
   ↳ NavType
     ↳ NavType.SerializableType
       ↳ NavType.EnumType

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 fields

boolean

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

@NonNull String

The name of this type.

Public constructors

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

Public methods

@NonNull D

Parse a value of this type from a String.

Inherited methods

From class NavType.SerializableType
boolean
@Nullable 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

From class NavType
final @RestrictTo(value = [RestrictTo.Scope.LIBRARY_GROUP]) @NonNull D
parseAndPut(
    @NonNull Bundle bundle,
    @NonNull String key,
    @NonNull String value
)

Parse a value of this type from a String and put it in a bundle

@NonNull String

Public fields

isNullableAllowed

@NonNull
public boolean isNullableAllowed

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

Returns
boolean

Returns true if this type allows null values, false otherwise.

name

@NonNull
public @NonNull String name

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

Public constructors

EnumType

@NonNull
public final <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

parseValue

@NonNull
public D parseValue(@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
D

parsed value of the type represented by this NavType

Throws
kotlin.IllegalArgumentException

if value cannot be parsed into this type