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

*** ** * ** ***


```
public abstract class InputMerger
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/work/ArrayCreatingInputMerger` | An `https://developer.android.com/reference/androidx/work/InputMerger` that attempts to merge the inputs, creating arrays when necessary. |
| `https://developer.android.com/reference/androidx/work/OverwritingInputMerger` | An `https://developer.android.com/reference/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 `https://developer.android.com/reference/androidx/work/ListenableWorker`.

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

| ### Public methods |
|---|---|
| `abstract @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Data` | `https://developer.android.com/reference/androidx/work/InputMerger#merge(kotlin.collections.List)(@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/androidx/work/Data> inputs)` Merges a list of `https://developer.android.com/reference/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)

```
public InputMerger()
```

## Public methods

### merge

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

```
public abstract @NonNull Data merge(@NonNull List<@NonNull Data> inputs)
```

Merges a list of `https://developer.android.com/reference/androidx/work/Data` and outputs a single Data object.

| Parameters |
|---|---|
| `@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/androidx/work/Data> inputs` | A list of `https://developer.android.com/reference/androidx/work/Data` |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/work/Data` | The merged output |