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

Set the type of the argument.

Public constructors

Builder

Added in 1.0.0
public Builder()

Public methods

build

Added in 1.0.0
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

Added in 1.0.0
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

Added in 1.0.0
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

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

This builder.