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

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(@NonNull NavType<@NonNull T> type)

Set the type of the argument.

Public constructors

Builder

public final Builder()

Public methods

build

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

the newly constructed NavArgument.

setDefaultValue

@NonNull
public final NavArgument.Builder setDefaultValue(@Nullable 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
@Nullable Object defaultValue

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

Returns
NavArgument.Builder

This builder.

setIsNullable

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

This builder.

setType

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

Set the type of the argument.

Parameters
@NonNull NavType<@NonNull T> type

Type of the argument.

Returns
NavArgument.Builder

This builder.