NavArgument.Builder

public final class NavArgument.Builder


A builder for constructing NavArgument instances.

Summary

Public constructors

Public methods

final @NonNull NavArgument

Build the NavArgument specified by this builder.

final @NonNull NavArgument.Builder
setDefaultValue(Object defaultValue)

Specify the default value for an argument.

final @NonNull NavArgument.Builder
setIsNullable(boolean isNullable)

Specify if the argument is nullable.

final @NonNull NavArgument.Builder
<T extends Object> setType(NavType<T> type)

Set the type of the argument.

Public constructors

Builder

public final Builder()

Public methods

build

public final @NonNull NavArgument build()

Build the NavArgument specified by this builder. If the type is not set, the builder will infer the type from the default argument value. If there is no default value, the type will be unspecified.

Returns
@NonNull NavArgument

the newly constructed NavArgument.

setDefaultValue

public final @NonNull NavArgument.Builder setDefaultValue(Object defaultValue)

Specify the default value for an argument. Calling this at least once will cause the argument to have a default value, even if it is set to null.

Parameters
Object defaultValue

Default value for this argument. Must match NavType if it is specified.

Returns
@NonNull NavArgument.Builder

This builder.

setIsNullable

public final @NonNull NavArgument.Builder setIsNullable(boolean isNullable)

Specify if the argument is nullable. The NavType you set for this argument must allow nullable values.

Parameters
boolean isNullable

Argument will be nullable if true.

Returns
@NonNull NavArgument.Builder

This builder.

setType

public final @NonNull