# InputMerger

# InputMerger

Artifact: [androidx.work:work-runtime](https://developer.android.com/jetpack/androidx/releases/work)  
[View Source](https://cs.android.com/search?q=file:androidx/work/InputMerger.kt+class:androidx.work.InputMerger)  
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/InputMerger "View this page in Java")


```
abstract class InputMerger
```

<br />

Known direct subclasses  
[ArrayCreatingInputMerger](https://developer.android.com/reference/kotlin/androidx/work/ArrayCreatingInputMerger), [OverwritingInputMerger](https://developer.android.com/reference/kotlin/androidx/work/OverwritingInputMerger)  

|-------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [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. |
| [OverwritingInputMerger](https://developer.android.com/reference/kotlin/androidx/work/OverwritingInputMerger)     | An [InputMerger](https://developer.android.com/reference/kotlin/androidx/work/InputMerger) that attempts to add all keys from all inputs to the output.       |

*** ** * ** ***

An abstract class that allows the user to define how to merge a list of inputs to a [ListenableWorker](https://developer.android.com/reference/kotlin/androidx/work/ListenableWorker).

Before workers run, they receive input [Data](https://developer.android.com/reference/kotlin/androidx/work/Data) from their parent workers, as well as anything specified directly to them via [WorkRequest.Builder.setInputData](https://developer.android.com/reference/kotlin/androidx/work/WorkRequest.Builder#setInputData(androidx.work.Data)). An InputMerger takes all of these objects and converts them to a single merged [Data](https://developer.android.com/reference/kotlin/androidx/work/Data) to be used as the worker input. [WorkManager](https://developer.android.com/reference/kotlin/androidx/work/WorkManager) offers two concrete InputMerger implementations: [OverwritingInputMerger](https://developer.android.com/reference/kotlin/androidx/work/OverwritingInputMerger) and [ArrayCreatingInputMerger](https://developer.android.com/reference/kotlin/androidx/work/ArrayCreatingInputMerger).

Note that the list of inputs to merge is in an unspecified order. You should not make assumptions about the order of inputs.

## Summary

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

|                                 ### Public functions                                 |
|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `abstract `[Data](https://developer.android.com/reference/kotlin/androidx/work/Data) | [merge](https://developer.android.com/reference/kotlin/androidx/work/InputMerger#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

### InputMerger

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

```
InputMerger()
```  

## Public functions

### merge

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

```
abstract 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 |