NavDeepLink.Builder
public final class NavDeepLink.Builder
A builder for constructing NavDeepLink instances.
Summary
Public methods |
|
|---|---|
final @NonNull NavDeepLink |
build()Build the |
final @NonNull NavDeepLink.Builder |
Set the action for the |
final @NonNull NavDeepLink.Builder |
setMimeType(@NonNull String mimeType)Set the mimeType for the |
final @NonNull NavDeepLink.Builder |
setUriPattern(@NonNull String uriPattern)Set the uri pattern for the |
final @NonNull NavDeepLink.Builder |
<T extends Object> setUriPattern(Set the uri pattern for the |
final @NonNull NavDeepLink.Builder |
<T extends Object> setUriPattern(Set the uri pattern for the |
Public methods
build
public final @NonNull NavDeepLink build()
Build the NavDeepLink specified by this builder.
| Returns | |
|---|---|
@NonNull NavDeepLink |
the newly constructed NavDeepLink. |
setAction
public final @NonNull NavDeepLink.Builder setAction(@NonNull String action)
Set the action for the NavDeepLink.
| Returns | |
|---|---|
@NonNull NavDeepLink.Builder |
This builder. |
| Throws | |
|---|---|
IllegalArgumentException |
if the action is empty. |
setMimeType
public final @NonNull NavDeepLink.Builder setMimeType(@NonNull String mimeType)
Set the mimeType for the NavDeepLink.
| Returns | |
|---|---|
@NonNull NavDeepLink.Builder |
This builder. |
setUriPattern
public final @NonNull NavDeepLink.Builder setUriPattern(@NonNull String uriPattern)
Set the uri pattern for the NavDeepLink.
| Returns | |
|---|---|
@NonNull NavDeepLink.Builder |
This builder. |
setUriPattern
public final @NonNull NavDeepLink.Builder <T extends Object> setUriPattern(
@NonNull String basePath,
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)
Set the uri pattern for the NavDeepLink.
Arguments extracted from destination T will be automatically appended to the base path provided in basePath.
Arguments are appended based on property name and in the same order as their declaration order in T. They are appended as query parameters if the argument has either:
-
a default value
-
a
NavTypeofCollectionNavType
Otherwise, the argument will be appended as path parameters. The final uriPattern is generated by concatenating uriPattern + path parameters + query parameters.
For example, the name property in this class does not meet either conditions and will be appended as a path param.
@Serializable
class MyClass(val name: String)
Given a uriPattern of "www.example.com", the generated final uriPattern will be www.example.com/{name}.
The name property in this class has a default value and will be appended as a query.
@Serializable
class MyClass(val name: String = "default")
Given a uriPattern of "www.example.com", the final generated uriPattern will be www.example.com?name={name}
The append order is based on their declaration order in T
@Serializable
class MyClass(val name: String = "default", val id: Int, val code: Int)
Given a uriPattern of "www.example.com", the final generated uriPattern will be www.example.com/{id}/{code}?name={name}. In this example, name is appended first as a query param, then id and code respectively as path params. The final pattern is then concatenated with uriPattern + path + query.
| Parameters | |
|---|---|
<T extends Object> |
The destination's route from KClass |
@NonNull String basePath |
The base uri path to append arguments onto |
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap |
map of destination arguments' kotlin type |
| Returns | |
|---|---|
@NonNull NavDeepLink.Builder |
This builder. |
setUriPattern
public final @NonNull NavDeepLink.Builder <T extends Object> setUriPattern(
@NonNull KClass<@NonNull T> route,
@NonNull String basePath,
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap
)
Set the uri pattern for the NavDeepLink.
Arguments extracted from destination T will be automatically appended to the base path provided in basePath.
Arguments are appended based on property name and in the same order as their declaration order in T. They are appended as query parameters if the argument has either:
-
a default value
-
a
NavTypeofCollectionNavType
Otherwise, the argument will be appended as path parameters. The final uriPattern is generated by concatenating uriPattern + path parameters + query parameters.
For example, the name property in this class does not meet either conditions and will be appended as a path param.
@Serializable
class MyClass(val name: String)
Given a uriPattern of "www.example.com", the generated final uriPattern will be www.example.com/{name}.
The name property in this class has a default value and will be appended as a query.
@Serializable
class MyClass(val name: String = "default")
Given a uriPattern of "www.example.com", the final generated uriPattern will be www.example.com?name={name}
The append order is based on their declaration order in T
@Serializable
class MyClass(val name: String = "default", val id: Int, val code: Int)
Given a uriPattern of "www.example.com", the final generated uriPattern will be www.example.com/{id}/{code}?name={name}. In this example, name is appended first as a query param, then id and code respectively as path params. The final pattern is then concatenated with uriPattern + path + query.
| Parameters | |
|---|---|
@NonNull KClass<@NonNull T> route |
The destination's route from KClass |
@NonNull String basePath |
The base uri path to append arguments onto |
@NonNull Map<@NonNull KType, @NonNull NavType<@NonNull ?>> typeMap |
map of destination arguments' kotlin type |
| Returns | |
|---|---|
@NonNull NavDeepLink.Builder |
This builder. |