# ArrayCreatingInputMerger

# ArrayCreatingInputMerger

Artifact:[androidx.work:work-runtime](https://developer.android.com/jetpack/androidx/releases/work)  
[View Source](https://cs.android.com/search?q=file:androidx/work/ArrayCreatingInputMerger.kt+class:androidx.work.ArrayCreatingInputMerger)  
Added in[1.0.0](https://developer.android.com/jetpack/androidx/releases/work#1.0.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/work/ArrayCreatingInputMerger "View this page in Java")

<br />

```
class ArrayCreatingInputMerger : InputMerger
```

<br />

|---|---|---------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)                                                    |||
| ↳ | [androidx.work.InputMerger](https://developer.android.com/reference/kotlin/androidx/work/InputMerger)                              ||
|   | ↳ | [androidx.work.ArrayCreatingInputMerger](https://developer.android.com/reference/kotlin/androidx/work/ArrayCreatingInputMerger) |

*** ** * ** ***

An[InputMerger](https://developer.android.com/reference/kotlin/androidx/work/InputMerger)that attempts to merge the inputs, creating arrays when necessary. For each input, we look at each key:

- If this is the first time we encountered the key:

  - If it's an array, put it in the output

  - If it's a primitive, turn it into a size 1 array and put it in the output

- Else (we have encountered the key before):

  - If the value type matches the old value type:

    - If they are arrays, concatenate them

    - If they are primitives, turn them into a size 2 array

  - Else if one is an array and the other is a primitive of that type: \* Make a longer array and concatenate them

  - Else throw an[IllegalArgumentException](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html)because the types don't match.

If a value by a key is`null`, it is considered to have type`String`, because it is the only nullable typed allowed in[Data](https://developer.android.com/reference/kotlin/androidx/work/Data).

## Summary

|                                                             ### Public constructors                                                              |
|--------------------------------------------------------------------------------------------------------------------------------------------------|
| [ArrayCreatingInputMerger](https://developer.android.com/reference/kotlin/androidx/work/ArrayCreatingInputMerger#ArrayCreatingInputMerger())`()` |

|                               ### Public functions                               |
|----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `open `[Data](https://developer.android.com/reference/kotlin/androidx/work/Data) | [merge](https://developer.android.com/reference/kotlin/androidx/work/ArrayCreatingInputMerger#merge(kotlin.collections.List))`(inputs: `[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Data](https://developer.android.com/reference/kotlin/androidx/work/Data)`>)` Merges a list of[Data](https://developer.android.com/reference/kotlin/androidx/work/Data)and outputs a single Data object. |

## Public constructors

### ArrayCreatingInputMerger

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

```
ArrayCreatingInputMerger()
```  

## Public functions

### merge

```
open fun merge(inputs: List<Data>): Data
```

Merges a list of[Data](https://developer.android.com/reference/kotlin/androidx/work/Data)and outputs a single Data object.  

|                                                                                     Parameters                                                                                     |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| `inputs: `[List](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html)`<`[Data](https://developer.android.com/reference/kotlin/androidx/work/Data)`>` | A list of[Data](https://developer.android.com/reference/kotlin/androidx/work/Data) |

|                                  Returns                                  |
|---------------------------------------------------------------------------|-------------------|
| [Data](https://developer.android.com/reference/kotlin/androidx/work/Data) | The merged output |