# 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)

*** ** * ** ***


```
public abstract class CollectionNavType<T extends Object> extends NavType<@NonNull T>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.navigation.NavType](https://developer.android.com/reference/androidx/navigation/NavType)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) T\> ||
|   | ↳ | [androidx.navigation.CollectionNavType](https://developer.android.com/reference/androidx/navigation/CollectionNavType) |

*** ** * ** ***

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

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | the type of the data that is supported by this NavType |

## Summary

| ### Public constructors |
|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html> https://developer.android.com/reference/androidx/navigation/CollectionNavType#CollectionNavType(kotlin.Boolean)(boolean isNullableAllowed)` |

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull T` | `https://developer.android.com/reference/androidx/navigation/CollectionNavType#emptyCollection()()` Create and return an empty collection of type `https://developer.android.com/reference/androidx/navigation/CollectionNavType` |
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html>` | `https://developer.android.com/reference/androidx/navigation/CollectionNavType#serializeAsValues(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull T value)` Serialize a value of this NavType into a list of String. |

### Inherited methods

From [androidx.navigation.NavType](https://developer.android.com/reference/androidx/navigation/NavType) `abstract T` `https://developer.android.com/reference/androidx/navigation/NavType#get(androidx.savedstate.SavedState,kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/SavedState bundle, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html key)`

Get a value of this type from the `savedState`
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/androidx/navigation/NavType#getName()()`

The name of this type.
`boolean` `https://developer.android.com/reference/androidx/navigation/NavType#isNullableAllowed()()`

Check if an argument with this type can hold a null value.
`abstract @https://developer.android.com/reference/androidx/annotation/NonNull T` `https://developer.android.com/reference/androidx/navigation/NavType#parseValue(kotlin.String)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value)`

Parse a value of this type from a String.
`@https://developer.android.com/reference/androidx/annotation/NonNull T` `https://developer.android.com/reference/androidx/navigation/NavType#parseValue(kotlin.String,kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html value, @https://developer.android.com/reference/androidx/annotation/NonNull T previousValue)`

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.
`abstract void` `https://developer.android.com/reference/androidx/navigation/NavType#put(androidx.savedstate.SavedState,kotlin.String,kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/savedstate/SavedState bundle, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html key, @https://developer.android.com/reference/androidx/annotation/NonNull T value)`

Put a value of this type in the `savedState`
`@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html` `https://developer.android.com/reference/androidx/navigation/NavType#serializeAsValue(kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull T value)`

Serialize a value of this NavType into a String.
`boolean` `https://developer.android.com/reference/androidx/navigation/NavType#valueEquals(kotlin.Any,kotlin.Any)(@https://developer.android.com/reference/androidx/annotation/NonNull T value, @https://developer.android.com/reference/androidx/annotation/NonNull T other)`

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

## Public constructors

### CollectionNavType

```
public <T extends Object> CollectionNavType(boolean isNullableAllowed)
```

| Parameters |
|---|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html>` | the type of the data that is supported by this NavType |
| `boolean isNullableAllowed` | whether the argument of this type can hold a null value |

## Public methods

### emptyCollection

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

```
public abstract @NonNull T emptyCollection()
```

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

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

### serializeAsValues

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

```
public abstract @NonNull List<@NonNull String> serializeAsValues(@NonNull T value)
```

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 |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull T value` | a value of this NavType |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/String.html>` | List containing encoded and serialized String representation of `https://developer.android.com/reference/androidx/navigation/CollectionNavType#serializeAsValues(kotlin.Any)` |