# CollectionNavType

Artifact: [androidx.navigation:navigation-common](https://developer.android.com/jetpack/androidx/releases/navigation) [View Source](https://cs.android.com/search?q=file:androidx/navigation/CollectionNavType.kt+class:androidx.navigation.CollectionNavType) Added in [2.8.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.8.0)

*** ** * ** ***

Common/AllAndroid/JVMJavaScript
- Cmn

  ```
  abstract class CollectionNavType<T : Any?> : NavType<T>
  ```

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.navigation.NavType](https://developer.android.com/reference/kotlin/androidx/navigation/NavType)\<T\> ||
|   | ↳ | [androidx.navigation.CollectionNavType](https://developer.android.com/reference/kotlin/androidx/navigation/CollectionNavType) |

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/navigation/NavType` for `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-collection/index.html` such as arrays, lists, maps.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | the type of the data that is supported by this NavType |

## Summary

| ### Public constructors |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?> https://developer.android.com/reference/kotlin/androidx/navigation/CollectionNavType#CollectionNavType(kotlin.Boolean)(isNullableAllowed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)` | Cmn |

| ### Public functions |
|---|---|---|
| `abstract T` | `https://developer.android.com/reference/kotlin/androidx/navigation/CollectionNavType#emptyCollection()()` Create and return an empty collection of type `https://developer.android.com/reference/kotlin/androidx/navigation/CollectionNavType` | Cmn |
| `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>` | `https://developer.android.com/reference/kotlin/androidx/navigation/CollectionNavType#serializeAsValues(kotlin.Any)(value: T)` Serialize a value of this NavType into a list of String. | Cmn |

### Inherited functions

From [androidx.navigation.NavType](https://developer.android.com/reference/kotlin/androidx/navigation/NavType) `abstract operator T?` `https://developer.android.com/reference/kotlin/androidx/navigation/NavType#get(androidx.savedstate.SavedState,kotlin.String)(bundle: https://developer.android.com/reference/kotlin/androidx/savedstate/SavedState, key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`

Get a value of this type from the `savedState`
Cmn `abstract T` `https://developer.android.com/reference/kotlin/androidx/navigation/NavType#parseValue(kotlin.String)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`

Parse a value of this type from a String.
Cmn `open T` `https://developer.android.com/reference/kotlin/androidx/navigation/NavType#parseValue(kotlin.String,kotlin.Any)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, previousValue: T)`

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.
Cmn `abstract https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/navigation/NavType#put(androidx.savedstate.SavedState,kotlin.String,kotlin.Any)(bundle: https://developer.android.com/reference/kotlin/androidx/savedstate/SavedState, key: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, value: T)`

Put a value of this type in the `savedState`
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` `https://developer.android.com/reference/kotlin/androidx/navigation/NavType#serializeAsValue(kotlin.Any)(value: T)`

Serialize a value of this NavType into a String.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/navigation/NavType#valueEquals(kotlin.Any,kotlin.Any)(value: T, other: T)`

Compares two values of type `https://developer.android.com/reference/kotlin/androidx/navigation/NavType` and returns true if values are equal.
Cmn

### Inherited properties

From [androidx.navigation.NavType](https://developer.android.com/reference/kotlin/androidx/navigation/NavType) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/navigation/NavType#isNullableAllowed()`

Check if an argument with this type can hold a null value.
Cmn `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` `https://developer.android.com/reference/kotlin/androidx/navigation/NavType#name()`

The name of this type.
Cmn

## Public constructors

### CollectionNavType

Cmn

```
<T : Any?> CollectionNavType(isNullableAllowed: Boolean)
```

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?>` | the type of the data that is supported by this NavType |
| `isNullableAllowed: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | whether the argument of this type can hold a null value |

## Public functions

### emptyCollection

Cmn Added in [2.8.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.8.0)

```
abstract fun emptyCollection(): T
```

Create and return an empty collection of type `https://developer.android.com/reference/kotlin/androidx/navigation/CollectionNavType`

For example, `https://developer.android.com/reference/kotlin/androidx/navigation/CollectionNavType` of type List should return emptyList().

### serializeAsValues

Cmn Added in [2.8.0](https://developer.android.com/jetpack/androidx/releases/navigation#2.8.0)

```
abstract fun serializeAsValues(value: T): List<String>
```

Serialize a value of this NavType into a list of String.

Each element in the collection should be converted to an individual String element of the returned list.

Note: Elements should be encoded with [Uri.encode](https://developer.android.com/reference/android/net/Uri#encode(java.lang.String))

| Parameters |
|---|---|
| `value: T` | a value of this NavType |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html>` | List containing encoded and serialized String representation of `https://developer.android.com/reference/kotlin/androidx/navigation/CollectionNavType#serializeAsValues(kotlin.Any)` |