public abstract class NavType<T extends Object>
Known indirect subclasses

NavType denotes the type that can be used in a NavArgument.

There are built-in NavTypes for primitive types, such as int, long, boolean, float, and strings, parcelable, and serializable classes (including Enums), as well as arrays of each supported type.

You should only use one of the static NavType instances and subclasses defined in this class.

Parameters
<T extends Object>

the type of the data that is supported by this NavType

Summary

Public fields

static final @NonNull NavType<boolean[]>

NavType for storing boolean arrays, corresponding with the "boolean[]" type in a Navigation XML file.

static final @NonNull NavType<List<@NonNull Boolean>>

NavType for storing list of Booleans.

static final @NonNull NavType<@NonNull Boolean>

NavType for storing boolean values, corresponding with the "boolean" type in a Navigation XML file.

static final @NonNull NavType<float[]>

NavType for storing float arrays, corresponding with the "float[]" type in a Navigation XML file.

static final @NonNull NavType<List<@NonNull Float>>

NavType for storing list of Floats.

static final @NonNull NavType<@NonNull Float>

NavType for storing float values, corresponding with the "float" type in a Navigation XML file.

static final @NonNull NavType<int[]>

NavType for storing integer arrays, corresponding with the "integer[]" type in a Navigation XML file.

static final @NonNull NavType<List<@NonNull Integer>>

NavType for storing list of Ints.

static final @NonNull NavType<@NonNull Integer>

NavType for storing integer values, corresponding with the "integer" type in a Navigation XML file.

static final @NonNull NavType<long[]>

NavType for storing long arrays, corresponding with the "long[]" type in a Navigation XML file.

static final @NonNull NavType<List<@NonNull Long>>

NavType for storing list of Longs.

static final @NonNull NavType<@NonNull Long>

NavType for storing long values, corresponding with the "long" type in a Navigation XML file.

static final @NonNull NavType<@NonNull Integer>

NavType for storing integer values representing resource ids, corresponding with the "reference" type in a Navigation XML file.

static final @NonNull NavType<String[]>

NavType for storing String arrays, corresponding with the "string[]" type in a Navigation XML file.

static final @NonNull NavType<List<@NonNull String>>

NavType for storing list of Strings.

static final @NonNull NavType<String>

NavType for storing String values, corresponding with the "string" type in a Navigation XML file.

Public constructors

<T extends Object> NavType(boolean isNullableAllowed)

Public fields

BoolArrayType

public static final @NonNull NavType<boolean[]> BoolArrayType

NavType for storing boolean arrays, corresponding with the "boolean[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

BoolType

public static final @NonNull NavType<@NonNull BooleanBoolType

NavType for storing boolean values, corresponding with the "boolean" type in a Navigation XML file.

Null values are not supported.

FloatArrayType

public static final @NonNull NavType<float[]> FloatArrayType

NavType for storing float arrays, corresponding with the "float[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

FloatType

public static final @NonNull NavType<@NonNull FloatFloatType

NavType for storing float values, corresponding with the "float" type in a Navigation XML file.

Null values are not supported.

IntArrayType

public static final @NonNull NavType<int[]> IntArrayType

NavType for storing integer arrays, corresponding with the "integer[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

IntType

public static final @NonNull NavType<@NonNull IntegerIntType

NavType for storing integer values, corresponding with the "integer" type in a Navigation XML file.

Null values are not supported.

LongArrayType

public static final @NonNull NavType<long[]> LongArrayType

NavType for storing long arrays, corresponding with the "long[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

LongType

public static final @NonNull NavType<@NonNull LongLongType

NavType for storing long values, corresponding with the "long" type in a Navigation XML file.

Null values are not supported. Default values for this type in Navigation XML files must always end with an 'L' suffix, e.g. app:defaultValue="123L".

ReferenceType

public static final @NonNull NavType<@NonNull IntegerReferenceType

NavType for storing integer values representing resource ids, corresponding with the "reference" type in a Navigation XML file.

Null values are not supported.

StringArrayType

public static final @NonNull NavType<String[]> StringArrayType

NavType for storing String arrays, corresponding with the "string[]" type in a Navigation XML file.

Null values are supported. Default values in Navigation XML files are not supported.

StringType

public static final @NonNull NavType<StringStringType

NavType for storing String values, corresponding with the "string" type in a Navigation XML file.

Null values are supported.

Public constructors

public <T extends Object> NavType(boolean isNullableAllowed)
Parameters
<T extends Object>

the type of the data that is supported by this NavType

boolean isNullableAllowed

whether an argument with this type can hold a null value.

Public methods

fromArgType

public static @NonNull NavType<@NonNull ?> fromArgType(String type, String packageName)

Parse an argType string into a NavType.

Parameters
String type

argType string, usually parsed from the Navigation XML file

String packageName

package name of the R file, used for parsing relative class names starting with a dot.

Returns
@NonNull NavType<@NonNull ?>

a NavType representing the type indicated by the argType string. Defaults to StringType for null.

getName

public @NonNull String getName()

The name of this type.

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

isNullableAllowed

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.

parseValue

public abstract @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 T

parsed value of the type represented by this NavType

parseValue

public @NonNullparseValue(@NonNull String value, @NonNull T 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.

By default, the given value will replace the previousValue.

Parameters
@NonNull String value

string representation of a value of this type

@NonNull T previousValue

previously parsed value of this type

Returns
@NonNull T

combined parsed value of the type represented by this NavType

serializeAsValue

public @NonNull String serializeAsValue(@NonNull T value)

Serialize a value of this NavType into a String.

By default it returns value of kotlin.toString or null if value passed in is null.

This method can be override for custom serialization implementation on types such custom NavType classes.

Note: Final output should be encoded with NavUriUtils.encode

Parameters
@NonNull T value

a value representing this NavType to be serialized into a String

valueEquals

public boolean valueEquals(@NonNull T value, @NonNull T other)

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

Parameters
@NonNull T value

the first value for comparison

@NonNull T other

the second value for comparison

Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.